new version frontend-webpage

This commit is contained in:
José Salazar
2025-11-21 09:13:05 -05:00
parent 23dfba35cc
commit de1cc96ba0
56 changed files with 7736 additions and 3367 deletions

View File

@@ -4,6 +4,7 @@ import { useMutation, useQueryClient, useQuery } from "@tanstack/react-query";
import { useNavigate } from "react-router-dom";
import { createPageUrl } from "@/utils";
import EventFormWizard from "@/components/events/EventFormWizard";
import RapidOrderInterface from "@/components/orders/RapidOrderInterface";
import { useToast } from "@/components/ui/use-toast";
import { Button } from "@/components/ui/button";
import { X, AlertTriangle } from "lucide-react";
@@ -16,6 +17,7 @@ export default function CreateEvent() {
const { toast } = useToast();
const [pendingEvent, setPendingEvent] = React.useState(null);
const [showConflictWarning, setShowConflictWarning] = React.useState(false);
const [showRapidInterface, setShowRapidInterface] = React.useState(false);
const { data: currentUser } = useQuery({
queryKey: ['current-user-create-event'],
@@ -48,15 +50,56 @@ export default function CreateEvent() {
},
});
const handleRapidSubmit = (rapidData) => {
// Convert rapid order message to event data
const eventData = {
event_name: "RAPID Order",
order_type: "rapid",
date: new Date().toISOString().split('T')[0],
status: "Active",
notes: rapidData.rawMessage,
shifts: [{
shift_name: "Shift 1",
location_address: "",
same_as_billing: true,
roles: [{
role: "",
department: "",
count: 1,
start_time: "09:00",
end_time: "17:00",
hours: 8,
uniform: "Type 1",
break_minutes: 15,
rate_per_hour: 0,
total_value: 0
}]
}],
requested: 1
};
createEventMutation.mutate(eventData);
};
const handleSubmit = (eventData) => {
// CRITICAL: Calculate total requested count from all roles before creating
const totalRequested = eventData.shifts.reduce((sum, shift) => {
return sum + shift.roles.reduce((roleSum, role) => roleSum + (parseInt(role.count) || 0), 0);
}, 0);
const eventDataWithRequested = {
...eventData,
requested: totalRequested // Set exact requested count
};
// Detect conflicts before creating
const conflicts = detectAllConflicts(eventData, allEvents);
const conflicts = detectAllConflicts(eventDataWithRequested, allEvents);
if (conflicts.length > 0) {
setPendingEvent({ ...eventData, detected_conflicts: conflicts });
setPendingEvent({ ...eventDataWithRequested, detected_conflicts: conflicts });
setShowConflictWarning(true);
} else {
createEventMutation.mutate(eventData);
createEventMutation.mutate(eventDataWithRequested);
}
};
@@ -137,6 +180,7 @@ export default function CreateEvent() {
<EventFormWizard
event={null}
onSubmit={handleSubmit}
onRapidSubmit={handleRapidSubmit}
isSubmitting={createEventMutation.isPending}
currentUser={currentUser}
onCancel={() => navigate(createPageUrl("ClientDashboard"))}