confirmed months tab added to salary page

dilmurod
Dilmurod 2 weeks ago
parent c06c96e5c9
commit df1cac3298

@ -1,3 +1,4 @@
import { TAccountingConfirmedMonths } from "./../../types/Accounting/TAccounting";
import { import {
TAccounting, TAccounting,
TAccountingHistory, TAccountingHistory,
@ -25,6 +26,14 @@ export const AccountingController = {
}); });
return data; return data;
}, },
async confirmedMonths() {
const { data } = await instance.get<TAccountingConfirmedMonths[]>(
`/salaries-group/`
);
return data;
},
async history(filterObject: TAccountingHistoryGetParams) { async history(filterObject: TAccountingHistoryGetParams) {
const params = { ...filterObject }; const params = { ...filterObject };
if (!!filterObject.search) params.search = filterObject.search; if (!!filterObject.search) params.search = filterObject.search;

@ -4,6 +4,7 @@ import axios from "axios";
// baseURL: "http://10.10.10.64:8080/api/v1/", // baseURL: "http://10.10.10.64:8080/api/v1/",
// }); // });
const instance = axios.create({ const instance = axios.create({
// baseURL: "https://board-api.ontime-logs.com/api/v1/",
baseURL: "https://api.tteld.co/api/v1/", baseURL: "https://api.tteld.co/api/v1/",
// baseURL: "http://10.10.10.64:8000/api/v1/", // baseURL: "http://10.10.10.64:8000/api/v1/",
}); });

@ -286,6 +286,7 @@ const App: React.FC = () => {
// ); // );
// taskSocket = new WebSocket(`wss://api.tteld.co/global/?user_id=${admin_id}`); // taskSocket = new WebSocket(`wss://api.tteld.co/global/?user_id=${admin_id}`);
taskSocket = new WebSocket( taskSocket = new WebSocket(
// `wss://board-socket.ontime-logs.com/global/?user_id=${admin_id}`
`wss://ontime-socket.tteld.co/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}` // `ws://10.10.10.64:8000/global/?user_id=${admin_id}`
); );

@ -1,5 +1,9 @@
import { Button, DatePicker, Tabs, Typography } from "antd"; 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 { theme } from "antd";
import currentMonthActive from "../../assets/currentMonthActive.svg"; import currentMonthActive from "../../assets/currentMonthActive.svg";
@ -19,13 +23,14 @@ import AccountingLast from "./AccountingLast";
import AccountingHistory from "./AccountingHistory"; import AccountingHistory from "./AccountingHistory";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { useAccountingData } from "../../Hooks/Accounting"; import { useAccountingData } from "../../Hooks/Accounting";
import ConfirmedMonths from "./ConfirmedMonths";
const Accounting: React.FC = () => { const Accounting: React.FC = () => {
const { token } = theme.useToken(); const { token } = theme.useToken();
const [activeTab, setActiveTab] = useState("1"); const [activeTab, setActiveTab] = useState("1");
const month = activeTab === "1" ? "current" : "last"; const month = activeTab === "" ? "current" : "last";
const { data, isLoading, refetch } = useAccountingData({ const { data, isLoading, refetch } = useAccountingData({
month: month, month: month,
@ -140,18 +145,35 @@ const Accounting: React.FC = () => {
> >
<AccountingLast /> <AccountingLast />
</TabPane> </TabPane>
<TabPane
tab={
<span style={{ display: "flex", alignItems: "center" }}>
<CheckCircleOutlined
style={{
fontSize: 16,
marginRight: 5,
color: activeTab === "3" ? "#F99E2C" : "#A1A2AB",
}}
/>
Confirmed Months
</span>
}
key="3"
>
<ConfirmedMonths />
</TabPane>
<TabPane <TabPane
tab={ tab={
<span style={{ display: "flex", alignItems: "center" }}> <span style={{ display: "flex", alignItems: "center" }}>
<img <img
style={{ marginRight: 5 }} style={{ marginRight: 5 }}
src={activeTab === "3" ? historyActive : history} src={activeTab === "4" ? historyActive : history}
alt="icon" alt="icon"
/> />
History History
</span> </span>
} }
key="3" key="4"
> >
<AccountingHistory /> <AccountingHistory />
</TabPane> </TabPane>

@ -58,7 +58,7 @@ const AccountingDetails = () => {
useEffect(() => { useEffect(() => {
const fetchUserDetails = async () => { 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"); const AUTH_TOKEN = localStorage.getItem("access");
try { try {

@ -527,10 +527,7 @@ const AccountingHistory: React.FC = () => {
icon={<EyeOutlined />} icon={<EyeOutlined />}
onClick={() => onClick={() =>
record.salary_document_path && record.salary_document_path &&
window.open( window.open(record.salary_document_path)
record.salary_document_path,
"_blank"
)
} }
disabled={!record.salary_document_path} disabled={!record.salary_document_path}
/> />

@ -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 (
<div>
<Table
size="middle"
bordered
dataSource={data?.map((u, i) => ({
no: i + 1,
...u,
}))}
columns={[
{
title: <img src={tagIcon} alt="" />,
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) => (
<Button
type="primary"
href={record.salary_document_path}
target="_blank"
>
Download
</Button>
),
},
]}
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,
}}
/>
</div>
);
}
export default ConfirmedMonths;

@ -33,6 +33,7 @@ import {
} from "antd"; } from "antd";
import { SearchOutlined } from "@ant-design/icons"; import { SearchOutlined } from "@ant-design/icons";
import TabPane from "antd/es/tabs/TabPane"; import TabPane from "antd/es/tabs/TabPane";
import api from "../../API/api";
// @ts-ignore // @ts-ignore
import IconSearch from "../../assets/searchIcon.png"; import IconSearch from "../../assets/searchIcon.png";
import { import {
@ -274,7 +275,6 @@ const Stat = () => {
null null
); );
const token = localStorage.getItem("access");
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
useEffect(() => { useEffect(() => {
@ -289,13 +289,9 @@ const Stat = () => {
} }
const formattedEndDate = finalEndDate.format("YYYY-MM-DD HH:mm:ss"); const formattedEndDate = finalEndDate.format("YYYY-MM-DD HH:mm:ss");
const response = await axios.get( const response = await api.get("stats/general-stats", {
"https://api.tteld.co/api/v1/stats/general-stats", params: { start_date: startDate, end_date: formattedEndDate },
{ });
params: { start_date: startDate, end_date: formattedEndDate },
headers: { Authorization: `Bearer ${token}` },
}
);
if (response.data.daily_stats) { if (response.data.daily_stats) {
setChartData(response.data.daily_stats); setChartData(response.data.daily_stats);
} }
@ -310,7 +306,7 @@ const Stat = () => {
}; };
fetchData(); fetchData();
}, [token, startDate, endDate]); }, [startDate, endDate]);
const formatDate = (dateString: string): string => { const formatDate = (dateString: string): string => {
const date = new Date(dateString); const date = new Date(dateString);

@ -219,7 +219,7 @@ const UpdateEdit = () => {
</Form.Item> </Form.Item>
</Col> </Col>
)} )}
{customerId !== null && ( {/* {customerId !== null && (
<Col span={8}> <Col span={8}>
<Form.Item <Form.Item
wrapperCol={{ span: "100%" }} wrapperCol={{ span: "100%" }}
@ -227,12 +227,25 @@ const UpdateEdit = () => {
> >
{data?.customer.id !== undefined && ( {data?.customer.id !== undefined && (
<Input <Input
defaultValue={data?.customer.name} defaultValue={data?.customer?.name}
readOnly readOnly
/> />
)} )}
</Form.Item> </Form.Item>
</Col> </Col>
)} */}
{customerId !== null && (
<Col span={8}>
<Form.Item
wrapperCol={{ span: "100%" }}
label="Driver"
>
<Input
defaultValue={data?.customer?.name || ""}
readOnly
/>
</Form.Item>
</Col>
)} )}
</Row> </Row>
</Form> </Form>

@ -34,3 +34,13 @@ export const useAccountingHistory = ({
} }
); );
}; };
export const useConfirmedMonths = () => {
return useQuery(
[`/salaries-group`],
() => AccountingController.confirmedMonths(),
{
refetchOnWindowFocus: false,
}
);
};

@ -13,6 +13,14 @@ export type TAccounting = {
username: string; username: string;
}; };
export type TAccountingConfirmedMonths = {
id: number;
month: string;
year: number;
salary_document_path: string;
created_at: string;
};
export type TAccountingHistory = { export type TAccountingHistory = {
id: number; id: number;
full_name: string; full_name: string;

Loading…
Cancel
Save