chore: add palier amende

This commit is contained in:
2026-03-25 11:11:16 +01:00
parent ac5ec11f54
commit 4aa356f9fe
2 changed files with 82 additions and 0 deletions
+6
View File
@@ -747,9 +747,15 @@ export const DEFAULT_DELIVERY_SCHEDULE: DeliverySchedule = {
saturday: { ...DEFAULT_DAY }, sunday: { ...DEFAULT_DAY }, saturday: { ...DEFAULT_DAY }, sunday: { ...DEFAULT_DAY },
}; };
export interface PenaltyTier {
min_cancel: number;
amount: number;
}
export interface AppSettings { export interface AppSettings {
penalties_enabled: boolean; penalties_enabled: boolean;
show_amende_score: boolean; show_amende_score: boolean;
penalty_tiers: PenaltyTier[];
points_enabled: boolean; points_enabled: boolean;
points_pools: PointsPool[]; points_pools: PointsPool[];
referral_enabled: boolean; referral_enabled: boolean;
@@ -646,6 +646,12 @@ export default function SettingsScreen() {
const [settings, setSettings] = useState<AppSettings>({ const [settings, setSettings] = useState<AppSettings>({
penalties_enabled: true, penalties_enabled: true,
show_amende_score: true, show_amende_score: true,
penalty_tiers: [
{ min_cancel: 0, amount: 20 },
{ min_cancel: 1, amount: 50 },
{ min_cancel: 2, amount: 100 },
{ min_cancel: 3, amount: 150 },
],
points_enabled: true, points_enabled: true,
points_pools: [ points_pools: [
{ key: "pool_0", name: "Pool 1", categories: [], tiers: [] }, { key: "pool_0", name: "Pool 1", categories: [], tiers: [] },
@@ -951,6 +957,76 @@ export default function SettingsScreen() {
thumbColor="#fff" thumbColor="#fff"
/> />
</View> </View>
<View style={[s.row, { flexDirection: "column", alignItems: "flex-start", gap: spacing.s }]}>
<View style={{ flexDirection: "row", justifyContent: "space-between", width: "100%", alignItems: "center" }}>
<Text style={s.rowLabel}>Barème des amendes</Text>
<TouchableOpacity
onPress={() =>
setSettings((prev) => ({
...prev,
penalty_tiers: [
...prev.penalty_tiers,
{
min_cancel: prev.penalty_tiers.length > 0
? prev.penalty_tiers[prev.penalty_tiers.length - 1].min_cancel + 1
: 0,
amount: 0,
},
],
}))
}
>
<Ionicons name="add-circle-outline" size={22} color={colors.accent} />
</TouchableOpacity>
</View>
<View style={{ flexDirection: "row", width: "100%", marginBottom: 2 }}>
<Text style={[s.rowDesc, { flex: 1 }]}>À partir de (annul.)</Text>
<Text style={[s.rowDesc, { width: 80, textAlign: "center" }]}>Montant</Text>
<View style={{ width: 28 }} />
</View>
{settings.penalty_tiers.map((tier, i) => (
<View key={i} style={{ flexDirection: "row", alignItems: "center", width: "100%", gap: spacing.s }}>
<TextInput
style={[s.thresholdInput, { flex: 1, textAlign: "center" }]}
value={String(tier.min_cancel)}
onChangeText={(v) => {
const n = parseInt(v, 10);
setSettings((prev) => {
const tiers = [...prev.penalty_tiers];
tiers[i] = { ...tiers[i], min_cancel: isNaN(n) ? 0 : n };
return { ...prev, penalty_tiers: tiers };
});
}}
keyboardType="number-pad"
placeholderTextColor={colors.textMuted}
/>
<TextInput
style={[s.thresholdInput, { width: 80, textAlign: "center" }]}
value={String(tier.amount)}
onChangeText={(v) => {
const n = parseInt(v, 10);
setSettings((prev) => {
const tiers = [...prev.penalty_tiers];
tiers[i] = { ...tiers[i], amount: isNaN(n) ? 0 : n };
return { ...prev, penalty_tiers: tiers };
});
}}
keyboardType="number-pad"
placeholderTextColor={colors.textMuted}
/>
<TouchableOpacity
onPress={() =>
setSettings((prev) => ({
...prev,
penalty_tiers: prev.penalty_tiers.filter((_, j) => j !== i),
}))
}
>
<Ionicons name="remove-circle-outline" size={22} color={colors.danger} />
</TouchableOpacity>
</View>
))}
</View>
</View> </View>
{/* Parrainage */} {/* Parrainage */}