feat: initial commit

This commit is contained in:
s.esmaeili
2026-09-09 06:46:27 +03:30
commit 0ed6bed028
214 changed files with 20177 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
import type { CreateOrderDto, CustomerBalanceDto } from '@gold-bank/shared-types';
export interface CustomerSummary {
id: string;
fullName: string;
mobile: string;
goldDebtGrams: string;
fiatDebtRial: string;
goldCreditLimitGrams: string;
}
export interface ProductVariantSummary {
id: string;
title: string;
rashWeightGrams: string;
defaultWagePercent: string;
}
export interface ProductSummary {
id: string;
title: string;
variants: ProductVariantSummary[];
}
export interface OrderDetail {
id: string;
orderNumber: string;
status: string;
totalGoldWeightGrams: string;
wageWeightGrams: string;
flatRialCharge: string;
isSuspendedOverCreditLimit: boolean;
deliveredAt: string | null;
items: Array<{
id: string;
quantity: number;
computedWeightGrams: string;
}>;
statusEvents: Array<{
toStatus: string;
note: string | null;
createdAt: string;
}>;
}
export declare const api: {
listCustomers: () => Promise<CustomerSummary[]>;
getCustomerBalance: (id: string) => Promise<CustomerBalanceDto>;
listProducts: () => Promise<ProductSummary[]>;
createOrder: (dto: CreateOrderDto) => Promise<OrderDetail>;
getOrder: (id: string) => Promise<OrderDetail>;
updateOrderStatus: (id: string, status: string, note?: string) => Promise<OrderDetail>;
};
+20
View File
@@ -0,0 +1,20 @@
const BASE = '/api';
async function request(path, options) {
const res = await fetch(`${BASE}${path}`, {
headers: { 'Content-Type': 'application/json' },
...options,
});
if (!res.ok) {
const body = await res.text();
throw new Error(`API ${path} failed (${res.status}): ${body}`);
}
return res.json();
}
export const api = {
listCustomers: () => request('/customers'),
getCustomerBalance: (id) => request(`/accounting/customers/${id}/balance`),
listProducts: () => request('/catalog/products'),
createOrder: (dto) => request('/orders', { method: 'POST', body: JSON.stringify(dto) }),
getOrder: (id) => request(`/orders/${id}`),
updateOrderStatus: (id, status, note) => request(`/orders/${id}/status`, { method: 'PATCH', body: JSON.stringify({ status, note }) }),
};
+61
View File
@@ -0,0 +1,61 @@
import type { CreateOrderDto, CustomerBalanceDto } from '@gold-bank/shared-types';
const BASE = '/api';
async function request<T>(path: string, options?: RequestInit): Promise<T> {
const res = await fetch(`${BASE}${path}`, {
headers: { 'Content-Type': 'application/json' },
...options,
});
if (!res.ok) {
const body = await res.text();
throw new Error(`API ${path} failed (${res.status}): ${body}`);
}
return res.json();
}
export interface CustomerSummary {
id: string;
fullName: string;
mobile: string;
goldDebtGrams: string;
fiatDebtRial: string;
goldCreditLimitGrams: string;
}
export interface ProductVariantSummary {
id: string;
title: string;
rashWeightGrams: string;
defaultWagePercent: string;
}
export interface ProductSummary {
id: string;
title: string;
variants: ProductVariantSummary[];
}
export interface OrderDetail {
id: string;
orderNumber: string;
status: string;
totalGoldWeightGrams: string;
wageWeightGrams: string;
flatRialCharge: string;
isSuspendedOverCreditLimit: boolean;
deliveredAt: string | null;
items: Array<{ id: string; quantity: number; computedWeightGrams: string }>;
statusEvents: Array<{ toStatus: string; note: string | null; createdAt: string }>;
}
export const api = {
listCustomers: () => request<CustomerSummary[]>('/customers'),
getCustomerBalance: (id: string) => request<CustomerBalanceDto>(`/accounting/customers/${id}/balance`),
listProducts: () => request<ProductSummary[]>('/catalog/products'),
createOrder: (dto: CreateOrderDto) =>
request<OrderDetail>('/orders', { method: 'POST', body: JSON.stringify(dto) }),
getOrder: (id: string) => request<OrderDetail>(`/orders/${id}`),
updateOrderStatus: (id: string, status: string, note?: string) =>
request<OrderDetail>(`/orders/${id}/status`, { method: 'PATCH', body: JSON.stringify({ status, note }) }),
};