chore: add comming soon category

This commit is contained in:
2026-03-07 17:59:34 +01:00
parent 0eb775f3ef
commit ab7d8929a8
4 changed files with 81 additions and 6 deletions
@@ -10,6 +10,7 @@ import {
KeyboardAvoidingView,
Platform,
ScrollView,
Switch,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { spacing, fontSize, borderRadius } from "../../theme";
@@ -44,6 +45,7 @@ export default function CategoriesScreen() {
const [name, setName] = useState("");
const [color, setColor] = useState("#7c3aed");
const [hexInput, setHexInput] = useState("#7c3aed");
const [isComingSoon, setIsComingSoon] = useState(false);
const [saving, setSaving] = useState(false);
const { alert, showError, showSuccess, showConfirm, hideAlert } = useAlert();
@@ -74,6 +76,7 @@ export default function CategoriesScreen() {
setEditingCategory(null);
setName("");
selectColor("#7c3aed");
setIsComingSoon(false);
setModalVisible(true);
};
@@ -81,12 +84,14 @@ export default function CategoriesScreen() {
setEditingCategory(cat);
setName(cat.name);
selectColor(cat.color || "#7c3aed");
setIsComingSoon(cat.is_coming_soon || false);
setModalVisible(true);
};
const closeModal = () => {
setModalVisible(false);
setName("");
setIsComingSoon(false);
setEditingCategory(null);
};
@@ -102,7 +107,7 @@ export default function CategoriesScreen() {
}
setSaving(true);
if (editingCategory) {
const res = await updateCategoryAdmin(editingCategory.id, trimmed, color);
const res = await updateCategoryAdmin(editingCategory.id, trimmed, color, isComingSoon);
if (res.success) {
showSuccess("Succès", "Catégorie modifiée");
closeModal();
@@ -111,7 +116,7 @@ export default function CategoriesScreen() {
showError("Erreur", res.error || "Erreur");
}
} else {
const res = await createCategoryAdmin(trimmed, color);
const res = await createCategoryAdmin(trimmed, color, isComingSoon);
if (res.success) {
showSuccess("Succès", "Catégorie créée");
closeModal();
@@ -175,6 +180,15 @@ export default function CategoriesScreen() {
textTransform: "capitalize",
},
catDate: { fontSize: fontSize.xs, color: colors.textSecondary, marginTop: 2 },
comingSoonBadge: {
backgroundColor: colors.warning + "33",
borderWidth: 1,
borderColor: colors.warning,
borderRadius: borderRadius.sm,
paddingHorizontal: 6,
paddingVertical: 2,
},
comingSoonBadgeText: { fontSize: fontSize.xs, color: colors.warning, fontWeight: "600" },
actions: { flexDirection: "row", gap: spacing.s },
actionBtn: { padding: 8 },
overlay: {
@@ -230,6 +244,15 @@ export default function CategoriesScreen() {
borderRadius: borderRadius.sm,
borderWidth: 2,
},
comingSoonRow: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
paddingVertical: spacing.s,
borderTopWidth: 1,
borderTopColor: colors.border,
},
comingSoonHint: { fontSize: fontSize.xs, color: colors.textMuted, marginTop: 2 },
modalBtns: { flexDirection: "row", gap: spacing.s },
cancelBtn: {
flex: 1,
@@ -285,7 +308,14 @@ export default function CategoriesScreen() {
]}
/>
<View>
<Text style={styles.catName}>{item.name}</Text>
<View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
<Text style={styles.catName}>{item.name}</Text>
{item.is_coming_soon && (
<View style={styles.comingSoonBadge}>
<Text style={styles.comingSoonBadgeText}>Prochainement</Text>
</View>
)}
</View>
<Text style={styles.catDate}>
Créée le{" "}
{new Date(item.created_at).toLocaleDateString("fr-FR")}
@@ -378,6 +408,21 @@ export default function CategoriesScreen() {
</View>
</View>
<View style={styles.comingSoonRow}>
<View>
<Text style={styles.label}>Prochainement</Text>
<Text style={styles.comingSoonHint}>
Affiche un message d'attente aux clients
</Text>
</View>
<Switch
value={isComingSoon}
onValueChange={setIsComingSoon}
trackColor={{ false: colors.border, true: colors.accent }}
thumbColor={colors.textWhite}
/>
</View>
<View style={styles.modalBtns}>
<TouchableOpacity style={styles.cancelBtn} onPress={closeModal}>
<Text style={styles.cancelBtnText}>Annuler</Text>