From a5f761062ebb3f69281d917c46ca13387e60fad2 Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 11 Mar 2026 08:55:05 +0100 Subject: [PATCH] goal creation style fix --- apps/admin/data/fitai.db | Bin 172032 -> 172032 bytes .../src/components/GoalCreationModal.tsx | 898 ++++++++++-------- 2 files changed, 499 insertions(+), 399 deletions(-) diff --git a/apps/admin/data/fitai.db b/apps/admin/data/fitai.db index 823a9751cbea5469abe50cef8187c1aa686cbfb1..25a5e7b590c9598546fa19c75bc1ca59ed022794 100644 GIT binary patch delta 89 zcmZoTz}0YoYl1Xm%0wAw#*~c-3(xcNJ!N3xOJ(3M void; - onSubmit: (goalData: CreateGoalData) => Promise; + visible: boolean; + onClose: () => void; + onSubmit: (goalData: CreateGoalData) => Promise; } const GOAL_TYPES = [ - { value: 'weight_target', label: 'Weight Target' }, - { value: 'strength_milestone', label: 'Strength Milestone' }, - { value: 'endurance_target', label: 'Endurance Target' }, - { value: 'flexibility_goal', label: 'Flexibility Goal' }, - { value: 'habit_building', label: 'Habit Building' }, - { value: 'custom', label: 'Custom Goal' }, + { value: "weight_target", label: "Weight Target" }, + { value: "strength_milestone", label: "Strength Milestone" }, + { value: "endurance_target", label: "Endurance Target" }, + { value: "flexibility_goal", label: "Flexibility Goal" }, + { value: "habit_building", label: "Habit Building" }, + { value: "custom", label: "Custom Goal" }, ] as const; const PRIORITIES = [ - { value: 'low', label: 'Low', color: '#10b981' }, - { value: 'medium', label: 'Medium', color: '#f59e0b' }, - { value: 'high', label: 'High', color: '#ef4444' }, + { value: "low", label: "Low" }, + { value: "medium", label: "Medium" }, + { value: "high", label: "High" }, ] as const; -export function GoalCreationModal({ visible, onClose, onSubmit }: GoalCreationModalProps) { - const [goalType, setGoalType] = useState('weight_target'); - const [title, setTitle] = useState(''); - const [description, setDescription] = useState(''); - const [targetValue, setTargetValue] = useState(''); - const [currentValue, setCurrentValue] = useState(''); - const [unit, setUnit] = useState(''); - const [priority, setPriority] = useState<'low' | 'medium' | 'high'>('medium'); - const [targetDate, setTargetDate] = useState(); - const [showDatePicker, setShowDatePicker] = useState(false); - const [submitting, setSubmitting] = useState(false); +export function GoalCreationModal({ + visible, + onClose, + onSubmit, +}: GoalCreationModalProps) { + const { colors, typography } = useTheme(); + const [goalType, setGoalType] = + useState("weight_target"); + const [title, setTitle] = useState(""); + const [description, setDescription] = useState(""); + const [targetValue, setTargetValue] = useState(""); + const [currentValue, setCurrentValue] = useState(""); + const [unit, setUnit] = useState(""); + const [priority, setPriority] = useState<"low" | "medium" | "high">("medium"); + const [targetDate, setTargetDate] = useState(); + const [showDatePicker, setShowDatePicker] = useState(false); + const [submitting, setSubmitting] = useState(false); - const resetForm = () => { - setGoalType('weight_target'); - setTitle(''); - setDescription(''); - setTargetValue(''); - setCurrentValue(''); - setUnit(''); - setPriority('medium'); - setTargetDate(undefined); - }; + const resetForm = () => { + setGoalType("weight_target"); + setTitle(""); + setDescription(""); + setTargetValue(""); + setCurrentValue(""); + setUnit(""); + setPriority("medium"); + setTargetDate(undefined); + }; - const handleSubmit = async () => { - if (!title.trim()) { - Alert.alert('Error', 'Please enter a goal title'); - return; - } + const handleSubmit = async () => { + if (!title.trim()) { + Alert.alert("Error", "Please enter a goal title"); + return; + } - setSubmitting(true); - try { - const goalData: CreateGoalData = { - goalType, - title: title.trim(), - description: description.trim() || undefined, - targetValue: targetValue ? parseFloat(targetValue) : undefined, - currentValue: currentValue ? parseFloat(currentValue) : undefined, - unit: unit.trim() || undefined, - targetDate: targetDate?.toISOString(), - priority, - }; + setSubmitting(true); + try { + const goalData: CreateGoalData = { + goalType, + title: title.trim(), + description: description.trim() || undefined, + targetValue: targetValue ? parseFloat(targetValue) : undefined, + currentValue: currentValue ? parseFloat(currentValue) : undefined, + unit: unit.trim() || undefined, + targetDate: targetDate?.toISOString(), + priority, + }; - await onSubmit(goalData); - resetForm(); - onClose(); - } catch (error) { - console.error('Error creating goal:', error); - Alert.alert('Error', 'Failed to create goal. Please try again.'); - } finally { - setSubmitting(false); - } - }; + await onSubmit(goalData); + resetForm(); + onClose(); + } catch (error) { + console.error("Error creating goal:", error); + Alert.alert("Error", "Failed to create goal. Please try again."); + } finally { + setSubmitting(false); + } + }; - const handleClose = () => { - resetForm(); - onClose(); - }; + const handleClose = () => { + resetForm(); + onClose(); + }; - return ( - { + switch (p) { + case "high": + return colors.danger; + case "medium": + return colors.warning; + case "low": + return colors.success; + } + }; + + return ( + + + - - - Create Fitness Goal - - - - + + Create Fitness Goal + + + + + - - {/* Goal Type */} - - Goal Type * - - {GOAL_TYPES.map((type) => ( - setGoalType(type.value)} - > - - {type.label} - - - ))} - - + + {/* Goal Type */} + + + Goal Type * + + + {GOAL_TYPES.map((type) => ( + setGoalType(type.value)} + > + + {type.label} + + + ))} + + - {/* Title */} - - Title * - - + {/* Title */} + + + Title * + + + - {/* Description */} - - Description - - + {/* Description */} + + + Description + + + - {/* Target Value & Unit */} - - - Target Value - - - - Unit - - - - - {/* Current Value */} - - Current Value - - - - {/* Target Date */} - - Target Date - setShowDatePicker(!showDatePicker)} - > - - {targetDate ? targetDate.toLocaleDateString() : 'Select target date'} - - - - - - {showDatePicker && ( - - { - setShowDatePicker(Platform.OS === 'ios'); - if (selectedDate) { - setTargetDate(selectedDate); - } - }} - minimumDate={new Date()} - themeVariant="light" - /> - - )} - - {/* Priority */} - - Priority - - {PRIORITIES.map((p) => ( - setPriority(p.value)} - > - - {p.label} - - - ))} - - - - - - - - {submitting ? 'Creating...' : 'Create Goal'} - - - + {/* Target Value & Unit */} + + + + Target Value + + - - ); + + + Unit + + + + + + {/* Current Value */} + + + Current Value + + + + + {/* Target Date */} + + + Target Date + + setShowDatePicker(!showDatePicker)} + > + + {targetDate + ? targetDate.toLocaleDateString() + : "Select target date"} + + + + + + {showDatePicker && ( + + { + setShowDatePicker(Platform.OS === "ios"); + if (selectedDate) { + setTargetDate(selectedDate); + } + }} + minimumDate={new Date()} + themeVariant="light" + /> + + )} + + {/* Priority */} + + + Priority + + + {PRIORITIES.map((p) => ( + setPriority(p.value)} + > + + {p.label} + + + ))} + + + + + + + + + + ); } const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#f9fafb', - }, - header: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - padding: 20, - paddingTop: Platform.OS === 'ios' ? 60 : 20, - backgroundColor: '#fff', - borderBottomWidth: 1, - borderBottomColor: '#e5e7eb', - }, - headerTitle: { - fontSize: 20, - fontWeight: '600', - color: '#111827', - }, - closeButton: { - padding: 4, - }, - content: { - flex: 1, - padding: 20, - }, - field: { - marginBottom: 20, - }, - label: { - fontSize: 14, - fontWeight: '600', - color: '#374151', - marginBottom: 8, - }, - input: { - backgroundColor: '#fff', - borderWidth: 1, - borderColor: '#d1d5db', - borderRadius: 8, - padding: 12, - fontSize: 16, - color: '#111827', - }, - textArea: { - height: 80, - textAlignVertical: 'top', - }, - row: { - flexDirection: 'row', - gap: 12, - }, - flex1: { - flex: 1, - }, - typeScroll: { - flexGrow: 0, - }, - typeButton: { - paddingHorizontal: 16, - paddingVertical: 8, - borderRadius: 8, - borderWidth: 1, - borderColor: '#d1d5db', - backgroundColor: '#fff', - marginRight: 8, - }, - typeButtonActive: { - backgroundColor: '#2563eb', - borderColor: '#2563eb', - }, - typeButtonText: { - fontSize: 14, - color: '#374151', - }, - typeButtonTextActive: { - color: '#fff', - fontWeight: '600', - }, - dateButton: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - backgroundColor: '#fff', - borderWidth: 1, - borderColor: '#d1d5db', - borderRadius: 8, - padding: 12, - }, - dateText: { - fontSize: 16, - color: '#111827', - }, - datePlaceholder: { - fontSize: 16, - color: '#9ca3af', - }, - priorityContainer: { - flexDirection: 'row', - gap: 12, - }, - priorityButton: { - flex: 1, - paddingVertical: 12, - borderRadius: 8, - borderWidth: 1, - borderColor: '#d1d5db', - backgroundColor: '#fff', - alignItems: 'center', - }, - priorityButtonText: { - fontSize: 14, - color: '#374151', - fontWeight: '500', - }, - priorityButtonTextActive: { - color: '#fff', - fontWeight: '600', - }, - footer: { - padding: 20, - paddingBottom: Platform.OS === 'ios' ? 40 : 20, - backgroundColor: '#fff', - borderTopWidth: 1, - borderTopColor: '#e5e7eb', - }, - submitButton: { - backgroundColor: '#2563eb', - borderRadius: 8, - padding: 16, - alignItems: 'center', - }, - submitButtonDisabled: { - opacity: 0.6, - }, - submitButtonText: { - fontSize: 16, - fontWeight: '600', - color: '#fff', - }, - datePickerContainer: { - backgroundColor: '#fff', - borderRadius: 8, - borderWidth: 1, - borderColor: '#d1d5db', - marginTop: 8, - overflow: 'hidden', - }, + container: { + flex: 1, + }, + header: { + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", + padding: 20, + paddingTop: Platform.OS === "ios" ? 60 : 20, + borderBottomWidth: 1, + }, + closeButton: { + padding: 4, + }, + content: { + flex: 1, + padding: 20, + }, + field: { + marginBottom: 20, + }, + input: { + borderWidth: 1, + borderRadius: 8, + padding: 12, + fontSize: 16, + marginTop: 8, + }, + textArea: { + height: 80, + textAlignVertical: "top", + }, + row: { + flexDirection: "row", + gap: 12, + }, + flex1: { + flex: 1, + }, + typeScroll: { + flexGrow: 0, + marginTop: 8, + }, + typeButton: { + paddingHorizontal: 16, + paddingVertical: 8, + borderRadius: 8, + borderWidth: 1, + marginRight: 8, + }, + dateButton: { + flexDirection: "row", + justifyContent: "space-between", + alignItems: "center", + borderWidth: 1, + borderRadius: 8, + padding: 12, + marginTop: 8, + }, + priorityContainer: { + flexDirection: "row", + gap: 12, + marginTop: 8, + }, + priorityButton: { + flex: 1, + paddingVertical: 12, + borderRadius: 8, + borderWidth: 1, + alignItems: "center", + }, + footer: { + padding: 20, + paddingBottom: Platform.OS === "ios" ? 40 : 20, + borderTopWidth: 1, + }, + submitButton: { + width: "100%", + }, + datePickerContainer: { + borderRadius: 8, + borderWidth: 1, + marginTop: 8, + overflow: "hidden", + }, });