diff --git a/src/App.tsx b/src/App.tsx index 548f9b9..ceff909 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -45,7 +45,6 @@ function App() { }> } /> - } /> { + const response: BaseResponse = await this.axiosInstance.request({ + method: 'get', + url: 'employee/accounts', + }); + + return response.data; + } + //========================== // 생성 메소드 private static createAxiosInstance() { diff --git a/src/api/interfaces/employeeApi.ts b/src/api/interfaces/employeeApi.ts index acba320..642b98a 100644 --- a/src/api/interfaces/employeeApi.ts +++ b/src/api/interfaces/employeeApi.ts @@ -27,6 +27,8 @@ interface employeeApi { employeeSignature(payStubId: number): Promise; employeeGetAttendanceList(): Promise; + + employeeGetMyInfo(): Promise; } export default employeeApi; diff --git a/src/components/ui/ToolBarLink.tsx b/src/components/ui/ToolBarLink.tsx index aab56d1..42e09fe 100644 --- a/src/components/ui/ToolBarLink.tsx +++ b/src/components/ui/ToolBarLink.tsx @@ -1,16 +1,7 @@ -import { useState } from 'react'; -import ToolBarDetail from './ToolBarDetail'; -import { Link } from 'react-router-dom'; import { NavLink } from 'react-router-dom'; // const mockData = ['나의 사업장', '캘린더']; -type LinkData = { - idx: number; - title: string; - url: string; -}; - type ToolBarLinkProps = { options: LinkData[]; }; @@ -18,12 +9,12 @@ type ToolBarLinkProps = { const ToolBarLink = ({ options }: ToolBarLinkProps) => { return ( <> -
+
{options.map((option) => { return ( - `bg-white px-8 py-3 ${isActive ? 'text-hanaLightGreen border-b-2 border-hanaLightGreen' : ''}` + `bg-white px-3 py-3 ${isActive ? 'text-hanaLightGreen border-b-2 border-hanaLightGreen' : ''}` } key={option.idx} to={option.url} diff --git a/src/pages/LandingPage/EmployeeAddMainAccount.tsx b/src/pages/LandingPage/EmployeeAddMainAccount.tsx index 43b8157..3967bb7 100644 --- a/src/pages/LandingPage/EmployeeAddMainAccount.tsx +++ b/src/pages/LandingPage/EmployeeAddMainAccount.tsx @@ -9,17 +9,7 @@ import InputBorder from '../../components/InputBorder'; import InputBorderSelect from '../../components/InputBorderSelect'; import ModalCenter from '../../components/ModalCenter'; import ApiClient from '../../api/apiClient'; - -export const BankList: SelectionProp[] = [ - { text: '하나은행', value: 'HANA' }, - { text: '신한은행', value: 'SHIN_HAN' }, - { text: '국민은행', value: 'KUK_MIN' }, - { text: '우리은행', value: 'URI' }, - { text: 'IBK기업은행', value: 'IBK' }, - { text: '농협은행', value: 'NONG_HYEOP' }, - { text: '수협은행', value: 'SU_HYEOP' }, - { text: '부산은행', value: 'BUSAN' }, -]; +import { BankList } from '../employee/datas'; const EmployeeAddMainAccount = () => { const [isModalOpen, setIsModal] = useState(false); diff --git a/src/pages/employee/Attendance/Attendance.tsx b/src/pages/employee/Attendance/Attendance.tsx index 082f565..bb33dfb 100644 --- a/src/pages/employee/Attendance/Attendance.tsx +++ b/src/pages/employee/Attendance/Attendance.tsx @@ -9,6 +9,8 @@ import { useNavigate } from 'react-router-dom'; import ApiClient from '../../../api/apiClient'; import { useEffect, useState } from 'react'; import BtnGray from '../../../components/BtnGray'; +import ToolBarLink from '../../../components/ui/ToolBarLink'; +import { EmployeeMenuList } from '../datas'; const today = new Date(); const day = today.getDay(); @@ -79,7 +81,7 @@ const Attendance = () => { <> {attendances && ( - +
{/* 오늘 출근 목록 */} @@ -98,7 +100,7 @@ const Attendance = () => { > @@ -115,13 +117,15 @@ const Attendance = () => { ))}
-
-
- [{item.workPlaceName}] - {item.notice[0].title} + {item.notice.length > 0 && ( +
+
+ [{item.workPlaceName}] + {item?.notice[0].title} +
+ {` ${item?.notice[0].content}`}
- {` ${item.notice[0].content}`} -
+ )} {isActivated(item) ? ( {}} /> ) : ( @@ -145,14 +149,14 @@ const Attendance = () => {
{item.workTime.length > 0 ? (
- {item.workTime[0]?.workDayOfWeek}{' '} - {item.workTime[0]?.workStartTime} + {item.workTime[0].workDayOfWeek}{' '} + {item.workTime[0].workStartTime} {' - '} - {item.workTime[0]?.workEndTime} + {item.workTime[0].workEndTime}
) : (
diff --git a/src/pages/employee/MyPageTab/EditMyPage.tsx b/src/pages/employee/MyPageTab/EditMyPage.tsx index a7051ee..f408f90 100644 --- a/src/pages/employee/MyPageTab/EditMyPage.tsx +++ b/src/pages/employee/MyPageTab/EditMyPage.tsx @@ -1,15 +1,14 @@ import { useNavigate } from 'react-router-dom'; import BtnBottom from '../../../components/BtnBottom'; import Frame from '../../../components/Frame'; -import InputBox from '../../../components/ui/InputBox'; import ReturnArrow from '../../../components/ui/ReturnArrow'; import ModalBottom from '../../../components/ModalBottom'; import { useRef, useState } from 'react'; import InputBorderSelect from '../../../components/InputBorderSelect'; -import { BankList } from '../../LandingPage/EmployeeAddMainAccount'; import InputBorder from '../../../components/InputBorder'; import ApiClient from '../../../api/apiClient'; import ModalCenter from '../../../components/ModalCenter'; +import { BankList } from '../datas'; const EditMyPage = () => { const [isModalOpen, setIsModalOpen] = useState(false); diff --git a/src/pages/employee/MyPageTab/MyPage.tsx b/src/pages/employee/MyPageTab/MyPage.tsx index b5cd574..ed45536 100644 --- a/src/pages/employee/MyPageTab/MyPage.tsx +++ b/src/pages/employee/MyPageTab/MyPage.tsx @@ -3,11 +3,11 @@ import Frame from '../../../components/Frame'; import Wrapper from '../../../components/Wrapper'; import WhiteBox from '../../../components/ui/WhiteBox'; import WorkPlaceName from '../../../components/ui/WorkPlaceName'; -import ToolBar2 from '../../../components/ui/ToolBar2'; import { useEffect, useState } from 'react'; import ApiClient from '../../../api/apiClient'; import ModalBottom from '../../../components/ModalBottom'; -import { formatDate, styleDate } from '../../../utils/format-date'; +import ToolBarLink from '../../../components/ui/ToolBarLink'; +import { EmployeeMenuList } from '../datas'; const MyPage = () => { const navigation = useNavigate(); @@ -15,6 +15,7 @@ const MyPage = () => { const [paperDetail, setPaperDetail] = useState(null); const [isModalOpen, setModalOpen] = useState(false); + const [myInfo, setMyInfo] = useState(null); const [modalMsg, setModalMsg] = useState(''); const openModal = (msg?: string) => { @@ -41,6 +42,17 @@ const MyPage = () => { } }; + const getMyInfo = async () => { + try { + const response: MyInfo = + await ApiClient.getInstance().employeeGetMyInfo(); + + setMyInfo(response); + } catch (err) { + console.error(err); + } + }; + const fetchData = async () => { try { const response: EmploymentContractListGetResponse[] = @@ -55,6 +67,7 @@ const MyPage = () => { useEffect(() => { fetchData(); + getMyInfo(); }, []); return ( <> @@ -146,7 +159,7 @@ const MyPage = () => { )} - +
{/* 나의 정보 */} @@ -155,17 +168,17 @@ const MyPage = () => { {/* 성명 */}
성명
-
이름
+
{myInfo?.username}
{/* 전화번호 */}
전화번호
-
이름
+
{myInfo?.phoneNumber}
{/* 계좌번호 */}
계좌번호
-
이름
+
{myInfo?.accountNumber}
diff --git a/src/pages/employee/PartTimeTab/Payment.tsx b/src/pages/employee/PartTimeTab/Payment.tsx index 9525a45..0b7ed08 100644 --- a/src/pages/employee/PartTimeTab/Payment.tsx +++ b/src/pages/employee/PartTimeTab/Payment.tsx @@ -1,38 +1,37 @@ import { useNavigate } from 'react-router-dom'; import WhiteBox from '../../../components/ui/WhiteBox'; import { formatMonths, styleMonths } from '../../../utils/format-date'; -import { useEffect, useState } from 'react'; +import { ChangeEvent, useEffect, useState } from 'react'; import { FaAngleRight } from 'react-icons/fa6'; import WorkPlaceName from '../../../components/ui/WorkPlaceName'; import ApiClient from '../../../api/apiClient'; -import generateMonthList from '../../../utils/generateMonthList'; -type Payment = { - name: string; - payment: number; +type Prop = { + monthList: Date[]; + selectedDate: Date; + selectDate: React.Dispatch; }; -const Payment = () => { +const Payment = ({ monthList, selectedDate, selectDate }: Prop) => { const today = new Date(); const navigate = useNavigate(); - const [monthList, setMonthList] = useState([]); - const [selectedMonth, setSelectedMonth] = useState( - today.getMonth() + 1 - ); - const [selectedYear, setSelectedYear] = useState(today.getFullYear()); + const [totalMonthlyPayment, setTotalMonthlyPayment] = useState(0); const [paymentList, setPaymentList] = useState< EmployeeSalaryGetResponseList[] >([]); const fetchData = async (year: number, month: number) => { + console.log(year, month); try { const response: MonthlyPayment = await ApiClient.getInstance().getMonthlyPayment(year, month); if (response) { setTotalMonthlyPayment(response.totalPayment); - setPaymentList(response.employeeSalaryGetResponseList); + setPaymentList(response.list); + console.log(response); + console.log('paymentList', paymentList); } } catch (err) { console.error(err); @@ -40,34 +39,35 @@ const Payment = () => { }; useEffect(() => { - fetchData(selectedYear, selectedMonth); - - setMonthList(generateMonthList()); - }, [selectedYear, selectedMonth]); + if (selectedDate) { + fetchData(selectedDate.getFullYear(), selectedDate.getMonth() + 1); + } + }, [selectedDate]); return ( <> {/* 총금액, 날짜 */} -
- -
+ {selectedDate.getMonth() + 1 && ( +
+ +
+ )}
{totalMonthlyPayment.toLocaleString()} 원
@@ -87,7 +87,7 @@ const Payment = () => { type='button' onClick={() => navigate( - `detail/${selectedYear}-${selectedMonth}` + + `/part-time/payment/detail/${selectedDate.getFullYear()}-${selectedDate.getMonth()}` + `/${item.workPlaceName}` ) } diff --git a/src/pages/employee/PartTimeTab/PaymentMain.tsx b/src/pages/employee/PartTimeTab/PaymentMain.tsx index a6b7a2a..49bdf56 100644 --- a/src/pages/employee/PartTimeTab/PaymentMain.tsx +++ b/src/pages/employee/PartTimeTab/PaymentMain.tsx @@ -1,29 +1,52 @@ import Frame from '../../../components/Frame'; import NavToggle from '../../../components/NavToggle'; -import { Outlet, useNavigate } from 'react-router-dom'; -import ToolBar2 from '../../../components/ui/ToolBar2'; +import { useNavigate } from 'react-router-dom'; +import ToolBarLink from '../../../components/ui/ToolBarLink'; +import { EmployeeMenuList } from '../datas'; +import { useEffect, useState } from 'react'; +import generateMonthList from '../../../utils/generateMonthList'; +import Payment from './Payment'; +import WorkTime from './WorkTime'; + +enum SELECTED_TAB { + PAYMENT = 'payment', + WORKTIME = 'worktime', +} const PaymentMain = () => { - const navigation = useNavigate(); + const today = new Date(); + const [monthList, setMonthList] = useState(() => generateMonthList()); + const [selectedYearMonth, setSelectedYearMonth] = useState(today); + + const [selectedTab, setSelectedTab] = useState( + SELECTED_TAB.PAYMENT + ); + + const selectPayment = () => setSelectedTab(SELECTED_TAB.PAYMENT); + const selectWorktime = () => setSelectedTab(SELECTED_TAB.WORKTIME); + return ( <> - +
{/* 토글 버튼 */} { - navigation('/part-time/payment'); - }} - secondSelected={() => { - navigation('/part-time/worktime'); - }} + firstSelected={selectPayment} + secondSelected={selectWorktime} /> - + {selectedTab === SELECTED_TAB.PAYMENT && ( + + )} + {selectedTab === SELECTED_TAB.WORKTIME && }
diff --git a/src/pages/employee/datas.ts b/src/pages/employee/datas.ts new file mode 100644 index 0000000..a976ea2 --- /dev/null +++ b/src/pages/employee/datas.ts @@ -0,0 +1,17 @@ +export const BankList: SelectionProp[] = [ + { text: '하나은행', value: 'HANA' }, + { text: '신한은행', value: 'SHIN_HAN' }, + { text: '국민은행', value: 'KUK_MIN' }, + { text: '우리은행', value: 'URI' }, + { text: 'IBK기업은행', value: 'IBK' }, + { text: '농협은행', value: 'NONG_HYEOP' }, + { text: '수협은행', value: 'SU_HYEOP' }, + { text: '부산은행', value: 'BUSAN' }, +]; + +export const EmployeeMenuList: LinkData[] = [ + { idx: 0, title: '캘린더', url: 'ca' }, + { idx: 1, title: '급여관리', url: '/part-time/payment' }, + { idx: 2, title: '마이페이지', url: '/my' }, + { idx: 3, title: '출퇴근', url: '/attendance' }, +]; diff --git a/src/types/api/employee-api.d.ts b/src/types/api/employee-api.d.ts index 9d84f08..880ca85 100644 --- a/src/types/api/employee-api.d.ts +++ b/src/types/api/employee-api.d.ts @@ -23,9 +23,10 @@ type ConfirmReqResponse = { //급여내역 월별 조회 type EmployeeSalaryGetResponseList = { - isConnected: boolean; id: number | null; + isConnected: boolean; isQuit: boolean; + payStubId: number | null; workPlaceName: string; workPlaceColor: string; payment: number; @@ -35,7 +36,7 @@ type MonthlyPayment = { year: number; month: number; totalPayment: number; - employeeSalaryGetResponseList: EmployeeSalaryGetResponseList[]; + list: EmployeeSalaryGetResponseList[]; }; //서류 조회 @@ -134,7 +135,7 @@ type AttendanceWorkTime = { type AttendanceTodayWork = { workPlaceEmployeeId: number; workPlaceName: string; - colorTypeCode: string; + colorTypeCd: string; workTime: AttendanceWorkTime[]; notice: Notice[]; // <- 차이점! 밑의 totalWorks 에는 없음 }; @@ -142,7 +143,7 @@ type AttendanceTodayWork = { type AttendanceWork = { workPlaceEmployeeId: number; workPlaceName: string; - colorTypeCode: string; + colorTypeCd: string; workTime: AttendanceWorkTime[]; }; @@ -150,3 +151,10 @@ type EmployeeTodayAttendancesResponse = { works: AttendanceTodayWork[]; totalWorks: AttendanceWork[]; }; + +//대표 계좌 조회 (내 정보 조회) +type MyInfo = { + accountNumber: string; + phoneNumber: string; //전화번호 + username: string; //성명 +}; diff --git a/src/types/components.d.ts b/src/types/components.d.ts index d6519d9..3886105 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -2,3 +2,9 @@ type SelectionProp = { text: string; value: any; }; + +type LinkData = { + idx: number; + title: string; + url: string; +};