create user pages crud also update pages ui build order and car ,driver first page interfase create model layer to componants

This commit is contained in:
m7amedez5511
2026-06-10 16:58:17 +03:00
parent 53c03e9867
commit e0e38dc87a
34 changed files with 2963 additions and 862 deletions

4
types/branch.ts Normal file
View File

@@ -0,0 +1,4 @@
export interface Branch {
id: string;
name: string;
}

97
types/order.ts Normal file
View File

@@ -0,0 +1,97 @@
export type OrderStatus =
| "Created"
| "Assigned"
| "InTransit"
| "Delivered"
| "Returned"
| "Cancelled";
export type PaymentMethod = "Cash" | "Card" | "Prepaid";
export type PaymentStatus = "Pending" | "Paid" | "Failed" | "Refunded";
export interface OrderAddress {
details?: {
city?: string;
district?: string;
street?: string;
buildingNo?: string;
unitNo?: string;
zipCode?: string;
};
location?: {
coordinates?: [number, number];
};
}
export interface Order {
id: string;
shipmentNumber: string;
recipientName: string;
recipientPhone: string;
currentStatus: OrderStatus;
clientId: string;
tripId?: string | null;
totalPrice?: number | null;
subTotal?: number | null;
vatAmount?: number | null;
vatRate?: number | null;
paymentMethod?: PaymentMethod | null;
paymentStatus?: PaymentStatus | null;
type?: string | null;
quantity: number;
weight?: number | null;
deliveryAddressId?: string | null;
pickupAddressId?: string | null;
createdAt: string;
updatedAt: string;
statusHistory?: Array<{
id: string;
status: OrderStatus;
reason?: string | null;
createdAt: string;
}>;
client?: { id: string; name: string; phone: string };
trip?: { id: string; tripNumber: string } | null;
}
export interface CreateOrderPayload {
shipmentNumber: string;
recipientName: string;
recipientPhone: string;
clientId: string;
tripId?: string;
subTotal?: number;
vatRate?: number;
vatAmount?: number;
totalPrice?: number;
paymentMethod?: PaymentMethod;
paymentStatus?: PaymentStatus;
type?: string;
quantity?: number;
weight?: number;
deliveryAddress?: OrderAddress;
pickupAddressId?: string;
}
export interface UpdateOrderPayload extends Partial<CreateOrderPayload> {
currentStatus?: OrderStatus;
}
export interface UpdateOrderStatusPayload {
status: OrderStatus;
reason?: string;
}
export interface TransferOrderPayload {
tripId: string;
}
export interface OrdersResponse {
data: Order[];
meta: {
total: number;
page: number;
limit: number;
totalPages: number;
};
}

4
types/role.ts Normal file
View File

@@ -0,0 +1,4 @@
export interface Role {
id: string;
name: string;
}

54
types/user.ts Normal file
View File

@@ -0,0 +1,54 @@
export interface User {
id: string;
name: string;
userName?: string;
email?: string;
phone: string;
isActive: boolean;
createdAt: string;
role?: { id?: string; name: string };
branch?: { id?: string; name: string };
}
export interface UserFormData {
name: string;
email: string;
phone: string;
password: string;
roleId: string;
branchId: string;
}
export interface FormErrors {
name?: string;
email?: string;
phone?: string;
password?: string;
roleId?: string;
branchId?: string;
}
export interface ApiListResponse<T> {
data: {
data: T[];
pagination: { total: number; page: number; pages: number ; };
meta?: { total: number; pages: number };
};
}
export type TableState = {
users: User[];
loading: boolean;
total: number;
pages: number;
error: string | null;
};
export type TableAction =
| { type: "LOAD_START" }
| { type: "LOAD_OK"; users: User[]; total: number; pages: number }
| { type: "LOAD_ERR"; error: string }
| { type: "ADD"; user: User }
| { type: "UPDATE"; user: User }
| { type: "DELETE"; id: string }
| { type: "CLEAR_ERR" };