From 029dc9da8d76a1c90c642559e29bea711def9962 Mon Sep 17 00:00:00 2001 From: Dilmurod Date: Wed, 4 Jun 2025 16:32:31 +0500 Subject: [PATCH] Pagination added per page and filters --- src/API/LayoutApi/accounting.ts | 39 +-- src/API/LayoutApi/services.ts | 9 +- src/API/LayoutApi/statistic.ts | 23 +- src/API/LayoutApi/tasks.ts | 2 +- src/API/LayoutApi/teams.ts | 6 +- src/API/auth/activate.ts | 1 - .../Accounting/AccountingCurrent.tsx | 263 +++++++++-------- .../Accounting/AccountingHistory.tsx | 197 ++++++++----- src/Components/Accounting/AccountingLast.tsx | 236 +++++++++++----- src/Components/Accounting/ConfirmedMonths.tsx | 102 ++++++- src/Components/CallRequests/Call.tsx | 22 +- src/Components/Companies/Companies.tsx | 22 +- src/Components/Companies/CompaniesEdit.tsx | 2 +- src/Components/Customers/Customers.tsx | 22 +- src/Components/Requests/Requests.tsx | 21 +- src/Components/Services/Services.tsx | 84 ++++-- src/Components/Statistics/Statistic.tsx | 264 ++++++++++++++++-- src/Components/Statistics/StatisticTable.tsx | 39 +-- .../Statistics/StatisticTeamTable.tsx | 37 +-- .../Statistics/StatisticsSupportTable.tsx | 39 +-- src/Components/Tasks/AddTask.tsx | 4 +- src/Components/Tasks/TaskModal.tsx | 60 ++-- src/Components/Tasks/Tasks.tsx | 23 +- src/Components/Teams/TeamTable.tsx | 33 +-- src/Components/Teams/Teams.tsx | 103 ++++++- src/Components/Updates/Update.tsx | 19 +- src/Components/Users/UserEdit.tsx | 2 +- src/Components/Users/Users.tsx | 22 +- src/Hooks/Accounting/index.ts | 54 +++- src/Hooks/Services/index.ts | 7 +- src/Hooks/Stats/index.ts | 43 ++- src/Hooks/Teams/index.ts | 11 +- 32 files changed, 1340 insertions(+), 471 deletions(-) diff --git a/src/API/LayoutApi/accounting.ts b/src/API/LayoutApi/accounting.ts index 8be40b5..6de7b00 100644 --- a/src/API/LayoutApi/accounting.ts +++ b/src/API/LayoutApi/accounting.ts @@ -1,18 +1,26 @@ -import { TAccountingConfirmedMonths } from "./../../types/Accounting/TAccounting"; -import { - TAccounting, - TAccountingHistory, -} from "../../types/Accounting/TAccounting"; import instance from "../api"; +export type TAccountingConfirmedMonthsParams = { + page?: number; + page_size?: number; +}; + export type TAccountingGetParams = { month: string; search?: string; team?: string; + page?: number; + page_size?: number; + role?: number; + salary_type?: string; }; export type TAccountingHistoryGetParams = { search?: string; team?: string; + page?: number; + page_size?: number; + role?: number; + salary_type?: string; }; export const AccountingController = { @@ -21,16 +29,16 @@ export const AccountingController = { if (!!filterObject.month) params.month = filterObject.month; - const { data } = await instance.get(`/employees-salaries/`, { + const { data } = await instance.get(`/employees-salaries/`, { params, }); return data; }, - async confirmedMonths() { - const { data } = await instance.get( - `/salaries-group/` - ); + async confirmedMonths(filterObject: TAccountingConfirmedMonthsParams) { + const { data } = await instance.get(`/salaries-group/`, { + params: filterObject, + }); return data; }, @@ -38,13 +46,12 @@ export const AccountingController = { const params = { ...filterObject }; if (!!filterObject.search) params.search = filterObject.search; if (!!filterObject.team) params.team = filterObject.team; + if (!!filterObject.page) params.page = filterObject.page; + if (!!filterObject.team) params.page_size = filterObject.page_size; - const { data } = await instance.get( - `/employees-salaries-history/`, - { - params, - } - ); + const { data } = await instance.get(`/employees-salaries-history/`, { + params, + }); return data; }, }; diff --git a/src/API/LayoutApi/services.ts b/src/API/LayoutApi/services.ts index 273c868..decd224 100644 --- a/src/API/LayoutApi/services.ts +++ b/src/API/LayoutApi/services.ts @@ -12,8 +12,13 @@ export type TServicePostParams = { }; export const serviceController = { - async read() { - const { data } = await instance.get(`services/`); + async read(page?: number, page_size?: number) { + const params: Record = {}; + if (page !== undefined) params.page = page; + if (page_size !== undefined) params.page_size = page_size; + const { data } = await instance.get(`services/`, { + params: { page, page_size }, + }); return data; }, diff --git a/src/API/LayoutApi/statistic.ts b/src/API/LayoutApi/statistic.ts index 60ab01f..75a2bc3 100644 --- a/src/API/LayoutApi/statistic.ts +++ b/src/API/LayoutApi/statistic.ts @@ -14,15 +14,21 @@ export type TStatGetParams = { start_date?: string; end_date?: string; for_salary?: boolean; + page?: number; + page_size?: number; }; export type TStatTeamGetParams = { search?: string; start_date?: string; end_date?: string; + page?: number; + page_size?: number; }; export type TStatCreatorsGetParams = { + page?: number; + page_size?: number; start_date?: string; end_date?: string; search?: string; @@ -45,7 +51,7 @@ export const statController = { if (!!filterObject.start_date) params.start_date = filterObject.start_date; if (!!filterObject.end_date) params.end_date = filterObject.end_date; - const { data } = await instance.get(`stats/all-users/`, { + const { data } = await instance.get(`stats/all-users/`, { params, }); return data; @@ -58,7 +64,7 @@ export const statController = { if (!!filterObject.start_date) params.start_date = filterObject.start_date; if (!!filterObject.end_date) params.end_date = filterObject.end_date; - const { data } = await instance.get(`stats/all-teams/`, { + const { data } = await instance.get(`stats/all-teams/`, { params, }); return data; @@ -70,15 +76,15 @@ export const statController = { if (!!filterObject.start_date) params.start_date = filterObject.start_date; if (!!filterObject.end_date) params.end_date = filterObject.end_date; if (!!filterObject.search) params.search = filterObject.search; + if (!!filterObject.page) params.page = filterObject.page; + if (!!filterObject.page_size) params.page_size = filterObject.page_size; - const { data } = await instance.get( - `stats/task-creators/`, - { - params, - } - ); + const { data } = await instance.get(`stats/task-creators/`, { + params, + }); return data; }, + async cards(filterObject: TStatCreatorsGetParams) { const params = { ...filterObject }; @@ -90,6 +96,7 @@ export const statController = { }); return data; }, + async teamChart(filterObject: TteamChartGetParams) { const params = { ...filterObject }; diff --git a/src/API/LayoutApi/tasks.ts b/src/API/LayoutApi/tasks.ts index d5f023c..fc417e1 100644 --- a/src/API/LayoutApi/tasks.ts +++ b/src/API/LayoutApi/tasks.ts @@ -53,7 +53,7 @@ export const taskController = { if (!!filterObject.page && filterObject.page !== 0) params.page = filterObject.page; - params.page_size = isMobile ? 10 : 15; + params.page_size = filterObject.page_size; if (!!filterObject.search) params.search = filterObject.search; if (Array.isArray(filterObject.status)) { params.status = filterObject.status.join(","); diff --git a/src/API/LayoutApi/teams.ts b/src/API/LayoutApi/teams.ts index a76f2ff..d2ff81e 100644 --- a/src/API/LayoutApi/teams.ts +++ b/src/API/LayoutApi/teams.ts @@ -3,6 +3,8 @@ import instance from "../api"; import { message } from "antd"; export type TTeamGetParams = { + page?: number; + page_size?: number; name?: string; company_id?: string | number; }; @@ -23,8 +25,10 @@ export const teamController = { if (!!obj.company_id) params.company_id = obj.company_id; if (!!obj.name) params.name = obj.name; + if (!!obj.page) params.page = obj.page; + if (!!obj.page_size) params.page_size = obj.page_size; - const { data } = await instance.get(`teams/`, { + const { data } = await instance.get(`teams/`, { params, }); return data; diff --git a/src/API/auth/activate.ts b/src/API/auth/activate.ts index b006a9a..752d253 100644 --- a/src/API/auth/activate.ts +++ b/src/API/auth/activate.ts @@ -28,7 +28,6 @@ export const registryVerify = async (value: activateInterface) => { role: data?.data.role, }; console.log(data); - const userJSON = JSON.stringify(userObject); localStorage.setItem("user", userJSON); diff --git a/src/Components/Accounting/AccountingCurrent.tsx b/src/Components/Accounting/AccountingCurrent.tsx index c894066..ddaff5c 100644 --- a/src/Components/Accounting/AccountingCurrent.tsx +++ b/src/Components/Accounting/AccountingCurrent.tsx @@ -9,6 +9,7 @@ import { message, Modal, Select, + Space, Table, Tooltip, Typography, @@ -26,8 +27,10 @@ import { DollarOutlined, EditOutlined, EllipsisOutlined, + LeftOutlined, PlusOutlined, QuestionCircleOutlined, + RightOutlined, SearchOutlined, } from "@ant-design/icons"; import { theme } from "antd"; @@ -35,6 +38,7 @@ import { useAccountingData } from "../../Hooks/Accounting"; import moment from "moment"; import api from "../../API/api"; import { useTeamData } from "../../Hooks/Teams"; +import { useRoleData } from "../../Hooks/Role"; type Employee = { id: number; @@ -61,6 +65,28 @@ const AccountingCurrent: React.FC = () => { const currentInfo = new Date().toLocaleString("default", { month: "long" }); + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); + + const pageSizeOptions = [10, 20, 30, 40, 50]; + + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); + }; + + const Next = () => { + const a = Number(page) + 1; + setPage(a); + }; + const Previos = () => { + Number(page); + if (page > 1) { + const a = Number(page) - 1; + setPage(a); + } + }; + const { Option } = Select; // const currentMonth = moment().month(); @@ -97,6 +123,8 @@ const AccountingCurrent: React.FC = () => { const [search, setSearch] = useState(""); const [team, setTeam] = useState(""); + const [role, setRole] = useState(""); + const [salaryType, setSalaryType] = useState(""); const showBonusModal = (userId: any) => { setSelectedUserId(userId); // Tanlangan user_id ni saqlash @@ -117,6 +145,10 @@ const AccountingCurrent: React.FC = () => { month: "current", search: search, team: team, + page: page, + page_size: pageSize, + role: role, + salary_type: salaryType, }); const handleDateChange = (date: dayjs.Dayjs | null) => { @@ -308,52 +340,6 @@ const AccountingCurrent: React.FC = () => { form.resetFields(); }; - // const handleOkBonusEdit = async () => { - // try { - // const values = await form.validateFields(); - - // console.log(values); - - // if (!selectedRecordBonus) { - // throw new Error("No record selected!"); - // } - - // const updatedData = { - // ...(selectedRecordBonus || {}), - // ...values, - // }; - - // const response = await api.put( - // `bonus/${selectedRecordBonus.id}/`, - // updatedData, - // { - // headers: { - // "Content-Type": "application/json", - // }, - // } - // ); - - // if (response.status === 202) { - // setBonusesData((prevData: any) => - // prevData.map((item: any) => - // item.id === selectedRecordBonus.id - // ? { ...item, ...updatedData } - // : item - // ) - // ); - // refetch(); - - // setIsEditBonusModalVisible(false); - // } else { - // throw new Error("Server Error"); - // } - // } catch (error) { - // console.error(error); - // } - // }; - - // EDIT modal Charge - const handleOkBonusEdit = async () => { try { const values = await form.validateFields(); @@ -362,10 +348,9 @@ const AccountingCurrent: React.FC = () => { throw new Error("No record selected!"); } - // Faqat kerakli maydonlarni olish const updatedData = { amount: values.amount, - reason: values.reason, // Formda `notes` deb saqlanayotgan bo‘lsa + reason: values.reason, }; const response = await api.put( @@ -494,17 +479,24 @@ const AccountingCurrent: React.FC = () => { const teamData = useTeamData({}); const teamOptions: { label: string; value: any }[] | undefined = - teamData?.data?.map((item) => ({ + teamData?.data?.map((item: any) => ({ label: item?.name, value: item?.name, })); - const additionalOption = { - label: "all", - value: "", - }; - if (teamOptions) { - teamOptions.unshift(additionalOption); - } + + const roleData = useRoleData(); + + const roleOptions: { label: string; value: any }[] | undefined = + roleData?.data?.map((item: any) => ({ + label: item?.name, + value: item?.id, + })); + + const salaryTypeOptions = [ + { label: "Hybrid", value: "hybrid" }, + { label: "Task Based", value: "task_based" }, + { label: "Fixed", value: "fixed" }, + ]; const deleteFunctionBonus = (record: any) => { const { id } = record; @@ -555,10 +547,11 @@ const AccountingCurrent: React.FC = () => { style={{ display: "flex", alignItems: "center", + gap: 12, marginBottom: 10, }} > -
+
} @@ -570,12 +563,27 @@ const AccountingCurrent: React.FC = () => { placeholder="Team" onChange={(value: any) => setTeam(value)} options={teamOptions} + allowClear + /> + setSalaryType(value)} + options={salaryTypeOptions} + allowClear /> ({ + dataSource={data?.data?.map((u: any, i: any) => ({ no: i + 1, ...u, }))} @@ -608,24 +616,6 @@ const AccountingCurrent: React.FC = () => { title: "Role", dataIndex: "role", key: "role", - filters: [ - { - text: "Tech Support", - value: "Tech Support", - }, - { - text: "Checker", - value: "Checker", - }, - { - text: "Accountant", - value: "Accountant", - }, - ], - filterMultiple: false, - onFilter: (value: any, record: any) => { - return record.role === value; - }, }, { title: "Team", @@ -656,25 +646,6 @@ const AccountingCurrent: React.FC = () => { return

{record.salary_type}

; } }, - filters: [ - { - text: "Hybrid", - value: "hybrid", - }, - { - text: "Task Based", - value: "task_based", - }, - { - text: "Fixed", - value: "fixed", - }, - ], - filterMultiple: false, - // defaultFilteredValue: ["hybrid"], - onFilter: (value: any, record: any) => { - return record.salary_type === value; - }, }, { title: "Base Salary", @@ -745,23 +716,24 @@ const AccountingCurrent: React.FC = () => { index % 2 === 0 ? "odd-row" : "even-row" } bordered - pagination={{ - pageSize: 10, - size: "default", - style: { - margin: 0, - justifyContent: "end", - position: "fixed", - bottom: 0, - left: 0, - width: "100%", - backgroundColor: token.colorBgContainer, - boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", - padding: "10px 0", - zIndex: 1000, - }, - showLessItems: true, - }} + // pagination={{ + // pageSize: 10, + // size: "default", + // style: { + // margin: 0, + // justifyContent: "end", + // position: "fixed", + // bottom: 0, + // left: 0, + // width: "100%", + // backgroundColor: token.colorBgContainer, + // boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", + // padding: "10px 0", + // zIndex: 1000, + // }, + // showLessItems: true, + // }} + pagination={false} onRow={(record) => ({ onClick: (e) => handleRowClick(record, e), })} @@ -1209,6 +1181,73 @@ const AccountingCurrent: React.FC = () => { + + + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + ); }; diff --git a/src/Components/Accounting/AccountingHistory.tsx b/src/Components/Accounting/AccountingHistory.tsx index 0ce5eb6..273c190 100644 --- a/src/Components/Accounting/AccountingHistory.tsx +++ b/src/Components/Accounting/AccountingHistory.tsx @@ -3,6 +3,7 @@ import { Drawer, Input, Select, + Space, Spin, Table, Tooltip, @@ -13,13 +14,16 @@ import tagIcon from "../../assets/tagIcon.svg"; import { CloseOutlined, EyeOutlined, + LeftOutlined, QuestionCircleOutlined, + RightOutlined, SearchOutlined, } from "@ant-design/icons"; import { theme } from "antd"; import api from "../../API/api"; import { useAccountingHistory } from "../../Hooks/Accounting"; import { useTeamData } from "../../Hooks/Teams"; +import { useRoleData } from "../../Hooks/Role"; const { Title } = Typography; @@ -50,6 +54,8 @@ interface SalaryData { } const AccountingHistory: React.FC = () => { + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); const [open, setOpen] = useState(false); const [userData, setUserData] = useState(null); @@ -58,17 +64,42 @@ const AccountingHistory: React.FC = () => { const [search, setSearch] = useState(""); const [team, setTeam] = useState(""); + const [role, setRole] = useState(""); + const [salaryType, setSalaryType] = useState(""); const themes = localStorage.getItem("theme") === "true" ? true : false; const { data, refetch, isLoading } = useAccountingHistory({ search: search, team: team, + page: page, + page_size: pageSize, + role: role, + salary_type: salaryType, }); const [selectedUser, setSelectedUser] = useState(null); const [loading, setLoading] = useState(false); + const pageSizeOptions = [10, 20, 30, 40, 50]; + + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); + }; + + const Next = () => { + const a = Number(page) + 1; + setPage(a); + }; + const Previos = () => { + Number(page); + if (page > 1) { + const a = Number(page) - 1; + setPage(a); + } + }; + const handleRowClick = async (record: any, e: any) => { setSelectedUser(record); setOpen(true); @@ -116,17 +147,24 @@ const AccountingHistory: React.FC = () => { const teamData = useTeamData({}); const teamOptions: { label: string; value: any }[] | undefined = - teamData?.data?.map((item) => ({ + teamData?.data?.map((item: any) => ({ label: item?.name, value: item?.name, })); - const additionalOption = { - label: "all", - value: "", - }; - if (teamOptions) { - teamOptions.unshift(additionalOption); - } + + const roleData = useRoleData(); + + const roleOptions: { label: string; value: any }[] | undefined = + roleData?.data?.map((item: any) => ({ + label: item?.name, + value: item?.id, + })); + + const salaryTypeOptions = [ + { label: "Hybrid", value: "hybrid" }, + { label: "Task Based", value: "task_based" }, + { label: "Fixed", value: "fixed" }, + ]; return (
@@ -134,10 +172,11 @@ const AccountingHistory: React.FC = () => { style={{ display: "flex", alignItems: "center", + gap: 12, marginBottom: 10, }} > -
+
} @@ -149,12 +188,27 @@ const AccountingHistory: React.FC = () => { placeholder="Team" onChange={(value: any) => setTeam(value)} options={teamOptions} + allowClear + /> + setSalaryType(value)} + options={salaryTypeOptions} + allowClear />
({ + dataSource={data?.data?.map((u: any, i: any) => ({ no: i + 1, ...u, }))} @@ -187,24 +241,6 @@ const AccountingHistory: React.FC = () => { title: "Role", dataIndex: "role", key: "role", - filters: [ - { - text: "Tech Support", - value: "Tech Support", - }, - { - text: "Checker", - value: "Checker", - }, - { - text: "Accountant", - value: "Accountant", - }, - ], - filterMultiple: false, - onFilter: (value: any, record: any) => { - return record.role === value; - }, }, { title: "Team", @@ -261,25 +297,6 @@ const AccountingHistory: React.FC = () => { return

{record.salary_type}

; // Agar boshqa qiymat bo'lsa, oddiy qilib chiqariladi } }, - filters: [ - { - text: "Hybrid", - value: "hybrid", - }, - { - text: "Task Based", - value: "task_based", - }, - { - text: "Fixed", - value: "fixed", - }, - ], - filterMultiple: false, - // defaultFilteredValue: ["hybrid"], - onFilter: (value: any, record: any) => { - return record.salary_type === value; - }, }, { title: "Base Salary", @@ -330,23 +347,7 @@ const AccountingHistory: React.FC = () => { index % 2 === 0 ? "odd-row" : "even-row" } bordered - pagination={{ - pageSize: 10, - size: "default", - style: { - margin: 0, - justifyContent: "end", - position: "fixed", - bottom: 0, - left: 0, - width: "100%", - backgroundColor: token.colorBgContainer, - boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", - padding: "10px 0", - zIndex: 1000, - }, - showLessItems: true, - }} + pagination={false} // onRow={(record) => ({ // onClick: () => { // if (record.user && record.user.id) { @@ -544,6 +545,74 @@ const AccountingHistory: React.FC = () => { )} + + + + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + ); }; diff --git a/src/Components/Accounting/AccountingLast.tsx b/src/Components/Accounting/AccountingLast.tsx index c8068c1..8378b9b 100644 --- a/src/Components/Accounting/AccountingLast.tsx +++ b/src/Components/Accounting/AccountingLast.tsx @@ -9,6 +9,7 @@ import { message, Modal, Select, + Space, Table, Tooltip, Typography, @@ -24,8 +25,10 @@ import { EditOutlined, EllipsisOutlined, InfoCircleOutlined, + LeftOutlined, PlusOutlined, QuestionCircleOutlined, + RightOutlined, SearchOutlined, } from "@ant-design/icons"; import { theme } from "antd"; @@ -36,6 +39,7 @@ import dayjs from "dayjs"; import "dayjs/locale/en"; import localizedFormat from "dayjs/plugin/localizedFormat"; import { useTeamData } from "../../Hooks/Teams"; +import { useRoleData } from "../../Hooks/Role"; type Employee = { id: number; @@ -86,6 +90,28 @@ const AccountingCurrent: React.FC = () => { ); }; + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); + + const pageSizeOptions = [10, 20, 30, 40, 50]; + + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); + }; + + const Next = () => { + const a = Number(page) + 1; + setPage(a); + }; + const Previos = () => { + Number(page); + if (page > 1) { + const a = Number(page) - 1; + setPage(a); + } + }; + const [selectedUserId, setSelectedUserId] = useState(null); const [selectedDate, setSelectedDate] = useState(null); @@ -98,8 +124,12 @@ const AccountingCurrent: React.FC = () => { const [chargesData, setChargesData] = useState([]); const [search, setSearch] = useState(""); + const [team, setTeam] = useState(""); + const [role, setRole] = useState(""); + const [salaryType, setSalaryType] = useState(""); + const showBonusModal = (userId: any) => { setSelectedUserId(userId); // Tanlangan user_id ni saqlash setIsBonusModalVisible(true); @@ -119,6 +149,10 @@ const AccountingCurrent: React.FC = () => { month: "last", search: search, team: team, + page: page, + page_size: pageSize, + role: role, + salary_type: salaryType, }); const handleDateChange = (date: dayjs.Dayjs | null) => { @@ -502,17 +536,25 @@ const AccountingCurrent: React.FC = () => { const teamData = useTeamData({}); const teamOptions: { label: string; value: any }[] | undefined = - teamData?.data?.map((item) => ({ + teamData?.data?.map((item: any) => ({ label: item?.name, value: item?.name, })); - const additionalOption = { - label: "all", - value: "", - }; - if (teamOptions) { - teamOptions.unshift(additionalOption); - } + + const roleData = useRoleData(); + + const roleOptions: { label: string; value: any }[] | undefined = + roleData?.data?.map((item: any) => ({ + label: item?.name, + value: item?.id, + })); + + const salaryTypeOptions = [ + { label: "Hybrid", value: "hybrid" }, + { label: "Task Based", value: "task_based" }, + { label: "Fixed", value: "fixed" }, + ]; + const { token } = theme.useToken(); const deleteFunctionBonus = (record: any) => { @@ -573,10 +615,11 @@ const AccountingCurrent: React.FC = () => { style={{ display: "flex", alignItems: "center", + gap: 12, // marginBottom: 10, }} > -
+
} @@ -589,11 +632,25 @@ const AccountingCurrent: React.FC = () => { onChange={(value: any) => setTeam(value)} options={teamOptions} /> + setSalaryType(value)} + options={salaryTypeOptions} + allowClear + />
({ + dataSource={data?.data?.map((u: any, i: any) => ({ no: i + 1, ...u, }))} @@ -722,24 +779,6 @@ const AccountingCurrent: React.FC = () => { title: "Role", dataIndex: "role", key: "role", - filters: [ - { - text: "Tech Support", - value: "Tech Support", - }, - { - text: "Checker", - value: "Checker", - }, - { - text: "Accountant", - value: "Accountant", - }, - ], - filterMultiple: false, - onFilter: (value: any, record: any) => { - return record.role === value; - }, }, { title: "Team", @@ -770,25 +809,6 @@ const AccountingCurrent: React.FC = () => { return

{record.salary_type}

; } }, - filters: [ - { - text: "Hybrid", - value: "hybrid", - }, - { - text: "Task Based", - value: "task_based", - }, - { - text: "Fixed", - value: "fixed", - }, - ], - filterMultiple: false, - // defaultFilteredValue: ["hybrid"], - onFilter: (value: any, record: any) => { - return record.salary_type === value; - }, }, { title: "Base Salary", @@ -841,7 +861,7 @@ const AccountingCurrent: React.FC = () => { item.is_confirmed)} + disabled={data?.data?.some((item: any) => item.is_confirmed)} > + + ); }; diff --git a/src/Components/Accounting/ConfirmedMonths.tsx b/src/Components/Accounting/ConfirmedMonths.tsx index 874411a..cc9aca6 100644 --- a/src/Components/Accounting/ConfirmedMonths.tsx +++ b/src/Components/Accounting/ConfirmedMonths.tsx @@ -1,10 +1,37 @@ import { useConfirmedMonths } from "../../Hooks/Accounting"; -import { Button, Table, theme } from "antd"; +import { Button, Input, Select, Space, Table, theme } from "antd"; import tagIcon from "../../assets/tagIcon.svg"; import dayjs from "dayjs"; +import { useState } from "react"; +import { LeftOutlined, RightOutlined } from "@ant-design/icons"; function ConfirmedMonths() { - const { data, isLoading, refetch } = useConfirmedMonths(); + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); + + const pageSizeOptions = [10, 20, 30, 40, 50]; + + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); + }; + + const Next = () => { + const a = Number(page) + 1; + setPage(a); + }; + const Previos = () => { + Number(page); + if (page > 1) { + const a = Number(page) - 1; + setPage(a); + } + }; + + const { data, isLoading, refetch } = useConfirmedMonths({ + page: page, + page_size: pageSize, + }); const { token } = theme.useToken(); @@ -13,7 +40,7 @@ function ConfirmedMonths() {
({ + dataSource={data?.data?.map((u: any, i: any) => ({ no: i + 1, ...u, }))} @@ -62,11 +89,11 @@ function ConfirmedMonths() { ]} loading={isLoading} rowKey="id" - pagination={{ - pageSize: 10, - size: "default", - style: { - margin: 0, + pagination={false} + /> + + + }} + wrap + > + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + ); } diff --git a/src/Components/CallRequests/Call.tsx b/src/Components/CallRequests/Call.tsx index 683a58f..9817c68 100644 --- a/src/Components/CallRequests/Call.tsx +++ b/src/Components/CallRequests/Call.tsx @@ -6,6 +6,7 @@ import { Input, Radio, RadioChangeEvent, + Select, Space, Typography, } from "antd"; @@ -17,13 +18,22 @@ import { theme } from "antd"; const Call = ({ socketData }: { socketData: TSocket | undefined }) => { const [status, setStatus] = useState("Awaiting"); const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); + const [tableData, setTableData] = useState(); const { data, isLoading, refetch } = useCallData({ status: status, page: page, - page_size: 10, + page_size: pageSize, }); + const pageSizeOptions = [10, 20, 30, 40, 50]; + + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); + }; + // const theme = localStorage.getItem("theme") === "true" ? true : false; const { token } = theme.useToken(); @@ -116,6 +126,16 @@ const Call = ({ socketData }: { socketData: TSocket | undefined }) => { }} wrap > + ({ + label: `${size}`, + value: size, + }))} + /> + )} - + - {/* + { }} wrap > - + { let num = e.target.value; @@ -76,18 +121,19 @@ const Service = () => { } }} /> - - - - */} + ); }; diff --git a/src/Components/Statistics/Statistic.tsx b/src/Components/Statistics/Statistic.tsx index e88f80d..e6df3d2 100644 --- a/src/Components/Statistics/Statistic.tsx +++ b/src/Components/Statistics/Statistic.tsx @@ -28,10 +28,12 @@ import { DatePickerProps, Input, Select, + Space, Tabs, Typography, + theme, } from "antd"; -import { SearchOutlined } from "@ant-design/icons"; +import { LeftOutlined, RightOutlined, SearchOutlined } from "@ant-design/icons"; import TabPane from "antd/es/tabs/TabPane"; import api from "../../API/api"; // @ts-ignore @@ -58,7 +60,6 @@ import teamsIconActive from "../../assets/teamsIconActive.svg"; import techSupports from "../../assets/techsupportIcon.svg"; import techSupportsActive from "../../assets/techsupportIconActive.svg"; -import axios from "axios"; import StatisticsSupportTable from "./StatisticsSupportTable"; const Stat = () => { @@ -73,17 +74,40 @@ const Stat = () => { .endOf("month") .format("YYYY-MM-DD")} 23:59:59`; + const { token } = theme.useToken(); + const [search, setSearch] = useState(""); const [SupportSearch, setSupportSearch] = useState(""); const [team, setTeam] = useState(""); const [startDate, setStartDate] = useState(start_date); const [endDate, setEndDate] = useState(end_date); + const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); const [forSalary, setForSalary] = useState(true); + const pageSizeOptions = [10, 20, 30, 40, 50]; + + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); + }; + + const Next = () => { + const a = Number(page) + 1; + setPage(a); + }; + const Previos = () => { + Number(page); + if (page > 1) { + const a = Number(page) - 1; + setPage(a); + } + }; + const teamData = useTeamData({}); const teamOptions: { label: string; value: any }[] | undefined = - teamData?.data?.map((item) => ({ + teamData?.data?.map((item: any) => ({ label: item?.name, value: item?.name, })); @@ -145,29 +169,21 @@ const Stat = () => { start_date: startDate, end_date: endDate, for_salary: forSalary, + page: page, + page_size: pageSize, }); - interface DataType { - data?: TStatTeam[]; - refetch: ( - options?: (RefetchOptions & RefetchQueryFilters) | undefined - ) => Promise>; - isLoading: boolean; - } - const TeamData: DataType = useStatTeamData({ + + const TeamData = useStatTeamData({ + page: page, + page_size: pageSize, search: "", start_date: startDate, end_date: endDate, }); - interface TaskCreatorsType { - data?: TStatCreators[]; - refetch: ( - options?: (RefetchOptions & RefetchQueryFilters) | undefined - ) => Promise>; - isLoading: boolean; - } - - const CreatorsData: TaskCreatorsType = useCreatorsData({ + const CreatorsData = useCreatorsData({ + page: page, + page_size: pageSize, search: SupportSearch, start_date: startDate, end_date: endDate, @@ -220,7 +236,7 @@ const Stat = () => { }, 1000); }; - const theme = localStorage.getItem("theme") === "true" ? true : false; + // const theme = localStorage.getItem("theme") === "true" ? true : false; const [activeTab, setActiveTab] = useState("1"); @@ -498,6 +514,73 @@ const Stat = () => { isLoading={CreatorsData?.isLoading} refetch={CreatorsData?.refetch} /> + + + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + { /> @@ -555,6 +638,74 @@ const Stat = () => { > Save as file + + + + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + { key="4" > @@ -631,6 +782,73 @@ const Stat = () => { + + + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + diff --git a/src/Components/Statistics/StatisticTable.tsx b/src/Components/Statistics/StatisticTable.tsx index 1b6076b..7b04a07 100644 --- a/src/Components/Statistics/StatisticTable.tsx +++ b/src/Components/Statistics/StatisticTable.tsx @@ -19,7 +19,7 @@ const StatTable = ({ refetch: ( options?: (RefetchOptions & RefetchQueryFilters) | undefined ) => Promise>; - data: { data: TStat[] | undefined }; + data: any; isLoading: boolean; }) => { const { token } = theme.useToken(); @@ -29,7 +29,7 @@ const StatTable = ({
({ + dataSource={data?.map((u: any, i: any) => ({ no: i + 1, ...u, }))} @@ -104,23 +104,24 @@ const StatTable = ({ // sortDirections: ["ascend", "descend"], // }, ]} - pagination={{ - pageSize: 10, - size: "default", - style: { - margin: 0, - justifyContent: "end", - position: "fixed", - bottom: 0, - left: 0, - width: "100%", - backgroundColor: token.colorBgContainer, - boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", - padding: "10px 0", - zIndex: 1000, - }, - showLessItems: true, - }} + // pagination={{ + // pageSize: 10, + // size: "default", + // style: { + // margin: 0, + // justifyContent: "end", + // position: "fixed", + // bottom: 0, + // left: 0, + // width: "100%", + // backgroundColor: token.colorBgContainer, + // boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", + // padding: "10px 0", + // zIndex: 1000, + // }, + // showLessItems: true, + // }} + pagination={false} rowClassName={(record, index) => index % 2 === 0 ? "odd-row" : "even-row" } diff --git a/src/Components/Statistics/StatisticTeamTable.tsx b/src/Components/Statistics/StatisticTeamTable.tsx index 73b34bb..9917d6d 100644 --- a/src/Components/Statistics/StatisticTeamTable.tsx +++ b/src/Components/Statistics/StatisticTeamTable.tsx @@ -17,7 +17,7 @@ const StatTeamTable = ({ refetch: ( options?: (RefetchOptions & RefetchQueryFilters) | undefined ) => Promise>; - data: TStatTeam[] | undefined; + data: any; isLoading: boolean; }) => { const { token } = theme.useToken(); @@ -26,7 +26,7 @@ const StatTeamTable = ({
({ + dataSource={data?.map((u: any, i: any) => ({ no: i + 1, ...u, }))} @@ -70,22 +70,23 @@ const StatTeamTable = ({ }, }, ]} - pagination={{ - pageSize: 10, - size: "default", - style: { - margin: 0, - justifyContent: "end", - position: "fixed", - bottom: 0, - left: 0, - width: "100%", - backgroundColor: token.colorBgContainer, - boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", - padding: "10px 0", - zIndex: 1000, - }, - }} + // pagination={{ + // pageSize: 10, + // size: "default", + // style: { + // margin: 0, + // justifyContent: "end", + // position: "fixed", + // bottom: 0, + // left: 0, + // width: "100%", + // backgroundColor: token.colorBgContainer, + // boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", + // padding: "10px 0", + // zIndex: 1000, + // }, + // }} + pagination={false} rowClassName={(record, index) => index % 2 === 0 ? "odd-row" : "even-row" } diff --git a/src/Components/Statistics/StatisticsSupportTable.tsx b/src/Components/Statistics/StatisticsSupportTable.tsx index 02dba2e..20213ca 100644 --- a/src/Components/Statistics/StatisticsSupportTable.tsx +++ b/src/Components/Statistics/StatisticsSupportTable.tsx @@ -17,7 +17,7 @@ const StatisticsSupportTable = ({ refetch: ( options?: (RefetchOptions & RefetchQueryFilters) | undefined ) => Promise>; - data: TStatCreators[] | undefined; + data: any; isLoading: boolean; }) => { const { token } = theme.useToken(); @@ -26,7 +26,7 @@ const StatisticsSupportTable = ({
({ + dataSource={data?.data?.map((u: any, i: any) => ({ no: i + 1, ...u, }))} @@ -51,23 +51,24 @@ const StatisticsSupportTable = ({ dataIndex: "number_of_tasks", }, ]} - pagination={{ - pageSize: 10, - size: "default", - style: { - margin: 0, - justifyContent: "end", - position: "fixed", - bottom: 0, - left: 0, - width: "100%", - backgroundColor: token.colorBgContainer, - boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", - padding: "10px 0", - zIndex: 1000, - }, - showLessItems: true, - }} + // pagination={{ + // pageSize: 10, + // size: "default", + // style: { + // margin: 0, + // justifyContent: "end", + // position: "fixed", + // bottom: 0, + // left: 0, + // width: "100%", + // backgroundColor: token.colorBgContainer, + // boxShadow: "0 4px 8px rgba(0, 0, 0, 0.4)", + // padding: "10px 0", + // zIndex: 1000, + // }, + // showLessItems: true, + // }} + pagination={false} rowClassName={(record, index) => index % 2 === 0 ? "odd-row" : "even-row" } diff --git a/src/Components/Tasks/AddTask.tsx b/src/Components/Tasks/AddTask.tsx index 36dc76c..fe06c6b 100644 --- a/src/Components/Tasks/AddTask.tsx +++ b/src/Components/Tasks/AddTask.tsx @@ -105,7 +105,7 @@ const AddTask = ({ }, [companyId, customerName]); // service select - const serviceOptions = ServiceData?.data?.map((item) => ({ + const serviceOptions = ServiceData?.data?.map((item: any) => ({ label: item?.title, value: item?.id, })); @@ -332,7 +332,7 @@ const AddTask = ({ > ({ + label: `${size}`, + value: size, + }))} + /> - + + + + { + let num = e.target.value; + if (Number(num) && num !== "0") { + setPage(Number(num)); + } + }} + /> + + + ); }; diff --git a/src/Components/Updates/Update.tsx b/src/Components/Updates/Update.tsx index 402ae93..81c12cb 100644 --- a/src/Components/Updates/Update.tsx +++ b/src/Components/Updates/Update.tsx @@ -35,10 +35,16 @@ const Update = () => { const { Option } = Select; const [page, setPage] = useState(1); + const [pageSize, setPageSize] = useState(10); - const page_size: number = 10; + const pageSizeOptions = [10, 20, 30, 40, 50]; - const { data, refetch, isLoading } = useUpdateData(status, page, page_size); + const handlePageSizeChange = (value: number) => { + setPageSize(value); + setPage(1); // Odatda pageSize o'zgarganda sahifani 1 ga qaytaramiz + }; + + const { data, refetch, isLoading } = useUpdateData(status, page, pageSize); const showModal = () => { setOpen(true); @@ -141,6 +147,15 @@ const Update = () => { }} wrap > + ({ + label: `${size}`, + value: size, + }))} + /> +