From 82925efaa64a59ce60fa0ba39ccd958638757057 Mon Sep 17 00:00:00 2001 From: jennyjoo <100cllr@gmail.com> Date: Tue, 2 Jul 2024 13:03:39 +0900 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=EC=95=8C=EB=B0=94=EC=83=9D=20?= =?UTF-8?q?=EA=B8=89=EC=97=AC=EB=AA=85=EC=84=B8=EC=84=9C=20=EC=88=98?= =?UTF-8?q?=EB=A0=B9=ED=99=95=EC=9D=B8=20=EC=84=9C=EB=AA=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/apiClient.ts | 13 ++++ src/api/interfaces/employeeApi.ts | 2 + src/pages/employee/PartTimeTab/PayStub.tsx | 73 ++++++++++++++++++++-- src/types/api/employee-api.d.ts | 5 ++ 4 files changed, 88 insertions(+), 5 deletions(-) diff --git a/src/api/apiClient.ts b/src/api/apiClient.ts index e39f130..d45e1da 100644 --- a/src/api/apiClient.ts +++ b/src/api/apiClient.ts @@ -110,6 +110,19 @@ class ApiClient implements employeeApi { return response.data; } + //알바생 - 급여 명세서 서명 + public async employeeSignature( + payStubId: number + ): Promise { + const response: BaseResponse = + await this.axiosInstance.request({ + method: 'get', + url: `papers/pay-stubs/${payStubId}/e-sign`, + }); + + return response.data; + } + //========================== // 생성 메소드 private static createAxiosInstance() { diff --git a/src/api/interfaces/employeeApi.ts b/src/api/interfaces/employeeApi.ts index 559b8fb..67485cd 100644 --- a/src/api/interfaces/employeeApi.ts +++ b/src/api/interfaces/employeeApi.ts @@ -19,6 +19,8 @@ interface employeeApi { yearn: number, month: number ): Promise; + + employeeSignature(payStubId: number): Promise; } export default employeeApi; diff --git a/src/pages/employee/PartTimeTab/PayStub.tsx b/src/pages/employee/PartTimeTab/PayStub.tsx index d792eab..159b425 100644 --- a/src/pages/employee/PartTimeTab/PayStub.tsx +++ b/src/pages/employee/PartTimeTab/PayStub.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import WhiteBox from '../../../components/ui/WhiteBox'; import { formatMonths, styleMonths } from '../../../utils/format-date'; import BtnGray from '../../../components/BtnGray'; @@ -6,6 +6,9 @@ import Circle from '../../../components/ui/Circle'; import ApiClient from '../../../api/apiClient'; import generateMonthList from '../../../utils/generateMonthList'; import BtnPrimary from '../../../components/BtnPrimary'; +import ModalBottom from '../../../components/ModalBottom'; +import SignPad from '../../../components/SignPad'; +import { redirect, useNavigate } from 'react-router-dom'; type Prop = { year: number; @@ -13,16 +16,53 @@ type Prop = { }; const PayStub = ({ year, month }: Prop) => { + const navigation = useNavigate(); const [monthList, setMonthList] = useState([]); const [selectedYear, setSelectedYear] = useState(year); const [selectedMonth, setSelectedMonth] = useState(month); - const [payStub, setPayStub] = useState(null); + + //급여 명세서 + const [payStub, setPayStub] = useState( + null + ); + + //모달 + const [isModalOpen, setIsModalOpen] = useState(false); + const [modalMsg, setModalMsg] = useState(''); + + //서명 + const [getSign, setGetsign] = useState(false); + const signRef = useRef(null); const setSelectedYearMonth = (year: number, month: number) => { setSelectedYear(year); setSelectedMonth(month); }; + const closeModal = () => { + setIsModalOpen(false); + }; + + const openModal = (msg?: string) => { + setModalMsg(msg || ''); + setIsModalOpen(true); + }; + + const signature = async (payStubId: number) => { + const sign: [] = signRef.current?.canvasRef.current.toData(); + console.log(sign); + if (!sign) return; + try { + const response: EmployeeSignatureResponse = + await ApiClient.getInstance().employeeSignature(payStubId); + if (response) { + window.location.reload(); + } + } catch (err) { + console.log(err); + } + }; + const getData = async () => { try { const response = await ApiClient.getInstance().employeeGetPayStub( @@ -47,6 +87,26 @@ const PayStub = ({ year, month }: Prop) => { return ( <> + {isModalOpen && payStub && ( + setGetsign(true)} + > +
+ {!getSign ? ( + <>{modalMsg} + ) : ( + signature(payStub.payStubId)} + /> + )} +
+
+ )} {payStub && (