diff --git a/src/Components/Profile/Profile.tsx b/src/Components/Profile/Profile.tsx index d1b93be..8e224d4 100644 --- a/src/Components/Profile/Profile.tsx +++ b/src/Components/Profile/Profile.tsx @@ -89,8 +89,7 @@ const Profile = () => { tasks: stat.number_of_tasks, })); - const firstDayOfMonth = dayjs().startOf("month"); // Oyning birinchi kuni - // const lastDayOfMonth = dayjs().endOf("month"); + const firstDayOfMonth = dayjs().startOf("month"); const today = dayjs(); const dateFormat = "YYYY-MM-DD"; diff --git a/src/Components/Statistics/Statistic.tsx b/src/Components/Statistics/Statistic.tsx index b7ef8c4..3c1d586 100644 --- a/src/Components/Statistics/Statistic.tsx +++ b/src/Components/Statistics/Statistic.tsx @@ -1,4 +1,4 @@ -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { QueryObserverResult, RefetchOptions, @@ -23,6 +23,8 @@ import TabPane from "antd/es/tabs/TabPane"; // @ts-ignore import IconSearch from "../../assets/searchIcon.png"; import { + Bar, + BarChart, CartesianGrid, Legend, Line, @@ -33,6 +35,15 @@ import { YAxis, } from "recharts"; +import generalActive from "../../assets/generalActive.svg"; +import general from "../../assets/general.svg"; +import checkersIcon from "../../assets/checkerIcon.svg"; +import chekersIconActive from "../../assets/checkersIconActive.svg"; +import teamsIcon from "../../assets/teamsIcon.svg"; +import teamsIconActive from "../../assets/teamsIconActive.svg"; + +import axios from "axios"; + const Stat = () => { const now = dayjs(); const { RangePicker } = DatePicker; @@ -40,7 +51,10 @@ const Stat = () => { const currentDate = moment(); const nextMonth = currentDate.clone().add(1, "months"); const start_date = `${currentDate.format("YYYY-MM")}-01 00:00:00`; - const end_date = `${nextMonth.format("YYYY-MM")}-01 00:00:00`; + const end_date = `${currentDate + .clone() + .endOf("month") + .format("YYYY-MM-DD")} 23:59:59`; const [search, setSearch] = useState(""); const [team, setTeam] = useState(""); @@ -87,8 +101,8 @@ const Stat = () => { setStartDate(""); setEndDate(""); } else { - const firstDate = date; - const secondDate = date?.add(1, "month"); + const firstDate = date.startOf("month"); + const secondDate = date?.add(1, "month").startOf("month"); // const yearStart = Number(firstDate?.year()); // const monthStart = Number(firstDate?.month()) + 1; // const yearEnd = Number(secondDate?.year()); @@ -97,8 +111,10 @@ const Stat = () => { // setStartDate(`${yearStart}-${monthStart}-01 00:00:00`); // setEndDate(`${yearEnd}-${monthEnd}-01 00:00:00`); - const formattedStartDate = firstDate.format("YYYY-MM-DD"); - const formattedEndDate = secondDate.format("YYYY-MM-DD"); + const formattedStartDate = firstDate.format("YYYY-MM-01 00:00:00"); + const formattedEndDate = secondDate + .subtract(1, "day") + .format("YYYY-MM-DD 23:59:59"); setStartDate(formattedStartDate); setEndDate(formattedEndDate); setForSalary(true); @@ -138,6 +154,8 @@ const Stat = () => { }; const theme = localStorage.getItem("theme") === "true" ? true : false; + const [activeTab, setActiveTab] = useState("1"); + const disabledDate = (current: any) => { return current && current >= moment().add(1, "month").startOf("month"); }; @@ -218,6 +236,59 @@ const Stat = () => { // lines massivini yangilash // const lines = updateLines(chartData, predefinedColors); + const [chartData, setChartData] = useState([]); + const [summaryData, setSummaryData] = useState | null>( + null + ); + + const token = localStorage.getItem("access"); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchData = async () => { + try { + const today = dayjs().endOf("day"); + + let finalEndDate = dayjs(endDate); + + if (finalEndDate.isAfter(today)) { + finalEndDate = today; + } + const formattedEndDate = finalEndDate.format("YYYY-MM-DD HH:mm:ss"); + + const response = await axios.get( + "https://api.tteld.co/api/v1/stats/general-stats", + { + params: { start_date: startDate, end_date: formattedEndDate }, + headers: { Authorization: `Bearer ${token}` }, + } + ); + if (response.data.daily_stats) { + setChartData(response.data.daily_stats); + } + if (response.data.summary) { + setSummaryData(response.data.summary); + } + setLoading(false); + } catch (error) { + console.error("Error fetching daily stats:", error); + setLoading(false); + } + }; + + fetchData(); + }, [token, startDate, endDate]); + + if (loading) return

Loading...

; + + const formatDate = (dateString: string): string => { + const date = new Date(dateString); + return new Intl.DateTimeFormat("en-EN", { + day: "2-digit", + month: "short", + }).format(date); + }; + return (
{
- - Users} key="1"> + setActiveTab(key)} + > + + icon + General + + } + key="1" + > +
+
+ {summaryData && ( +
+

Total

+ {summaryData.total} +

Tasks

+
+ )} + {summaryData && ( +
+

Active

+ {summaryData.total_completed} +

Tasks

+
+ )} + {summaryData && ( +
+

Inactive

+ {summaryData.total_incomplete} +

Tasks

+
+ )} +
+ + + + + + + + + + + + +
+
+ + icon + Checkers + + } + key="2" + > { Save as file - Teams} key="2"> + + icon + Teams + + } + key="3" + > - diff --git a/src/Components/Statistics/StatisticTable.tsx b/src/Components/Statistics/StatisticTable.tsx index cb98736..b3f6059 100644 --- a/src/Components/Statistics/StatisticTable.tsx +++ b/src/Components/Statistics/StatisticTable.tsx @@ -77,7 +77,7 @@ const StatTable = ({
{record.salary_type === "hybrid" ? (

- Base Amount: $ + Fixed Amount: $ {record.salary_base_amount}

) : ( @@ -89,6 +89,9 @@ const StatTable = ({

} + overlayStyle={{ + maxWidth: "700px", + }} > ${record.salary} diff --git a/src/Components/Users/UserEdit.tsx b/src/Components/Users/UserEdit.tsx index 7926145..9b057bd 100644 --- a/src/Components/Users/UserEdit.tsx +++ b/src/Components/Users/UserEdit.tsx @@ -92,6 +92,8 @@ const UserEdit = () => { } }; + const [form] = Form.useForm(); + useEffect(() => { if (data?.role.name === "Checker" && data?.salary_type === "hybrid") { setShowInput(true); @@ -136,6 +138,7 @@ const UserEdit = () => { style={{ display: "flex" }} >
{ )} - {data?.role?.name === "Checker" && ( - - - - - - )} - + + + + )} {showInput && ( } /> diff --git a/src/assets/checkerIcon.svg b/src/assets/checkerIcon.svg new file mode 100644 index 0000000..07fd755 --- /dev/null +++ b/src/assets/checkerIcon.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/checkersIconActive.svg b/src/assets/checkersIconActive.svg new file mode 100644 index 0000000..2c8ad23 --- /dev/null +++ b/src/assets/checkersIconActive.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/general.svg b/src/assets/general.svg new file mode 100644 index 0000000..19dce2f --- /dev/null +++ b/src/assets/general.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/generalActive.svg b/src/assets/generalActive.svg new file mode 100644 index 0000000..07fadc2 --- /dev/null +++ b/src/assets/generalActive.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/assets/teamsIcon.svg b/src/assets/teamsIcon.svg new file mode 100644 index 0000000..a3d8de7 --- /dev/null +++ b/src/assets/teamsIcon.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/assets/teamsIconActive.svg b/src/assets/teamsIconActive.svg new file mode 100644 index 0000000..e9c8a2b --- /dev/null +++ b/src/assets/teamsIconActive.svg @@ -0,0 +1,3 @@ + + +