Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
import { apiGet, apiPost, apiPut } from "@/app/lib/clientApi";
|
|
import type { AdminWarehouse } from "@/app/lib/types";
|
|
|
|
// Client-side wrapper for the branch Warehouse tab's store picker. Calls only the portal's own
|
|
// /api/warehouses route handler (which forwards the admin JWT to mobile-api's
|
|
// GET /api/admin/warehouses), mirroring app/lib/services/adminUsers.ts.
|
|
|
|
export async function listAdminWarehouses(): Promise<AdminWarehouse[]> {
|
|
return apiGet<AdminWarehouse[]>("/api/warehouses");
|
|
}
|
|
|
|
/**
|
|
* Branch-store picker candidate list. Fetches from the dedicated branch-store endpoint
|
|
* (which proxies mobile-api's GET /api/admin/warehouses/branch-store → service-inventory's
|
|
* findBranchStoreWarehouses). Returns only active M/S warehouses — EVENT is excluded
|
|
* server-side, not by client-side filtering. Use this in the branch Warehouse tab's store
|
|
* picker instead of listAdminWarehouses so the exclusion lives at the data source.
|
|
*/
|
|
export async function listBranchStoreWarehouses(): Promise<AdminWarehouse[]> {
|
|
return apiGet<AdminWarehouse[]>("/api/warehouses/branch-store");
|
|
}
|
|
|
|
/** Create payload for a new warehouse — `code` is only writable on CREATE. */
|
|
export interface AdminWarehouseCreatePayload {
|
|
code: string;
|
|
name: string;
|
|
type: string;
|
|
status?: string;
|
|
parentId?: number | null;
|
|
address?: string | null;
|
|
fulfilmentMode?: "QIANYI" | "MANUAL";
|
|
onlinePriority?: number;
|
|
qyWarehouseCode?: string | null;
|
|
}
|
|
|
|
/** Edit payload for an existing warehouse — the id is in the path, not the body. */
|
|
export interface AdminWarehouseUpdatePayload {
|
|
name: string;
|
|
type: string;
|
|
status?: string;
|
|
parentId?: number | null;
|
|
address?: string | null;
|
|
fulfilmentMode?: "QIANYI" | "MANUAL";
|
|
onlinePriority?: number;
|
|
qyWarehouseCode?: string | null;
|
|
}
|
|
|
|
/** Create: POSTs to /api/warehouses (-> mobile-api POST /api/admin/warehouses). */
|
|
export async function createAdminWarehouse(
|
|
input: AdminWarehouseCreatePayload,
|
|
): Promise<AdminWarehouse> {
|
|
return apiPost<AdminWarehouse>("/api/warehouses", input);
|
|
}
|
|
|
|
/** Update: PUTs to /api/warehouses/{id} (-> mobile-api PUT /api/admin/warehouses/{id}). */
|
|
export async function updateAdminWarehouse(
|
|
id: number,
|
|
input: AdminWarehouseUpdatePayload,
|
|
): Promise<AdminWarehouse> {
|
|
return apiPut<AdminWarehouse>(`/api/warehouses/${id}`, input);
|
|
}
|