fitst commit
This commit is contained in:
73
screens/home/lib/api.ts
Normal file
73
screens/home/lib/api.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import httpClient from '@/api/httpClient';
|
||||
import { API_URLS } from '@/api/URLs';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import {
|
||||
businessAboutDetailRes,
|
||||
businessAboutRes,
|
||||
Categories,
|
||||
CompanyBody,
|
||||
CountryBody,
|
||||
ProductBody,
|
||||
States,
|
||||
} from './types';
|
||||
|
||||
export const products_api = {
|
||||
async getProducts(params: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
search?: string;
|
||||
}): Promise<AxiosResponse<ProductBody>> {
|
||||
const res = await httpClient.get(API_URLS.Get_Products, { params });
|
||||
return res;
|
||||
},
|
||||
|
||||
async getCompany(params: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
search?: string;
|
||||
}): Promise<AxiosResponse<CompanyBody>> {
|
||||
const res = await httpClient.get(API_URLS.Get_Company, { params });
|
||||
return res;
|
||||
},
|
||||
|
||||
async getCountry(params: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
search?: string;
|
||||
}): Promise<AxiosResponse<CountryBody>> {
|
||||
const res = await httpClient.get(API_URLS.Get_Countries, { params });
|
||||
return res;
|
||||
},
|
||||
|
||||
async getStates(): Promise<AxiosResponse<States>> {
|
||||
const res = await httpClient.get(API_URLS.Get_States);
|
||||
return res;
|
||||
},
|
||||
|
||||
async getCategorys(params?: { parent: number }): Promise<AxiosResponse<Categories>> {
|
||||
const res = await httpClient.get(API_URLS.Get_Categories, { params });
|
||||
return res;
|
||||
},
|
||||
|
||||
async getCategoryChild(id: number): Promise<AxiosResponse<Categories>> {
|
||||
const res = await httpClient.get(API_URLS.Get_Categories_Child(id));
|
||||
return res;
|
||||
},
|
||||
|
||||
async businessAbout(params: {
|
||||
country?: string;
|
||||
district: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
region?: string;
|
||||
types?: number;
|
||||
}): Promise<AxiosResponse<businessAboutRes>> {
|
||||
const res = await httpClient.get(API_URLS.Business_About, { params });
|
||||
return res;
|
||||
},
|
||||
|
||||
async businessAboutDetail(id: number): Promise<AxiosResponse<businessAboutDetailRes>> {
|
||||
const res = await httpClient.get(API_URLS.Business_About_Detail(id));
|
||||
return res;
|
||||
},
|
||||
};
|
||||
150
screens/home/lib/types.ts
Normal file
150
screens/home/lib/types.ts
Normal file
@@ -0,0 +1,150 @@
|
||||
export interface ProductBody {
|
||||
status: boolean;
|
||||
data: {
|
||||
links: {
|
||||
previous: null | string;
|
||||
next: null | string;
|
||||
};
|
||||
total_items: number;
|
||||
total_pages: number;
|
||||
page_size: number;
|
||||
current_page: number;
|
||||
results: ProductResponse[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface ProductResponse {
|
||||
id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
company: string;
|
||||
files: {
|
||||
id: number;
|
||||
file: string;
|
||||
}[];
|
||||
category: { id: number; name: string; icon: string }[];
|
||||
}
|
||||
|
||||
export interface CompanyBody {
|
||||
status: boolean;
|
||||
data: {
|
||||
links: {
|
||||
previous: null | string;
|
||||
next: null | string;
|
||||
};
|
||||
total_items: number;
|
||||
total_pages: number;
|
||||
page_size: number;
|
||||
current_page: number;
|
||||
results: CompanyResponse[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface CompanyResponse {
|
||||
id: number;
|
||||
company_name: string;
|
||||
country_name: string;
|
||||
region_name: string;
|
||||
district_name: string;
|
||||
product_service_company: {
|
||||
id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
company: string;
|
||||
files: [
|
||||
{
|
||||
id: number;
|
||||
file: string;
|
||||
},
|
||||
];
|
||||
category: [];
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface CountryBody {
|
||||
status: boolean;
|
||||
data: {
|
||||
links: {
|
||||
previous: null | string;
|
||||
next: null | string;
|
||||
};
|
||||
total_items: number;
|
||||
total_pages: number;
|
||||
page_size: number;
|
||||
current_page: number;
|
||||
results: CountryResponse[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface CountryResponse {
|
||||
id: number;
|
||||
name: string;
|
||||
companies: {
|
||||
id: number;
|
||||
company_name: string;
|
||||
service_count: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface States {
|
||||
status: boolean;
|
||||
data: {
|
||||
id: number;
|
||||
name: string;
|
||||
region: {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
districts: { id: number; name: string; code: string }[];
|
||||
}[];
|
||||
code: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface Categories {
|
||||
status: boolean;
|
||||
data: {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
external_id: null | string;
|
||||
level: number;
|
||||
is_leaf: boolean;
|
||||
icon_name: null | string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface businessAboutRes {
|
||||
status: boolean;
|
||||
data: {
|
||||
links: {
|
||||
previous: null | string;
|
||||
next: null | string;
|
||||
};
|
||||
total_items: number;
|
||||
total_pages: number;
|
||||
page_size: number;
|
||||
current_page: number;
|
||||
results: { id: number; company_name: string }[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface businessAboutDetailRes {
|
||||
status: boolean;
|
||||
data: businessAboutDetailResData;
|
||||
}
|
||||
|
||||
export interface businessAboutDetailResData {
|
||||
company_name: string;
|
||||
director_full_name: string;
|
||||
company_image: null | string;
|
||||
phone: string;
|
||||
product_service_company: {
|
||||
title: string;
|
||||
description: string;
|
||||
category: { id: number; name: string; icon_name: string }[];
|
||||
files: {
|
||||
file: string;
|
||||
}[];
|
||||
}[];
|
||||
}
|
||||
Reference in New Issue
Block a user