diff --git a/apps/edr-freight-api/src/modules/train-scheduling/train-scheduling.service.ts b/apps/edr-freight-api/src/modules/train-scheduling/train-scheduling.service.ts index 68fae00ea..34c4a7843 100644 --- a/apps/edr-freight-api/src/modules/train-scheduling/train-scheduling.service.ts +++ b/apps/edr-freight-api/src/modules/train-scheduling/train-scheduling.service.ts @@ -82,17 +82,6 @@ export class TrainSchedulingService { async getEligibleContainerBookings(query: GetEligibleContainerBookingsDto) { const bookingRepository = this.dataSource.getRepository(Booking); const queryBuilder = bookingRepository -<<<<<<< HEAD - .createQueryBuilder('booking') - .leftJoinAndSelect('booking.company', 'company') - .leftJoinAndSelect('booking.originYard', 'originYard') - .leftJoinAndSelect('booking.destinationYard', 'destinationYard') - .leftJoinAndSelect('booking.bookingContainers', 'bookingContainer') - .leftJoinAndSelect('bookingContainer.containerType', 'containerType') - .leftJoin(TrainScheduleBooking, 'scheduleBooking', 'scheduleBooking.booking_id = booking.id') - .where('booking.freightType = :freightType', { freightType: 'CONTAINER' }) - .andWhere('scheduleBooking.id IS NULL'); -======= .createQueryBuilder("booking") .leftJoinAndSelect("booking.customer", "customer") .leftJoinAndSelect("booking.originYard", "originYard") @@ -106,7 +95,6 @@ export class TrainSchedulingService { ) .where("booking.freightType = :freightType", { freightType: "CONTAINER" }) .andWhere("scheduleBooking.id IS NULL"); ->>>>>>> bd6ad54eea229305a214d06081e0ffd27fe163b8 if (query.originStationId) { queryBuilder.andWhere("booking.originYardId = :originStationId", { @@ -144,13 +132,6 @@ export class TrainSchedulingService { const items: EligibleBookingItem[] = bookings.map((booking) => ({ id: booking.id, reference: booking.reference, -<<<<<<< HEAD - customer: booking.company?.name ?? booking.company?.email ?? 'Unknown customer', - containerType: booking.bookingContainers - ?.map((container) => container.containerType?.label ?? container.containerType?.code ?? 'Container') - .join(', ') ?? 'Container', - quantity: booking.bookingContainers?.reduce((sum, container) => sum + Number(container.quantity ?? 0), 0) ?? 0, -======= customer: booking.company?.name ?? booking.company?.email ?? "Unknown customer", containerType: @@ -167,7 +148,6 @@ export class TrainSchedulingService { (sum, container) => sum + Number(container.quantity ?? 0), 0, ) ?? 0, ->>>>>>> bd6ad54eea229305a214d06081e0ffd27fe163b8 weightTons: this.roundTons(booking.cargoTotalWeightVgm), origin: booking.originYard?.label ?? @@ -674,17 +654,6 @@ export class TrainSchedulingService { } async getContainerTrainScheduleById(id: string) { -<<<<<<< HEAD - const schedule = await this.dataSource.getRepository(TrainSchedule).findOne({ - where: { id }, - relations: { - trainSet: { locomotive: true, wagons: { wagonType: true, allocations: { booking: true } } }, - originStation: true, - destinationStation: true, - scheduleBookings: { booking: { company: true, originYard: true, destinationYard: true } }, - }, - }); -======= const schedule = await this.dataSource .getRepository(TrainSchedule) .findOne({ @@ -701,7 +670,6 @@ export class TrainSchedulingService { }, }, }); ->>>>>>> bd6ad54eea229305a214d06081e0ffd27fe163b8 if (!schedule) { throw new NotFoundException(`Train schedule ${id} not found`); diff --git a/apps/edr-freight-api/src/seed/demo-bookings.seeder.ts b/apps/edr-freight-api/src/seed/demo-bookings.seeder.ts index da835dabd..e215dbd9b 100644 --- a/apps/edr-freight-api/src/seed/demo-bookings.seeder.ts +++ b/apps/edr-freight-api/src/seed/demo-bookings.seeder.ts @@ -2,16 +2,6 @@ import { Injectable, Logger } from "@nestjs/common"; import { randomUUID } from "crypto"; import { DataSource } from "typeorm"; -<<<<<<< HEAD -import { BookingContainer } from '../modules/bookings/entities/booking-container.entity'; -import { Booking } from '../modules/bookings/entities/booking.entity'; -import { Company } from '../modules/companies/entities/company.entity'; -import { Locomotive } from '../modules/locomotives/entities/locomotive.entity'; -import { ServiceType } from '../modules/rule-engine/entities/service-type.entity'; -import { Yard } from '../modules/rule-engine/entities/yard.entity'; -import { WagonType } from '../modules/wagon-types/entities/wagon-type.entity'; -import { ContainerType } from '../modules/rule-engine/entities/container-type.entity'; -======= import { BookingContainer } from "../modules/bookings/entities/booking-container.entity"; import { Booking } from "../modules/bookings/entities/booking.entity"; import { Customer } from "../modules/customers/entities/customer.entity"; @@ -20,7 +10,6 @@ import { ServiceType } from "../modules/rule-engine/entities/service-type.entity import { Yard } from "../modules/rule-engine/entities/yard.entity"; import { WagonType } from "../modules/wagon-types/entities/wagon-type.entity"; import { ContainerType } from "../modules/rule-engine/entities/container-type.entity"; ->>>>>>> bd6ad54eea229305a214d06081e0ffd27fe163b8 const SEED_FLAG = "SEED_DEMO_BOOKINGS"; @@ -220,11 +209,6 @@ export class DemoBookingsSeeder { { conflictPaths: { email: true } }, ); -<<<<<<< HEAD - const [serviceType, company, yards, containerTypes] = await Promise.all([ - manager.getRepository(ServiceType).findOneByOrFail({ code: SERVICE_TYPE_CODE }), - manager.getRepository(Customer).findOneByOrFail({ email: CUSTOMER_EMAIL }), -======= const [serviceType, customer, yards, containerTypes] = await Promise.all([ manager .getRepository(ServiceType) @@ -232,7 +216,6 @@ export class DemoBookingsSeeder { manager .getRepository(Customer) .findOneByOrFail({ email: CUSTOMER_EMAIL }), ->>>>>>> bd6ad54eea229305a214d06081e0ffd27fe163b8 manager.getRepository(Yard).find(), manager.getRepository(ContainerType).find(), ]); @@ -264,13 +247,8 @@ export class DemoBookingsSeeder { await manager.getRepository(Booking).upsert( { reference: demoBooking.reference, -<<<<<<< HEAD - companyId: company.id, - status: 'APPROVED', -======= companyId: customer.id, status: "APPROVED", ->>>>>>> bd6ad54eea229305a214d06081e0ffd27fe163b8 scheduledDate: new Date(demoBooking.scheduledDate), totalAmount: 0, paymentStatus: "PENDING", diff --git a/apps/edr-freight-web/backoffice/package.json b/apps/edr-freight-web/backoffice/package.json index 7499e38a2..9d5843372 100644 --- a/apps/edr-freight-web/backoffice/package.json +++ b/apps/edr-freight-web/backoffice/package.json @@ -16,6 +16,7 @@ "@edr/ui-common": "workspace:*", "@tanstack/react-query": "^5.100.11", "@tria-plc/iamui-common": "1.1.1", + "@hello-pangea/dnd": "^18.0.1", "axios": "^1.7.7", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", diff --git a/apps/edr-freight-web/backoffice/src/components/ui/card.tsx b/apps/edr-freight-web/backoffice/src/components/ui/card.tsx new file mode 100644 index 000000000..524e7794f --- /dev/null +++ b/apps/edr-freight-web/backoffice/src/components/ui/card.tsx @@ -0,0 +1 @@ +export { Card, CardHeader, CardTitle, CardDescription, CardFooter, CardAction, CardContent } from '@edr/ui-common'; diff --git a/apps/edr-freight-web/backoffice/src/pages/trains/TrainsPage.tsx b/apps/edr-freight-web/backoffice/src/pages/trains/TrainsPage.tsx index ef6dba506..9794e86f3 100644 --- a/apps/edr-freight-web/backoffice/src/pages/trains/TrainsPage.tsx +++ b/apps/edr-freight-web/backoffice/src/pages/trains/TrainsPage.tsx @@ -1,42 +1,3 @@ -<<<<<<< HEAD -import { useState } from 'react'; -import { useTrains, useDeleteTrain, useCreateTrain } from '@/hooks/useTrains'; -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'; -import { Badge } from '@/components/ui/badge'; -import { Button } from '@/components/ui/button'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; -import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; -import { Input } from '@/components/ui/input'; -import { Label } from '@/components/ui/label'; -import { useToast } from '@/hooks/use-toast'; -import { Plus, Eye, Trash2 } from 'lucide-react'; -import { Link } from 'react-router-dom'; - -const CreateTrainForm = ({ onSuccess }: { onSuccess: () => void }) => { - const [form, setForm] = useState({ code: '', capacityTons: 0, trainNumber: '', trainName: '' }); - const createTrain = useCreateTrain(); - const { toast } = useToast(); - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - try { - await createTrain.mutateAsync(form); - toast({ title: 'Train created', description: `${form.code} added.` }); - onSuccess(); - } catch { - toast({ title: 'Error', description: 'Failed to create train.', variant: 'destructive' }); - } - }; - - return ( -
-======= import { useMemo, useState } from 'react'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { isAxiosError } from 'axios'; @@ -794,45 +755,7 @@ const TrainsPage = () => { ->>>>>>> 523d7e58422f1bde8024c2dd237092a7cf6aa190 ); }; -export default function TrainsPage() { - const { data: trains, isLoading } = useTrains(); - const deleteTrain = useDeleteTrain(); - const [open, setOpen] = useState(false); - - if (isLoading) return