fitst commit

This commit is contained in:
Samandar Turgunboyev
2026-01-28 18:26:50 +05:00
parent 166a55b1e9
commit 124798419b
196 changed files with 26627 additions and 421 deletions

View File

@@ -0,0 +1,80 @@
import createContextHook from '@nkzw/create-context-hook';
import { useState } from 'react';
import { Announcement, Bonus, Employee, ProductService } from './type';
export const [ProfileDataProvider, useProfileData] = createContextHook(() => {
const [employees, setEmployees] = useState<Employee[]>([
{
id: '1',
firstName: 'Aziz',
lastName: 'Rahimov',
phoneNumber: '+998901234567',
addedAt: new Date().toISOString(),
},
]);
const [announcements] = useState<Announcement[]>([
{
id: '1',
name: "Yangi loyiha bo'yicha hamkorlik",
companyTypes: ['IT', 'Qurilish'],
totalAmount: 5000000,
paymentStatus: 'paid',
createdAt: new Date().toISOString(),
},
]);
const [bonuses] = useState<Bonus[]>([
{
id: '1',
title: 'Yillik bonus',
description: "Yil davomida ko'rsatilgan yuqori natijalarga oid bonus",
percentage: 15,
bonusAmount: 3000000,
createdAt: new Date().toISOString(),
},
]);
const [productServices, setProductServices] = useState<ProductService[]>([]);
const addEmployee = (employee: Omit<Employee, 'id' | 'addedAt'>) => {
setEmployees((prev) => [
...prev,
{
...employee,
id: Date.now().toString(),
addedAt: new Date().toISOString(),
},
]);
};
const removeEmployee = (id: string) => {
setEmployees((prev) => prev.filter((e) => e.id !== id));
};
const updateEmployee = (id: string, data: Partial<Employee>) => {
setEmployees((prev) => prev.map((e) => (e.id === id ? { ...e, ...data } : e)));
};
const addProductService = (service: Omit<ProductService, 'id' | 'createdAt'>) => {
setProductServices((prev) => [
...prev,
{
...service,
id: Date.now().toString(),
createdAt: new Date().toISOString(),
},
]);
};
return {
employees,
addEmployee,
removeEmployee,
updateEmployee,
announcements,
bonuses,
productServices,
addProductService,
};
});

108
screens/profile/lib/api.ts Normal file
View File

@@ -0,0 +1,108 @@
import httpClient from '@/api/httpClient';
import { API_URLS } from '@/api/URLs';
import { ProductBody, ProductResponse } from '@/screens/home/lib/types';
import { AxiosResponse } from 'axios';
import {
ExployeesResponse,
MyAdsData,
MyAdsDataRes,
MyBonusesData,
UserInfoResponseData,
} from './type';
export const user_api = {
async getMe(): Promise<AxiosResponse<UserInfoResponseData>> {
const res = await httpClient.get(API_URLS.Get_Me);
return res;
},
async updateMe(body: {
first_name: string;
industries: {
id: number;
name: string;
code: string;
external_id: null | number;
level: number;
is_leaf: boolean;
icon_name: null | string;
parent: {
id: number;
name: string;
code: string;
};
}[];
person_type: 'employee' | 'legal_entity' | 'ytt' | 'band';
phone: string;
activate_types: number[];
}) {
const res = await httpClient.patch(API_URLS.User_Update, body);
return res;
},
async employess(params: {
page: number;
page_size: number;
}): Promise<AxiosResponse<ExployeesResponse>> {
const res = await httpClient.get(API_URLS.Employee_List, { params });
return res;
},
async create_employee(body: { first_name: string; last_name: string; phone: string }) {
const res = await httpClient.post(API_URLS.Employee_List, body);
return res;
},
async my_ads(params: { page: number; page_size: number }): Promise<AxiosResponse<MyAdsData>> {
const res = await httpClient.get(API_URLS.My_Ads, { params });
return res;
},
async my_ads_detail(id: number): Promise<AxiosResponse<{ status: boolean; data: MyAdsDataRes }>> {
const res = await httpClient.get(API_URLS.My_Ads_Detail(id));
return res;
},
async my_bonuses(params: {
page: number;
page_size: number;
}): Promise<AxiosResponse<MyBonusesData>> {
const res = await httpClient.get(API_URLS.My_Bonuses, { params });
return res;
},
async my_sevices(params: {
page: number;
page_size: number;
my: boolean;
}): Promise<AxiosResponse<ProductBody>> {
const res = await httpClient.get(API_URLS.Get_Products, { params });
return res;
},
async add_service(body: FormData) {
const res = await httpClient.post(API_URLS.Get_Products, body, {
headers: { 'Content-Type': 'multipart/form-data' },
});
return res;
},
async update_service({ body, id }: { body: FormData; id: number }) {
const res = await httpClient.patch(API_URLS.Detail_Products(id), body, {
headers: { 'Content-Type': 'multipart/form-data' },
});
return res;
},
async delete_service(id: number) {
const res = await httpClient.delete(API_URLS.Delete_Products(id));
return res;
},
async detail_service(
id: number
): Promise<AxiosResponse<{ status: boolean; data: ProductResponse }>> {
const res = await httpClient.get(API_URLS.Detail_Products(id));
return res;
},
};

168
screens/profile/lib/type.ts Normal file
View File

@@ -0,0 +1,168 @@
export interface Employee {
id: string;
firstName: string;
lastName: string;
phoneNumber: string;
addedAt: string;
}
export interface Announcement {
id: string;
name: string;
companyTypes: string[];
totalAmount: number;
paymentStatus: 'paid' | 'pending' | 'failed';
createdAt: string;
}
export interface Bonus {
id: string;
title: string;
description: string;
percentage: number;
bonusAmount: number;
createdAt: string;
}
export interface ProductService {
id: string;
title: string;
description: string;
mediaUrl: string;
mediaType: 'image' | 'video';
categories: string[];
createdAt: string;
}
export interface UserInfoResponseData {
status: boolean;
data: {
id: number;
activate_types: {
id: number;
name: string;
code: string;
external_id: null | number;
level: number;
is_leaf: boolean;
icon_name: null | string;
parent: {
id: number;
name: string;
code: string;
};
}[];
last_login: null | string;
is_superuser: boolean;
is_staff: boolean;
is_active: boolean;
date_joined: string;
first_name: string;
last_name: null | string;
email: null | string;
phone: string;
username: string;
validated_at: string;
company_name: string;
stir: string;
director_full_name: string;
referral: null | string;
referral_amount: number;
referral_share: number;
telegram_id: null | string;
can_create_referral: boolean;
role: string;
person_type: 'employee' | 'legal_entity' | 'ytt' | 'band';
company_image: null | string;
address: null | string;
district: number;
parent: null | string;
user_tg_ids: number[];
};
}
export interface ExployeesResponse {
status: boolean;
data: {
links: {
previous: null | string;
next: null | string;
};
total_items: number;
total_pages: number;
page_size: number;
current_page: number;
results: ExployeesDataResponse[];
};
}
export interface ExployeesDataResponse {
first_name: string;
last_name: string;
phone: string;
}
export interface MyAdsData {
status: boolean;
data: {
links: {
previous: null | string;
next: null | string;
};
total_items: number;
total_pages: number;
page_size: number;
current_page: number;
results: MyAdsDataRes[];
};
}
export interface MyAdsDataRes {
id: number;
title: string;
description: string;
total_view_count: number;
files: {
id: number;
file: string;
}[];
status: 'paid' | 'pending' | 'verified' | 'canceled';
types: {
id: number;
name: string;
}[];
letters: string[];
total_price: number;
phone_number: string;
payments_type: 'OTHER' | 'PAYME' | 'REFERRAL';
created_at: string;
username: string;
}
export interface MyBonusesData {
status: boolean;
data: {
links: {
previous: null | string;
next: null | string;
};
total_items: number;
total_pages: number;
page_size: number;
current_page: number;
results: MyBonusesDataRes[];
};
}
export interface MyBonusesDataRes {
id: number;
ad: {
title: string;
description: string;
};
amount: number;
percent: number;
created_at: string;
}