2024-12-12 18:33:44 +00:00
|
|
|
import { Challenge } from "@/utils/features/challenges/challengesSlice"
|
|
|
|
import { FontAwesome6 } from "@expo/vector-icons"
|
2024-12-14 10:55:11 +00:00
|
|
|
import { View, ViewStyle } from "react-native"
|
2024-12-12 22:41:20 +00:00
|
|
|
import { Button, Card, IconButton, MD3Colors, Surface, Text } from "react-native-paper"
|
2024-12-12 18:33:44 +00:00
|
|
|
|
2024-12-12 22:41:20 +00:00
|
|
|
export type ChallengeCardProps = {
|
2024-12-14 10:55:11 +00:00
|
|
|
challenge: Challenge | null,
|
2024-12-12 22:41:20 +00:00
|
|
|
onSuccess?: () => void,
|
|
|
|
onFail?: () => void,
|
|
|
|
onDelete?: () => void,
|
|
|
|
onEdit?: () => void,
|
2024-12-14 10:55:11 +00:00
|
|
|
style?: ViewStyle,
|
2024-12-12 22:41:20 +00:00
|
|
|
}
|
|
|
|
|
2024-12-14 10:55:11 +00:00
|
|
|
export default function ChallengeCard({ challenge, onSuccess, onFail, onDelete, onEdit, style }: ChallengeCardProps) {
|
2024-12-12 18:33:44 +00:00
|
|
|
return (
|
2024-12-14 10:55:11 +00:00
|
|
|
<Surface elevation={2} style={{ ...style, borderRadius: 20 }}>
|
2024-12-12 22:41:20 +00:00
|
|
|
<Card.Title
|
2024-12-14 10:55:11 +00:00
|
|
|
title={challenge?.title}
|
2024-12-12 22:41:20 +00:00
|
|
|
titleStyle={{ textAlign: 'center' }}
|
|
|
|
titleVariant='headlineMedium'
|
|
|
|
right={(props) => onEdit ? <IconButton {...props} icon='file-document-edit-outline' onPress={() => onEdit()} /> : <></>} />
|
|
|
|
<View style={{ flexGrow: 1 }}>
|
|
|
|
<Surface elevation={5} mode='flat' style={{ flexGrow: 1, paddingHorizontal: 15, paddingVertical: 20 }}>
|
2024-12-14 10:55:11 +00:00
|
|
|
<Text variant='bodyLarge' style={{ flexGrow: 1 }}>{challenge?.description}</Text>
|
2024-12-12 22:41:20 +00:00
|
|
|
<Text variant='titleMedium'>
|
2024-12-14 10:55:11 +00:00
|
|
|
Récompense : {challenge?.reward} <FontAwesome6 name='coins' />
|
2024-12-12 22:41:20 +00:00
|
|
|
</Text>
|
|
|
|
</Surface>
|
|
|
|
</View>
|
|
|
|
<View style={{ flexWrap: 'wrap', flexDirection: 'row', justifyContent: 'space-around', padding: 15 }}>
|
|
|
|
{onFail && <Button key='failBtn' mode='outlined' icon='cancel' onPress={() => onFail()}>
|
2024-12-12 23:02:58 +00:00
|
|
|
Échouer
|
2024-12-12 22:41:20 +00:00
|
|
|
</Button>}
|
|
|
|
{onSuccess && <Button key='successBtn' mode='contained' icon='check' onPress={() => onSuccess()}>
|
|
|
|
Terminer
|
|
|
|
</Button>}
|
2024-12-14 10:55:11 +00:00
|
|
|
{onDelete && <Button key='deleteBtn' mode='contained' icon='delete' onPress={() => onDelete()} buttonColor={MD3Colors.error60} textColor={MD3Colors.secondary10}>
|
2024-12-12 22:41:20 +00:00
|
|
|
Supprimer
|
|
|
|
</Button>}
|
|
|
|
</View>
|
|
|
|
</Surface>
|
2024-12-12 18:33:44 +00:00
|
|
|
)
|
|
|
|
}
|