diff --git a/src/API/LayoutApi/accounting.ts b/src/API/LayoutApi/accounting.ts index 82cc57c..8be40b5 100644 --- a/src/API/LayoutApi/accounting.ts +++ b/src/API/LayoutApi/accounting.ts @@ -1,3 +1,4 @@ +import { TAccountingConfirmedMonths } from "./../../types/Accounting/TAccounting"; import { TAccounting, TAccountingHistory, @@ -25,6 +26,14 @@ export const AccountingController = { }); return data; }, + + async confirmedMonths() { + const { data } = await instance.get( + `/salaries-group/` + ); + return data; + }, + async history(filterObject: TAccountingHistoryGetParams) { const params = { ...filterObject }; if (!!filterObject.search) params.search = filterObject.search; diff --git a/src/API/api.ts b/src/API/api.ts index 104c181..67ba70d 100644 --- a/src/API/api.ts +++ b/src/API/api.ts @@ -4,6 +4,7 @@ import axios from "axios"; // baseURL: "http://10.10.10.64:8080/api/v1/", // }); const instance = axios.create({ + // baseURL: "https://board-api.ontime-logs.com/api/v1/", baseURL: "https://api.tteld.co/api/v1/", // baseURL: "http://10.10.10.64:8000/api/v1/", }); diff --git a/src/App.tsx b/src/App.tsx index a68437e..38873b2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -286,6 +286,7 @@ const App: React.FC = () => { // ); // taskSocket = new WebSocket(`wss://api.tteld.co/global/?user_id=${admin_id}`); taskSocket = new WebSocket( + // `wss://board-socket.ontime-logs.com/global/?user_id=${admin_id}` `wss://ontime-socket.tteld.co/global/?user_id=${admin_id}` // `ws://10.10.10.64:8000/global/?user_id=${admin_id}` ); diff --git a/src/Components/Accounting/Accounting.tsx b/src/Components/Accounting/Accounting.tsx index 9582870..014f35f 100644 --- a/src/Components/Accounting/Accounting.tsx +++ b/src/Components/Accounting/Accounting.tsx @@ -1,5 +1,9 @@ import { Button, DatePicker, Tabs, Typography } from "antd"; -import { ReloadOutlined } from "@ant-design/icons"; +import { + CheckCircleOutlined, + CheckSquareOutlined, + ReloadOutlined, +} from "@ant-design/icons"; import { theme } from "antd"; import currentMonthActive from "../../assets/currentMonthActive.svg"; @@ -19,13 +23,14 @@ import AccountingLast from "./AccountingLast"; import AccountingHistory from "./AccountingHistory"; import dayjs from "dayjs"; import { useAccountingData } from "../../Hooks/Accounting"; +import ConfirmedMonths from "./ConfirmedMonths"; const Accounting: React.FC = () => { const { token } = theme.useToken(); const [activeTab, setActiveTab] = useState("1"); - const month = activeTab === "1" ? "current" : "last"; + const month = activeTab === "" ? "current" : "last"; const { data, isLoading, refetch } = useAccountingData({ month: month, @@ -140,18 +145,35 @@ const Accounting: React.FC = () => { > + + + Confirmed Months + + } + key="3" + > + + icon History } - key="3" + key="4" > diff --git a/src/Components/Accounting/AccountingDetails.tsx b/src/Components/Accounting/AccountingDetails.tsx index dae9733..ce24c2c 100644 --- a/src/Components/Accounting/AccountingDetails.tsx +++ b/src/Components/Accounting/AccountingDetails.tsx @@ -58,7 +58,7 @@ const AccountingDetails = () => { useEffect(() => { const fetchUserDetails = async () => { - const API_URL = `https://api.tteld.co/api/v1/user-salaries/${id}`; + const API_URL = `https://board-api.ontime-logs.com/api/v1/user-salaries/${id}`; const AUTH_TOKEN = localStorage.getItem("access"); try { diff --git a/src/Components/Accounting/AccountingHistory.tsx b/src/Components/Accounting/AccountingHistory.tsx index 9791178..4fc6dfb 100644 --- a/src/Components/Accounting/AccountingHistory.tsx +++ b/src/Components/Accounting/AccountingHistory.tsx @@ -527,10 +527,7 @@ const AccountingHistory: React.FC = () => { icon={} onClick={() => record.salary_document_path && - window.open( - record.salary_document_path, - "_blank" - ) + window.open(record.salary_document_path) } disabled={!record.salary_document_path} /> diff --git a/src/Components/Accounting/ConfirmedMonths.tsx b/src/Components/Accounting/ConfirmedMonths.tsx new file mode 100644 index 0000000..874411a --- /dev/null +++ b/src/Components/Accounting/ConfirmedMonths.tsx @@ -0,0 +1,87 @@ +import { useConfirmedMonths } from "../../Hooks/Accounting"; +import { Button, Table, theme } from "antd"; +import tagIcon from "../../assets/tagIcon.svg"; +import dayjs from "dayjs"; + +function ConfirmedMonths() { + const { data, isLoading, refetch } = useConfirmedMonths(); + + const { token } = theme.useToken(); + + return ( +
+ ({ + no: i + 1, + ...u, + }))} + columns={[ + { + title: , + dataIndex: "no", + key: "no", + width: "5%", + align: "center", + }, + { + title: "Year", + dataIndex: "year", + key: "year", + width: "20%", + }, + { + title: "Month", + dataIndex: "month", + key: "month", + width: "20%", + }, + { + title: "Confirmed", + dataIndex: "created_at", + key: "created_at", + width: "30%", + render: (text: string) => dayjs(text).format("YYYY-MM-DD HH:mm"), + }, + { + title: "Action", + key: "action", + align: "center", + width: "10%", + render: (_: any, record: any) => ( + + ), + }, + ]} + loading={isLoading} + rowKey="id" + 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, + }} + /> + + ); +} + +export default ConfirmedMonths; diff --git a/src/Components/Statistics/Statistic.tsx b/src/Components/Statistics/Statistic.tsx index f369cec..e88f80d 100644 --- a/src/Components/Statistics/Statistic.tsx +++ b/src/Components/Statistics/Statistic.tsx @@ -33,6 +33,7 @@ import { } from "antd"; import { SearchOutlined } from "@ant-design/icons"; import TabPane from "antd/es/tabs/TabPane"; +import api from "../../API/api"; // @ts-ignore import IconSearch from "../../assets/searchIcon.png"; import { @@ -274,7 +275,6 @@ const Stat = () => { null ); - const token = localStorage.getItem("access"); const [loading, setLoading] = useState(true); useEffect(() => { @@ -289,13 +289,9 @@ const Stat = () => { } 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}` }, - } - ); + const response = await api.get("stats/general-stats", { + params: { start_date: startDate, end_date: formattedEndDate }, + }); if (response.data.daily_stats) { setChartData(response.data.daily_stats); } @@ -310,7 +306,7 @@ const Stat = () => { }; fetchData(); - }, [token, startDate, endDate]); + }, [startDate, endDate]); const formatDate = (dateString: string): string => { const date = new Date(dateString); diff --git a/src/Components/Updates/UpdateEdit.tsx b/src/Components/Updates/UpdateEdit.tsx index c581a29..1e1c1f6 100644 --- a/src/Components/Updates/UpdateEdit.tsx +++ b/src/Components/Updates/UpdateEdit.tsx @@ -219,7 +219,7 @@ const UpdateEdit = () => { )} - {customerId !== null && ( + {/* {customerId !== null && ( { > {data?.customer.id !== undefined && ( )} + )} */} + {customerId !== null && ( + + + + + )} diff --git a/src/Hooks/Accounting/index.ts b/src/Hooks/Accounting/index.ts index c96edf5..2c08500 100644 --- a/src/Hooks/Accounting/index.ts +++ b/src/Hooks/Accounting/index.ts @@ -34,3 +34,13 @@ export const useAccountingHistory = ({ } ); }; + +export const useConfirmedMonths = () => { + return useQuery( + [`/salaries-group`], + () => AccountingController.confirmedMonths(), + { + refetchOnWindowFocus: false, + } + ); +}; diff --git a/src/types/Accounting/TAccounting.ts b/src/types/Accounting/TAccounting.ts index b706697..e11c59c 100644 --- a/src/types/Accounting/TAccounting.ts +++ b/src/types/Accounting/TAccounting.ts @@ -13,6 +13,14 @@ export type TAccounting = { username: string; }; +export type TAccountingConfirmedMonths = { + id: number; + month: string; + year: number; + salary_document_path: string; + created_at: string; +}; + export type TAccountingHistory = { id: number; full_name: string;