added debounce to - + buttons

This commit is contained in:
Jelaletdin12
2025-11-16 23:37:21 +05:00
parent f867896817
commit 4fe0fb3d4e
52 changed files with 2548 additions and 2253 deletions

View File

@@ -3,7 +3,7 @@ export * from "../../features/category/hooks/useCategories"
export * from "../../features/cart/hooks/useCart"
export * from "../../features/favorites/hooks/useFavorites"
export * from "../../features/orders/hooks/useOrders"
export * from "./useSearch"
export * from "../../features/search/hooks/useSearch"
export * from "../../features/profile/hooks/useUserProfile"
export * from "./useOpenStore"

View File

@@ -1,28 +0,0 @@
// import { useQuery } from "@tanstack/react-query"
// import { apiClient } from "@/lib/api"
// import type { SearchFilters, SearchResponse } from "@/lib/types/api"
// export function useSearch(options: SearchFilters) {
// const { q, category_id, brand_id, price_from, price_to, page = 1, per_page = 20 } = options
// return useQuery({
// queryKey: ["search", { q, category_id, brand_id, price_from, price_to, page, per_page }],
// queryFn: async () => {
// const params = new URLSearchParams({
// page: String(page),
// per_page: String(per_page),
// })
// // if (q) params.append("q", q)
// if (category_id) params.append("category_id", String(category_id))
// if (brand_id) params.append("brand_id", String(brand_id))
// if (price_from) params.append("price_from", String(price_from))
// if (price_to) params.append("price_to", String(price_to))
// const response = await apiClient.get<SearchResponse>(`/search?${params}`)
// return response.data
// },
// enabled: !!q && q.length > 0,
// staleTime: 1000 * 60 * 5,
// })
// }

View File

@@ -11,6 +11,14 @@ export interface ProductMedia {
images_1200x1200: string;
}
export type DeliveryType = "SELECTED_DELIVERY" | "PICK_UP";
export interface PaymentType {
id: number;
name: string;
code?: string;
}
export interface ProductProperty {
attribute_id: number;
name: string;
@@ -22,6 +30,22 @@ export interface ProductReviews {
rating: string;
}
export interface ProductBrand {
id: number | null;
name: string | null;
}
export interface ProductChannel {
id: number;
name: string;
}
export interface ProductCategory {
id: number;
name: string;
slug?: string;
}
export interface Product {
id: number;
parent_id: number | null;
@@ -47,22 +71,13 @@ export interface Product {
size: string | null;
available_colors?: string[];
available_sizes?: string[];
brand: {
id: number | null;
name: string | null;
};
channel?: Array<{
id: number;
name: string;
}>;
brand: ProductBrand;
channel?: ProductChannel[];
properties?: ProductProperty[];
variations?: any[];
reviews: ProductReviews;
reviews_resources?: any[];
categories?: Array<{
id: number;
name: string;
}>;
categories?: ProductCategory[];
}
// Category Types
@@ -71,8 +86,10 @@ export interface Category {
name: string;
slug: string;
image: string;
parent_id?: number;
parent_id?: number | null;
children?: Category[];
media:ProductMedia[];
}
// Collection Types
@@ -86,19 +103,43 @@ export interface Collection {
}
// Cart Types
export interface CartProduct {
id: number;
name: string;
slug: string;
price_amount: string;
old_price_amount: string | null;
media?: ProductMedia[];
channel?: ProductChannel[];
stock: number;
image?: string;
images?: string[];
}
export interface CartItem {
id: number;
product_id: number;
product?: Product;
seller: {
product: CartProduct;
product_quantity: number;
seller?: {
id: number;
name: string;
};
quantity: number;
price: number;
total: number;
price_formatted?: string;
sub_total_formatted?: string;
price_formatted: string;
sub_total_formatted: string;
total_formatted: string;
discount_formatted: string;
}
export interface CartResponse {
message?: string;
data: CartItem[];
count?: number;
total?: number;
total_formatted?: string;
}
export interface Cart {
@@ -111,33 +152,84 @@ export interface Cart {
// Favorites Types
export interface Favorite {
id: number;
id?: number;
product_id: number;
product?: Product;
product: Product;
added_at?: string;
created_at?: string;
}
// Order Types
export interface OrderItem {
export interface OrderProduct {
id: number;
product_id: number;
product?: Product;
name: string;
thumbnail: string;
images_400x400: string;
images_800x800: string;
images_1200x1200: string;
}
export interface OrderItem {
product: OrderProduct;
order: {
id: number;
};
quantity: number;
price: number;
total: number;
unit_price_amount: string;
}
export interface Order {
id: number;
number?: string;
status: "pending" | "processing" | "shipped" | "delivered" | "cancelled";
items: OrderItem[];
total: number;
total_formatted?: string;
created_at: string;
updated_at?: string;
estimated_delivery?: string;
tracking_number?: string;
status: string;
shipping_method: string;
notes: string | null;
customer_name: string;
customer_phone: string;
customer_address: string;
delivery_time: string;
delivery_at: string;
region: string;
user_id: number;
province_id: number | null;
payment_type: string;
orderItems: OrderItem[];
}
export interface OrdersResponse {
message: string;
data: Order[];
pagination: {
page: number;
perPage: number;
count: number;
first_page_url: string;
next_page_url: string | null;
prev_page_url: string | null;
};
}
export interface CreateOrderRequest {
customer_name: string;
customer_phone: string;
customer_address: string;
shipping_method: string;
payment_type_id: number;
delivery_time?: string;
delivery_at?: string;
region: string;
note?: string;
}
export interface CreateOrderPayload {
customer_name?: string;
customer_phone?: string;
customer_address: string;
shipping_method: string;
payment_type_id: number;
delivery_time?: string;
delivery_at?: string;
region: string;
note?: string;
}
// Pagination Types
@@ -152,6 +244,7 @@ export interface Pagination {
last_page?: number;
per_page?: number;
total?: number;
hasMorePages?: boolean;
}
export interface PaginatedResponse<T> {
@@ -181,15 +274,31 @@ export interface SearchResponse {
};
}
// Profile Types
// User Profile Types
export interface UserProfile {
id: number;
email: string;
phone?: string;
first_name: string;
last_name: string;
phone_number: string;
address: string;
email?: string;
}
export interface ProfileResponse {
message: string;
data: UserProfile;
}
export interface UpdateProfileRequest {
first_name?: string;
last_name?: string;
avatar?: string;
created_at: string;
phone_number?: string;
address?: string;
email?: string;
}
export interface UpdateProfileResponse {
message: string;
data: UserProfile;
}
// Auth Types
@@ -198,6 +307,26 @@ export interface AuthResponse {
user: UserProfile;
}
export interface LoginRequest {
phone_number: string;
}
export interface VerifyTokenRequest {
phone_number: string;
code: string;
}
export interface LoginResponse {
message: string;
token?: string;
}
export interface VerifyTokenResponse {
message: string;
token: string;
user: UserProfile;
}
// Banner Types
export interface Banner {
id: number;
@@ -210,19 +339,22 @@ export interface Banner {
place?: string;
}
// Generic API Error Response
export interface ApiError {
message: string;
errors?: Record<string, string[]>;
}
// Region, Address, PaymentType, and ShippingMethod Types
// Region and Province Types
export interface Region {
id: number;
code: string;
name: string;
region: string;
}
export interface Province {
id: number;
name: string;
region: string;
code?: string;
}
// Address Types
export interface Address {
id: number;
title: string;
@@ -232,27 +364,111 @@ export interface Address {
is_default?: boolean;
}
// Payment Type Options
export interface PaymentTypeOption {
id: number;
name: string;
code: string;
}
// Shipping Method Types
export interface ShippingMethod {
id: number;
name: string;
code: string;
}
// Order creation payload type
export interface CreateOrderPayload {
customer_name?: string;
customer_phone?: string;
customer_address: string;
shipping_method: string;
payment_type_id: number;
delivery_time?: string;
delivery_at?: string;
region: string;
note?: string;
// Generic API Error Response
export interface ApiError {
message: string;
errors?: Record<string, string[]>;
error?: string;
}
// API Response Wrapper
export interface ApiResponse<T = any> {
message?: string;
data?: T;
error?: string;
success?: boolean;
}
// Add to Cart Request
export interface AddToCartRequest {
productId: number;
quantity?: number;
}
// Update Cart Item Quantity Request
export interface UpdateCartItemQuantityRequest {
productId: number;
quantity: number;
}
// Remove from Cart Request
export interface RemoveFromCartRequest {
productId: number;
}
// Add to Favorites Request
export interface AddToFavoritesRequest {
productId: number;
}
// Remove from Favorites Request
export interface RemoveFromFavoritesRequest {
productId: number;
}
// Cancel Order Request
export interface CancelOrderRequest {
orderId: number;
}
// Order Summary for Cart Page
export interface OrderBillingItem {
title: string;
value: string;
}
export interface OrderBilling {
body: OrderBillingItem[];
footer: {
title: string;
value: string;
};
}
export interface OrderSummary {
id: number;
seller: {
id: number;
name: string;
};
items: CartItem[];
billing: OrderBilling;
}
// Category Products Response
export interface CategoryProductsResponse {
message?: string;
data: Product[];
pagination?: Pagination;
}
// Query Options for Hooks
export interface QueryOptions {
enabled?: boolean;
page?: number;
limit?: number;
refetchOnWindowFocus?: boolean;
refetchOnMount?: boolean;
staleTime?: number;
}
// User Store Data
export interface UserOrderData {
customer_name: string;
customer_phone: string;
customer_address?: string;
}