chore: restructure project into backend and frontend folders
- Move all frontend code to frontend/ directory - Add backend/ with Go project structure (cmd, internal, pkg) - Add docker-compose.yml for orchestration
This commit is contained in:
115
frontend/src/pages/DeliveryListPage.tsx
Normal file
115
frontend/src/pages/DeliveryListPage.tsx
Normal file
@@ -0,0 +1,115 @@
|
||||
import { useState } from 'react';
|
||||
import { ArrowLeft, Filter } from 'lucide-react';
|
||||
import { useDeliveryStore } from '../stores/deliveryStore';
|
||||
import { DeliveryList as DeliveryListComponent } from '../components/delivery/DeliveryList';
|
||||
import { DeliveryForm } from '../components/delivery/DeliveryForm';
|
||||
import { Button } from '../components/ui/Button';
|
||||
import { Select } from '../components/ui/Select';
|
||||
import type { Delivery, PickupLocation } from '../types';
|
||||
import { pickupLocationLabels } from '../types';
|
||||
|
||||
interface DeliveryListPageProps {
|
||||
selectedDate: string;
|
||||
onBack: () => void;
|
||||
}
|
||||
|
||||
export const DeliveryListPage = ({ selectedDate, onBack }: DeliveryListPageProps) => {
|
||||
const deliveries = useDeliveryStore(state => state.deliveries);
|
||||
const toggleStatus = useDeliveryStore(state => state.toggleStatus);
|
||||
const deleteDelivery = useDeliveryStore(state => state.deleteDelivery);
|
||||
const updateDelivery = useDeliveryStore(state => state.updateDelivery);
|
||||
const addDelivery = useDeliveryStore(state => state.addDelivery);
|
||||
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [editingDelivery, setEditingDelivery] = useState<Delivery | null>(null);
|
||||
const [pickupFilter, setPickupFilter] = useState<PickupLocation | 'all'>('all');
|
||||
|
||||
const dayDeliveries = deliveries.filter(d => d.date === selectedDate);
|
||||
const filteredDeliveries = pickupFilter === 'all'
|
||||
? dayDeliveries
|
||||
: dayDeliveries.filter(d => d.pickupLocation === pickupFilter);
|
||||
|
||||
const pickupOptions: { value: PickupLocation | 'all'; label: string }[] = [
|
||||
{ value: 'all', label: 'Все места загрузки' },
|
||||
{ value: 'warehouse', label: pickupLocationLabels.warehouse },
|
||||
{ value: 'symbat', label: pickupLocationLabels.symbat },
|
||||
{ value: 'nursaya', label: pickupLocationLabels.nursaya },
|
||||
{ value: 'galaktika', label: pickupLocationLabels.galaktika },
|
||||
];
|
||||
|
||||
const handleStatusChange = (id: string) => {
|
||||
toggleStatus(id);
|
||||
};
|
||||
|
||||
const handleEdit = (delivery: Delivery) => {
|
||||
setEditingDelivery(delivery);
|
||||
setIsFormOpen(true);
|
||||
};
|
||||
|
||||
const handleDelete = (id: string) => {
|
||||
if (confirm('Удалить эту доставку?')) {
|
||||
deleteDelivery(id);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = (data: Omit<Delivery, 'id' | 'createdAt' | 'updatedAt'>) => {
|
||||
if (editingDelivery) {
|
||||
updateDelivery(editingDelivery.id, data);
|
||||
} else {
|
||||
addDelivery(data);
|
||||
}
|
||||
setEditingDelivery(null);
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
setEditingDelivery(null);
|
||||
setIsFormOpen(true);
|
||||
};
|
||||
|
||||
const handleCloseForm = () => {
|
||||
setIsFormOpen(false);
|
||||
setEditingDelivery(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between flex-wrap gap-4">
|
||||
<div className="flex items-center gap-4">
|
||||
<Button variant="ghost" size="sm" onClick={onBack}>
|
||||
<ArrowLeft size={18} className="mr-1" />
|
||||
Назад
|
||||
</Button>
|
||||
<div className="flex items-center gap-2 text-sm text-[#75777d]">
|
||||
<Filter size={16} />
|
||||
<span>Всего: {filteredDeliveries.length}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-48">
|
||||
<Select
|
||||
label=""
|
||||
value={pickupFilter}
|
||||
onChange={(e) => setPickupFilter(e.target.value as PickupLocation | 'all')}
|
||||
options={pickupOptions}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeliveryListComponent
|
||||
deliveries={filteredDeliveries}
|
||||
onStatusChange={handleStatusChange}
|
||||
onEdit={handleEdit}
|
||||
onDelete={handleDelete}
|
||||
onAdd={handleAdd}
|
||||
date={selectedDate}
|
||||
/>
|
||||
|
||||
<DeliveryForm
|
||||
isOpen={isFormOpen}
|
||||
onClose={handleCloseForm}
|
||||
onSubmit={handleSubmit}
|
||||
initialData={editingDelivery}
|
||||
defaultDate={selectedDate}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user