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
59 lines
2.5 KiB
TypeScript
59 lines
2.5 KiB
TypeScript
import { apiGet, apiPost, apiPut } from "@/app/lib/clientApi";
|
|
|
|
// Admin shipping settings client (add-shipping-rates), over app/api/shipping/[...path]. Weights are kg and money
|
|
// is RM, as the admin and the xlsx see them; the server stores grams.
|
|
|
|
export type ShippingZone = { id?: number; code: string; name: string; status: "Y" | "N"; geoLocationIds: number[] };
|
|
export type RateCardStatus = "DRAFT" | "ACTIVE" | "INACTIVE";
|
|
export type RateRow = {
|
|
zoneCode: string;
|
|
type: "BRACKET" | "OVERFLOW";
|
|
fromKg: number | null;
|
|
toKg: number | null;
|
|
stepKg: number | null;
|
|
fee: number | null;
|
|
maxLengthCm: number | null;
|
|
maxWidthCm: number | null;
|
|
maxHeightCm: number | null;
|
|
};
|
|
export type RateCard = {
|
|
id?: number;
|
|
name: string;
|
|
effectiveFrom: string;
|
|
status?: RateCardStatus;
|
|
volumetricDivisor?: number | null;
|
|
freeShippingThreshold?: number | null;
|
|
warehouseId?: number | null;
|
|
rows?: RateRow[] | null;
|
|
};
|
|
export type Courier = {
|
|
id?: number;
|
|
code: string;
|
|
name: string;
|
|
trackingUrlTemplate?: string | null;
|
|
isDefault: boolean;
|
|
status: "Y" | "N";
|
|
};
|
|
export type CalculateRequest = {
|
|
rateCardId?: number;
|
|
geoLocationId: string;
|
|
weightKg: number;
|
|
lengthCm: number;
|
|
widthCm: number;
|
|
heightCm: number;
|
|
merchandiseTotal?: number;
|
|
};
|
|
export type CalculateResult = { zoneCode: string; billableWeightG: number; fee: number; rateCardId: number };
|
|
|
|
export const listZones = () => apiGet<ShippingZone[]>("/api/shipping/zones");
|
|
export const saveZone = (zone: ShippingZone) => apiPost<ShippingZone>("/api/shipping/zones", zone);
|
|
export const listRateCards = () => apiGet<RateCard[]>("/api/shipping/rate-cards");
|
|
export const getRateCard = (id: number) => apiGet<RateCard>(`/api/shipping/rate-cards/${id}`);
|
|
export const saveRateCard = (card: RateCard) => apiPost<RateCard>("/api/shipping/rate-cards", card);
|
|
export const saveRates = (id: number, rows: RateRow[]) => apiPut<RateCard>(`/api/shipping/rate-cards/${id}/rates`, { rows });
|
|
export const activateRateCard = (id: number) => apiPost<RateCard>(`/api/shipping/rate-cards/${id}/activate`, {});
|
|
export const deactivateRateCard = (id: number) => apiPost<RateCard>(`/api/shipping/rate-cards/${id}/deactivate`, {});
|
|
export const listCouriers = () => apiGet<Courier[]>("/api/shipping/couriers");
|
|
export const saveCourier = (courier: Courier) => apiPost<Courier>("/api/shipping/couriers", courier);
|
|
export const calculateShipping = (req: CalculateRequest) => apiPost<CalculateResult>("/api/shipping/calculate", req);
|