feat: finish company profile in the backoffice

This commit is contained in:
Nathnael
2026-06-23 06:45:29 +00:00
parent f7cbb6af6f
commit a6f3fd5643
24 changed files with 690 additions and 938 deletions

View File

@@ -1,13 +1,17 @@
import { QUERY_KEYS } from "@/constants/QUERY_KEYS";
import { endpoint } from "@/utils/endpoint";
import type { FleetResourceSlug } from "@/pages/fleet/config/resources";
import type { BookingDetail } from "@/types/booking";
import type {
CreateFileUploadFieldDto,
CreateFileUploadSettingDto,
FileUploadField,
FileUploadSetting,
UpdateFileUploadFieldDto,
UpdateFileUploadSettingDto,
} from "@/types/fileUploadSettings";
Company,
CompanyListFilter,
CompanyProfile,
CompanyStats,
CustomerBooking,
CustomerDocument,
CustomerPayment,
PaginatedCompanies,
ProfileStatus,
} from "@/types/customer";
import {
CreateDropdownOptionDto,
CreateDropdownSettingDto,
@@ -16,72 +20,20 @@ import {
UpdateDropdownOptionDto,
UpdateDropdownSettingDto,
} from "@/types/dropdownSettings";
import type {
CreateFileUploadFieldDto,
CreateFileUploadSettingDto,
FileUploadField,
FileUploadSetting,
UpdateFileUploadFieldDto,
UpdateFileUploadSettingDto,
} from "@/types/fileUploadSettings";
import type { IOverviewDashboard, OverviewRange } from "@/types/overview";
import {
RuleEngineListResult,
RuleEngineRecord,
RuleEngineResourceSlug,
} from "@/types/rule-engine";
import { fileUploadSettingsService } from "./fileUploadSettings.service";
import { dropdownSettingsService } from "./dropdownSettings.service";
import {
ruleEngineService,
RuleEngineListParams,
} from "./ruleEngine/ruleEngine.service";
import {
bookingsService,
BookingListFilter,
type ApproveStepPayload,
type PaginatedBookings,
type RejectStepPayload,
} from "./bookings.service";
import type { BookingDetail } from "@/types/booking";
import type { IOverviewDashboard, OverviewRange } from "@/types/overview";
import { overviewService } from "./overview.service";
import {
cargoService,
type Cargo,
type DeliverCargoPayload,
} from "./cargoService";
import { containerService, type Container } from "./containerService";
import { containerTypesService } from "./container-types.service";
import {
wagonService,
type Wagon,
type WagonListFilters,
} from "./wagon.service";
import { wagonTypesService, type WagonType } from "./wagon-types.service";
import { trainService, type Train } from "./trains.service";
import {
locomotivesService,
type Locomotive,
type SaveLocomotivePayload,
} from "./locomotives.service";
import { cargoTypesService } from "./cargo-types.service";
import {
fleetService,
type FleetListFilters,
type FleetRecord,
} from "./fleet/fleet.service";
import type { FleetResourceSlug } from "@/pages/fleet/config/resources";
import {
paymentsService,
type PaginatedPayments,
type PaymentListFilter,
type PaymentSummary,
} from "./payments.service";
import {
signaturesService,
type SavedSignature,
type SaveSignaturePayload,
} from "./signatures.service";
import { warehouseService } from "./warehouse.service";
import { trainSchedulingService } from "./trainScheduling.service";
import {
routesService,
type RouteRecord,
type SaveRoutePayload,
type YardRef,
} from "./routes.service";
import type {
AssignBookingsPayload,
BatchBoardSchedule,
@@ -157,6 +109,66 @@ import type {
WarehouseYard,
WarehouseZone,
} from "@/types/warehouse";
import { endpoint } from "@/utils/endpoint";
import {
BookingListFilter,
bookingsService,
type ApproveStepPayload,
type PaginatedBookings,
type RejectStepPayload,
} from "./bookings.service";
import { cargoTypesService } from "./cargo-types.service";
import {
cargoService,
type Cargo,
type DeliverCargoPayload,
} from "./cargoService";
import { containerTypesService } from "./container-types.service";
import { containerService, type Container } from "./containerService";
import { customersService } from "./customers.service";
import { dropdownSettingsService } from "./dropdownSettings.service";
import { fileUploadSettingsService } from "./fileUploadSettings.service";
import {
fleetService,
type FleetListFilters,
type FleetRecord,
} from "./fleet/fleet.service";
import {
locomotivesService,
type Locomotive,
type SaveLocomotivePayload,
} from "./locomotives.service";
import { overviewService } from "./overview.service";
import {
paymentsService,
type PaginatedPayments,
type PaymentListFilter,
type PaymentSummary,
} from "./payments.service";
import {
routesService,
type RouteRecord,
type SaveRoutePayload,
type YardRef,
} from "./routes.service";
import {
RuleEngineListParams,
ruleEngineService,
} from "./ruleEngine/ruleEngine.service";
import {
signaturesService,
type SavedSignature,
type SaveSignaturePayload,
} from "./signatures.service";
import { trainService, type Train } from "./trains.service";
import { trainSchedulingService } from "./trainScheduling.service";
import { wagonTypesService, type WagonType } from "./wagon-types.service";
import {
wagonService,
type Wagon,
type WagonListFilters,
} from "./wagon.service";
import { warehouseService } from "./warehouse.service";
/** Query keys for inventory-lifecycle mutations that ripple across views. */
const INVENTORY_INVALIDATIONS: ReadonlyArray<readonly unknown[]> = [
@@ -1879,6 +1891,64 @@ export const api = {
),
},
customers: {
stats: endpoint<Record<string, never>, CompanyStats>(
"customers",
"stats",
() => customersService.stats(),
() => QUERY_KEYS.CUSTOMERS.stats,
),
list: endpoint<{ filter: CompanyListFilter }, PaginatedCompanies>(
"customers",
"list",
({ filter }) => customersService.list(filter),
({ filter }) => QUERY_KEYS.CUSTOMERS.list(filter),
),
getById: endpoint<{ id: string }, Company | undefined>(
"customers",
"getById",
({ id }) => customersService.getById(id),
({ id }) => QUERY_KEYS.CUSTOMERS.byId(id),
),
bookings: endpoint<{ id: string }, CustomerBooking[]>(
"customers",
"bookings",
({ id }) => customersService.bookingsFor(id),
({ id }) => QUERY_KEYS.CUSTOMERS.bookings(id),
),
documents: endpoint<{ id: string }, CustomerDocument[]>(
"customers",
"documents",
({ id }) => customersService.documentsFor(id),
({ id }) => QUERY_KEYS.CUSTOMERS.documents(id),
),
payments: endpoint<{ id: string }, CustomerPayment[]>(
"customers",
"payments",
({ id }) => customersService.paymentsFor(id),
({ id }) => QUERY_KEYS.CUSTOMERS.payments(id),
),
setProfileStatus: endpoint<
{ profileId: string; status: ProfileStatus },
CompanyProfile
>(
"customers",
"setProfileStatus",
({ profileId, status }) => customersService.setProfileStatus(profileId, status),
undefined,
(_input, data) => [
QUERY_KEYS.CUSTOMERS.byId(data.companyId),
QUERY_KEYS.CUSTOMERS.ROOT,
],
),
},
overview: {
get: endpoint<{ range?: OverviewRange }, IOverviewDashboard>(
"overview",
@@ -1886,4 +1956,4 @@ export const api = {
({ range }) => overviewService.getDashboard(range),
),
},
};
};