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:
Egor Pozharov
2026-04-14 13:14:28 +06:00
parent 11e12f964d
commit 4e0899d3ce
54 changed files with 779 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
import { MapPin, Phone, Package, Store, Calendar, MessageSquare, CheckCircle2, Circle, CheckSquare } from 'lucide-react';
import type { Delivery } from '../../types';
import { pickupLocationLabels } from '../../types';
import { StatusBadge } from './StatusBadge';
import { Card } from '../ui/Card';
interface DeliveryCardProps {
delivery: Delivery;
onStatusChange: (id: string) => void;
onEdit: (delivery: Delivery) => void;
onDelete: (id: string) => void;
}
export const DeliveryCard = ({ delivery, onStatusChange, onEdit, onDelete }: DeliveryCardProps) => {
const handleAddressClick = () => {
const encodedAddress = encodeURIComponent(delivery.address);
window.open(`https://maps.google.com/?q=${encodedAddress}`, '_blank');
};
const handlePhoneClick = () => {
window.location.href = `tel:${delivery.phone}`;
};
return (
<Card className="relative">
<div className="flex items-start justify-between mb-3">
<div className="flex items-center gap-2">
<StatusBadge
status={delivery.status}
onClick={() => onStatusChange(delivery.id)}
size="md"
/>
</div>
<div className="flex gap-1">
<button
onClick={() => onEdit(delivery)}
className="p-1.5 rounded-md hover:bg-[#f5f3f5] text-[#75777d] transition-colors"
title="Редактировать"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>
</button>
<button
onClick={() => onDelete(delivery.id)}
className="p-1.5 rounded-md hover:bg-red-50 text-red-500 transition-colors"
title="Удалить"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>
</button>
</div>
</div>
<div className="space-y-2.5">
<div className="flex items-center gap-2 text-sm">
<Calendar size={16} className="text-[#75777d]" />
<span className="text-[#1b1b1d] font-medium">{delivery.date}</span>
</div>
<div className="flex items-center gap-2 text-sm">
<Store size={16} className="text-[#75777d]" />
<span className="text-[#1b1b1d]">{pickupLocationLabels[delivery.pickupLocation]}</span>
</div>
<div className="flex items-center gap-2 text-sm">
<Package size={16} className="text-[#75777d]" />
<span className="text-[#1b1b1d]">{delivery.productName}</span>
</div>
<button
onClick={handleAddressClick}
className="flex items-start gap-2 text-sm w-full text-left hover:bg-[#f5f3f5] -mx-1 px-1 py-0.5 rounded transition-colors"
>
<MapPin size={16} className="text-[#F28C28] mt-0.5 shrink-0" />
<span className="text-[#1B263B] underline decoration-[#F28C28]/30 underline-offset-2">
{delivery.address}
</span>
</button>
<button
onClick={handlePhoneClick}
className="flex items-center gap-2 text-sm w-full text-left hover:bg-[#f5f3f5] -mx-1 px-1 py-0.5 rounded transition-colors"
>
<Phone size={16} className="text-[#16a34a] shrink-0" />
<span className="text-[#16a34a] font-medium">
{delivery.phone}
</span>
</button>
{delivery.additionalPhone && (
<button
onClick={() => window.location.href = `tel:${delivery.additionalPhone}`}
className="flex items-center gap-2 text-sm w-full text-left hover:bg-[#f5f3f5] -mx-1 px-1 py-0.5 rounded transition-colors"
>
<Phone size={16} className="text-[#75777d] shrink-0" />
<span className="text-[#75777d]">
{delivery.additionalPhone}
</span>
</button>
)}
<div className="flex items-center gap-2 text-sm">
<CheckSquare size={16} className={delivery.hasElevator ? 'text-[#16a34a]' : 'text-[#75777d]'} />
<span className="text-[#1b1b1d]">
{delivery.hasElevator ? 'Есть лифт' : 'Нет лифта'}
</span>
</div>
{delivery.comment && (
<div className="flex items-start gap-2 text-sm">
<MessageSquare size={16} className="text-[#75777d] mt-0.5 shrink-0" />
<span className="text-[#45474d]">{delivery.comment}</span>
</div>
)}
</div>
<div className="mt-4 pt-3 border-t border-[#e4e2e4]">
<button
onClick={() => onStatusChange(delivery.id)}
className="w-full flex items-center justify-center gap-2 py-2 rounded-md bg-[#f5f3f5] hover:bg-[#e4e2e4] transition-colors text-sm font-medium text-[#1b1b1d]"
>
{delivery.status === 'new' ? (
<>
<CheckCircle2 size={16} className="text-[#16a34a]" />
Отметить доставленным
</>
) : (
<>
<Circle size={16} className="text-[#F28C28]" />
Вернуть в "Новые"
</>
)}
</button>
</div>
</Card>
);
};

View File

@@ -0,0 +1,183 @@
import { useState, useEffect } from 'react';
import { Button, Input, Select, Modal } from '../ui';
import type { Delivery, PickupLocation, DeliveryStatus } from '../../types';
import { pickupLocationLabels } from '../../types';
interface DeliveryFormProps {
isOpen: boolean;
onClose: () => void;
onSubmit: (delivery: Omit<Delivery, 'id' | 'createdAt' | 'updatedAt'>) => void;
initialData?: Delivery | null;
defaultDate?: string;
}
const pickupOptions: { value: PickupLocation; label: string }[] = [
{ value: 'warehouse', label: pickupLocationLabels.warehouse },
{ value: 'symbat', label: pickupLocationLabels.symbat },
{ value: 'nursaya', label: pickupLocationLabels.nursaya },
{ value: 'galaktika', label: pickupLocationLabels.galaktika },
];
export const DeliveryForm = ({ isOpen, onClose, onSubmit, initialData, defaultDate }: DeliveryFormProps) => {
const [formData, setFormData] = useState({
date: defaultDate || new Date().toLocaleDateString('ru-RU').split('.').join('-'),
pickupLocation: 'warehouse' as PickupLocation,
productName: '',
address: '',
phone: '',
additionalPhone: '',
hasElevator: false,
comment: '',
status: 'new' as DeliveryStatus,
});
useEffect(() => {
if (initialData) {
setFormData({
date: initialData.date,
pickupLocation: initialData.pickupLocation,
productName: initialData.productName,
address: initialData.address,
phone: initialData.phone,
additionalPhone: initialData.additionalPhone || '',
hasElevator: initialData.hasElevator,
comment: initialData.comment,
status: initialData.status,
});
} else if (defaultDate) {
setFormData(prev => ({ ...prev, date: defaultDate }));
}
}, [initialData, defaultDate, isOpen]);
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
onSubmit(formData);
if (!initialData) {
setFormData({
date: defaultDate || new Date().toLocaleDateString('ru-RU').split('.').join('-'),
pickupLocation: 'warehouse',
productName: '',
address: '',
phone: '',
additionalPhone: '',
hasElevator: false,
comment: '',
status: 'new',
});
}
onClose();
};
const formatDateForInput = (dateStr: string) => {
const [day, month, year] = dateStr.split('-');
return `${year}-${month}-${day}`;
};
const formatDateFromInput = (dateStr: string) => {
const [year, month, day] = dateStr.split('-');
return `${day}-${month}-${year}`;
};
return (
<Modal
isOpen={isOpen}
onClose={onClose}
title={initialData ? 'Редактировать доставку' : 'Новая доставка'}
footer={
<>
<Button variant="ghost" onClick={onClose}>
Отмена
</Button>
<Button type="submit" form="delivery-form">
{initialData ? 'Сохранить' : 'Создать'}
</Button>
</>
}
>
<form id="delivery-form" onSubmit={handleSubmit} className="space-y-4">
<div>
<label className="block text-sm font-medium text-[#1b1b1d] mb-1">
Дата доставки
</label>
<input
type="date"
value={formatDateForInput(formData.date)}
onChange={(e) => setFormData({ ...formData, date: formatDateFromInput(e.target.value) })}
className="w-full px-3 py-2 bg-[#f5f3f5] border border-[#c5c6cd] rounded-md text-[#1b1b1d] focus:outline-none focus:ring-2 focus:ring-[#1B263B] focus:border-transparent transition-colors"
required
/>
</div>
<Select
label="Место загрузки"
value={formData.pickupLocation}
onChange={(e) => setFormData({ ...formData, pickupLocation: e.target.value as PickupLocation })}
options={pickupOptions}
/>
<Input
label="Название товара"
value={formData.productName}
onChange={(e) => setFormData({ ...formData, productName: e.target.value })}
placeholder="Введите название товара"
required
/>
<Input
label="Адрес разгрузки"
value={formData.address}
onChange={(e) => setFormData({ ...formData, address: e.target.value })}
placeholder="ул. Примерная, д. 1"
required
/>
<Input
label="Телефон покупателя"
type="tel"
value={formData.phone}
onChange={(e) => setFormData({ ...formData, phone: e.target.value })}
onFocus={(e) => {
if (!e.target.value) {
setFormData({ ...formData, phone: '+7' });
}
}}
placeholder="+7 (776)-567-89-01"
required
/>
<Input
label="Дополнительный номер телефона"
type="tel"
value={formData.additionalPhone}
onChange={(e) => setFormData({ ...formData, additionalPhone: e.target.value })}
onFocus={(e) => {
if (!e.target.value) {
setFormData({ ...formData, additionalPhone: '+7' });
}
}}
placeholder="+7 (776)-567-89-01"
/>
<div className="flex items-center gap-2">
<input
type="checkbox"
id="hasElevator"
checked={formData.hasElevator}
onChange={(e) => setFormData({ ...formData, hasElevator: e.target.checked })}
className="w-4 h-4 text-[#1B263B] border-[#c5c6cd] rounded focus:ring-[#1B263B]"
/>
<label htmlFor="hasElevator" className="text-sm text-[#1b1b1d]">
Наличие лифта
</label>
</div>
<Input
label="Комментарий"
value={formData.comment}
onChange={(e) => setFormData({ ...formData, comment: e.target.value })}
placeholder="Дополнительная информация..."
/>
</form>
</Modal>
);
};

View File

@@ -0,0 +1,139 @@
import { useState } from 'react';
import { Plus, LayoutGrid, Table as TableIcon } from 'lucide-react';
import { DeliveryCard } from './DeliveryCard';
import { DeliveryRow } from './DeliveryRow';
import { Button } from '../ui/Button';
import type { Delivery } from '../../types';
interface DeliveryListProps {
deliveries: Delivery[];
onStatusChange: (id: string) => void;
onEdit: (delivery: Delivery) => void;
onDelete: (id: string) => void;
onAdd: () => void;
date: string;
}
export const DeliveryList = ({ deliveries, onStatusChange, onEdit, onDelete, onAdd, date }: DeliveryListProps) => {
const [viewMode, setViewMode] = useState<'kanban' | 'table'>('kanban');
const newDeliveries = deliveries.filter(d => d.status === 'new');
const deliveredDeliveries = deliveries.filter(d => d.status === 'delivered');
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h2 className="text-xl font-semibold text-[#1b1b1d]">
Доставки на {date}
</h2>
<div className="flex items-center gap-2">
<div className="flex bg-[#f0edef] rounded-lg p-1">
<button
onClick={() => setViewMode('kanban')}
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${
viewMode === 'kanban' ? 'bg-white shadow-sm text-[#1b1b1d]' : 'text-[#75777d] hover:text-[#1b1b1d]'
}`}
>
<LayoutGrid size={16} />
<span className="hidden sm:inline">Канбан</span>
</button>
<button
onClick={() => setViewMode('table')}
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${
viewMode === 'table' ? 'bg-white shadow-sm text-[#1b1b1d]' : 'text-[#75777d] hover:text-[#1b1b1d]'
}`}
>
<TableIcon size={16} />
<span className="hidden sm:inline">Таблица</span>
</button>
</div>
<Button onClick={onAdd} size="sm">
<Plus size={16} className="mr-1" />
<span className="hidden sm:inline">Добавить</span>
</Button>
</div>
</div>
{deliveries.length === 0 ? (
<div className="text-center py-12 bg-[#f5f3f5] rounded-lg">
<p className="text-[#75777d]">Нет доставок на эту дату</p>
<Button onClick={onAdd} variant="ghost" className="mt-2">
Создать первую доставку
</Button>
</div>
) : viewMode === 'kanban' ? (
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="space-y-3">
<div className="flex items-center justify-between">
<h3 className="font-medium text-[#1b1b1d] flex items-center gap-2">
<span className="w-2 h-2 rounded-full bg-[#F28C28]"></span>
Новые
<span className="text-sm text-[#75777d] font-normal">({newDeliveries.length})</span>
</h3>
</div>
<div className="space-y-3">
{newDeliveries.map(delivery => (
<DeliveryCard
key={delivery.id}
delivery={delivery}
onStatusChange={onStatusChange}
onEdit={onEdit}
onDelete={onDelete}
/>
))}
</div>
</div>
<div className="space-y-3">
<div className="flex items-center justify-between">
<h3 className="font-medium text-[#1b1b1d] flex items-center gap-2">
<span className="w-2 h-2 rounded-full bg-[#16a34a]"></span>
Доставлено
<span className="text-sm text-[#75777d] font-normal">({deliveredDeliveries.length})</span>
</h3>
</div>
<div className="space-y-3">
{deliveredDeliveries.map(delivery => (
<DeliveryCard
key={delivery.id}
delivery={delivery}
onStatusChange={onStatusChange}
onEdit={onEdit}
onDelete={onDelete}
/>
))}
</div>
</div>
</div>
) : (
<div className="overflow-x-auto">
<table className="w-full bg-white rounded-lg shadow-sm border border-[#e4e2e4]">
<thead className="bg-[#f5f3f5]">
<tr className="text-left text-xs font-semibold text-[#75777d] uppercase tracking-wider">
<th className="px-4 py-3">Статус</th>
<th className="px-4 py-3">Дата</th>
<th className="px-4 py-3">Загрузка</th>
<th className="px-4 py-3">Товар</th>
<th className="px-4 py-3">Адрес</th>
<th className="px-4 py-3">Телефон</th>
<th className="px-4 py-3">Комментарий</th>
<th className="px-4 py-3">Действия</th>
</tr>
</thead>
<tbody className="divide-y divide-[#e4e2e4]">
{deliveries.map(delivery => (
<DeliveryRow
key={delivery.id}
delivery={delivery}
onStatusChange={onStatusChange}
onEdit={onEdit}
onDelete={onDelete}
/>
))}
</tbody>
</table>
</div>
)}
</div>
);
};

View File

@@ -0,0 +1,78 @@
import { MapPin, Phone } from 'lucide-react';
import type { Delivery } from '../../types';
import { pickupLocationLabels } from '../../types';
import { StatusBadge } from './StatusBadge';
interface DeliveryRowProps {
delivery: Delivery;
onStatusChange: (id: string) => void;
onEdit: (delivery: Delivery) => void;
onDelete: (id: string) => void;
}
export const DeliveryRow = ({ delivery, onStatusChange, onEdit, onDelete }: DeliveryRowProps) => {
const handleAddressClick = (e: React.MouseEvent) => {
e.stopPropagation();
const encodedAddress = encodeURIComponent(delivery.address);
window.open(`https://maps.google.com/?q=${encodedAddress}`, '_blank');
};
const handlePhoneClick = (e: React.MouseEvent) => {
e.stopPropagation();
window.location.href = `tel:${delivery.phone}`;
};
return (
<tr className="hover:bg-[#f5f3f5] transition-colors border-b border-[#e4e2e4] last:border-b-0">
<td className="px-4 py-3">
<StatusBadge
status={delivery.status}
onClick={() => onStatusChange(delivery.id)}
size="sm"
/>
</td>
<td className="px-4 py-3 text-sm text-[#1b1b1d]">{delivery.date}</td>
<td className="px-4 py-3 text-sm text-[#1b1b1d]">{pickupLocationLabels[delivery.pickupLocation]}</td>
<td className="px-4 py-3 text-sm text-[#1b1b1d]">{delivery.productName}</td>
<td className="px-4 py-3">
<button
onClick={handleAddressClick}
className="flex items-center gap-1.5 text-sm text-[#1B263B] hover:text-[#F28C28] transition-colors text-left"
>
<MapPin size={14} />
<span className="max-w-[200px] truncate">{delivery.address}</span>
</button>
</td>
<td className="px-4 py-3">
<button
onClick={handlePhoneClick}
className="flex items-center gap-1.5 text-sm text-[#16a34a] hover:underline transition-colors"
>
<Phone size={14} />
{delivery.phone}
</button>
</td>
<td className="px-4 py-3 text-sm text-[#45474d] max-w-[200px] truncate">
{delivery.comment || '-'}
</td>
<td className="px-4 py-3">
<div className="flex items-center gap-1">
<button
onClick={() => onEdit(delivery)}
className="p-1.5 rounded-md hover:bg-[#e4e2e4] text-[#75777d] transition-colors"
title="Редактировать"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>
</button>
<button
onClick={() => onDelete(delivery.id)}
className="p-1.5 rounded-md hover:bg-red-50 text-red-500 transition-colors"
title="Удалить"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>
</button>
</div>
</td>
</tr>
);
};

View File

@@ -0,0 +1,34 @@
import type { DeliveryStatus } from '../../types';
import { statusLabels } from '../../types';
interface StatusBadgeProps {
status: DeliveryStatus;
onClick?: () => void;
size?: 'sm' | 'md' | 'lg';
}
export const StatusBadge = ({ status, onClick, size = 'md' }: StatusBadgeProps) => {
const baseStyles = 'inline-flex items-center justify-center font-medium rounded-full transition-colors';
const variants = {
new: 'bg-[#ffdcc3] text-[#6e3900]',
delivered: 'bg-[#dcfce7] text-[#166534]',
};
const sizes = {
sm: 'px-2 py-0.5 text-xs',
md: 'px-3 py-1 text-sm',
lg: 'px-4 py-2 text-base',
};
const clickableStyles = onClick ? 'cursor-pointer hover:opacity-80 active:scale-95' : '';
return (
<span
className={`${baseStyles} ${variants[status]} ${sizes[size]} ${clickableStyles}`}
onClick={onClick}
>
{statusLabels[status]}
</span>
);
};