Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/TeamWazard/wazard-front int…
Browse files Browse the repository at this point in the history
…o feat/#75
  • Loading branch information
seoyoung7623 committed Jun 2, 2023
2 parents 5f050e3 + 2ed35b2 commit 1f16d15
Show file tree
Hide file tree
Showing 11 changed files with 710 additions and 11 deletions.
14 changes: 13 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ import AlbaTest2 from "pages/main/AlbaTest2";
import AlbaTest3 from "pages/main/AlbaTest3";
import AlbaInvitePage from "pages/alba/AlbaInvitedPage";
import ScrollToTop from "components/ScrollToTop";
import AlbaContract from "pages/alba/AlbaContract";
import AlbaContract from "pages/alba/inAlba/AlbaContract";
import MyPageAlbaRecord from "pages/alba/MyPageAlbaRecord";
import AlbaMainPage from "pages/alba/inAlba/AlbaMainPage";
import AlbaAttendance from "pages/alba/inAlba/AlbaAttendance";
import AlbaReplace from "pages/alba/inAlba/AlbaReplace";
import AlbaReplaceForm from "pages/alba/inAlba/AlbaReplaceForm";
import MyPageAlbaRecordCheck from "pages/alba/MyPageAlbaRecordCheck";
import MyPageCertification from "pages/main/MyPageCertification";
import MyPageEdit from "pages/main/MyPageEdit";
import CompanyInviteContract from "pages/company/inCompany/CompanyInviteContract";

function App() {
return (
Expand Down Expand Up @@ -81,6 +84,10 @@ function App() {
path="/company_main/:id/invite"
element={<CompanyInvite />}
></Route>
<Route
path="/company_main/:id/invite/:id"
element={<CompanyInviteContract />}
></Route>

<Route path="/company_main/:id/qr" element={<CompanyQR />}></Route>

Expand All @@ -100,6 +107,11 @@ function App() {
<Route path="/alba_list" element={<AlbaList />} />
<Route path="/alba_invited" element={<AlbaInvitePage />} />
<Route path="/alba_main/:id/contract" element={<AlbaContract />} />
<Route path="/alba_main/:id/replace" element={<AlbaReplace />} />
<Route
path="/alba_main/:id/replace/form"
element={<AlbaReplaceForm />}
/>
<Route path="/alba_record" element={<MyPageAlbaRecord />} />
<Route
path="/alba_record/:id"
Expand Down
15 changes: 12 additions & 3 deletions src/components/LeftMenuAlba.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const LeftMenuAlba = (props) => {
const location = useLocation();
const [showSubMenu, setShowSubMenu] = useState(false);
const { companyId } = props;

const handleSubMenuToggle = () => {
setShowSubMenu(!showSubMenu);
};
Expand Down Expand Up @@ -136,10 +137,18 @@ const LeftMenuAlba = (props) => {
</NavLink>

<NavLink
to={`/albatest3`}
className={location.pathname === `/albatest3` ? "active" : ""}
to={`/alba_main/${companyId}/replace`}
className={
location.pathname === `/alba_main/${companyId}/replace/form`
? "active"
: ""
}
>
<MenuItem isActive={location.pathname === `/albatest3`}>
<MenuItem
isActive={
location.pathname === `/alba_main/${companyId}/replace/form`
}
>
대타 기록
</MenuItem>
</NavLink>
Expand Down
8 changes: 4 additions & 4 deletions src/components/LeftMenuCeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ const LeftMenuCeo = (props) => {
<NavLink
to={`/company_main/${companyId}/alba_list`}
className={
location.pathname === `/company_main/${companyId}/alba_list`
location.pathname.includes(`/company_main/${companyId}/alba_list`)
? "active"
: ""
}
>
<MenuItem
isActive={
location.pathname === `/company_main/${companyId}/alba_list`
}
isActive={location.pathname.includes(
`/company_main/${companyId}/alba_list`
)}
>
알바생 관리
</MenuItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useDispatch, useSelector } from "react-redux";
import { useLocation, useNavigate, useParams } from "react-router-dom";
import { useState } from "react";

import Header from "components/Header";
import HeaderAlba from "components/HeaderAlba";

import "../../style/company/companyAlba.scss";
import "../../../style/company/companyAlba.scss";
import LeftMenuAlba from "components/LeftMenuAlba";

const AlbaContract = (props) => {
Expand Down Expand Up @@ -42,7 +42,7 @@ const AlbaContract = (props) => {

return (
<div className="albaList">
<Header />
<HeaderAlba />
<div className="companyAlba-Wrapper">
<LeftMenuAlba companyId={id} />
<div className="list-Wrapper">
Expand Down
65 changes: 65 additions & 0 deletions src/pages/alba/inAlba/AlbaReplace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { useDispatch, useSelector } from "react-redux";
import { useLocation, useNavigate, useParams } from "react-router-dom";
import { useState } from "react";

import HeaderAlba from "components/HeaderAlba";
import LeftMenuAlba from "components/LeftMenuAlba";
import "../../../style/alba/albaReplace.scss";

const AlbaReplace = () => {
const dispatch = useDispatch();

const navigate = useNavigate();
const { id } = useParams();

const location = useLocation();
const alba_replace = useSelector((state) => state.alba_replace);

return (
<div className="albaList">
<HeaderAlba />
<div className="Alba-Wrapper">
<LeftMenuAlba companyId={id} />
<div className="list-Wrapper">
<div className="title">
<p>대타 기록</p>
<button
className="btn_record"
onClick={() => {
navigate(`/alba_main/${id}/replace/form`);
}}
>
기록하기
</button>
</div>
<div className="list">
{alba_replace.map((it) => (
<div className="company_one">
<div className="company_one_right">
<div className="company_set">
<label>기존근무자: </label>
{it.userName}
</div>
<div className="company_set">
<label>대체근무자: </label>
{it.replaceUser}
</div>
<div className="company_set_time">
<label>대타 시간:</label>
{it.checkDate}
<br />
{it.startTime}
{"-"}
{it.endTime}
</div>
</div>
</div>
))}
</div>
</div>
</div>
</div>
);
};

export default AlbaReplace;
157 changes: 157 additions & 0 deletions src/pages/alba/inAlba/AlbaReplaceForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import { useDispatch, useSelector } from "react-redux";
import { useLocation, useNavigate, useParams } from "react-router-dom";
import { useState, useRef } from "react";
import HeaderAlba from "components/HeaderAlba";
import LeftMenuAlba from "components/LeftMenuAlba";
import "../../../style/alba/albaReplace.scss";
import { addReplace } from "../../../redux-toolkit/albaModule/AlbaReplaceSlice";

const AlbaReplaceForm = () => {
const [info, setInfo] = useState({
userName: "김민규",
replaceUser: "",
startTime: "",
endTime: "",
checkDate: "",
});

const dispatch = useDispatch();
const navigate = useNavigate();
const location = useLocation();
const { id } = useParams();

const alba_replace = useSelector((state) => state.alba_replace);

const inputRefs = {
replaceUserInput: useRef(),
startTimeInput: useRef(),
endTimeInput: useRef(),
checkDateInput: useRef(),
};

// const startHandleChange = (e) => {
// const inputTime = e.target.value;
// // 시간 유효성 검사 등을 수행할 수 있습니다.

// console.log(inputTime);
// setInfo(inputTime);
// };
const userHandleChange = (e) => {
{
setInfo((prevInfo) => ({
...prevInfo,
[e.target.name]: e.target.value,
}));
}
};

// const startHandleChange = (e) => {
// const inputTime = e.target.value;
// setInfo((prevInfo) => ({
// ...prevInfo,
// startTime: inputTime,
// }));
// };

// const endHandleChange = (e) => {
// const inputTime = e.target.value;
// setInfo((prevInfo) => ({
// ...prevInfo,
// endTime: inputTime,
// }));
// };

// const dateHandleChange = (e) => {
// const inputTime = e.target.value;
// setInfo((prevInfo) => ({
// ...prevInfo,
// checkDate: inputTime,
// }));
// console.log({ info });
// };

const onClickSave = () => {
if (info.replaceUser === "") {
inputRefs.replaceUserInput.current.focus();
} else if (info.startTime === "") {
inputRefs.startTimeInput.current.focus();
} else if (info.endTime === "") {
inputRefs.endTimeInput.current.focus();
} else if (info.checkDate === "") {
inputRefs.checkDateInput.current.focus();
} else {
dispatch(addReplace(info));
console.log({ info });
navigate(`/alba_main/${id}/replace`);
}
};

return (
<div className="albaList">
<HeaderAlba />
<div className="Alba-Wrapper">
<LeftMenuAlba companyId={id} />
<div className="list-Wrapper">
<div className="title">
<p>대타 기록하기</p>
</div>
<div className="form-Wrapper">
<div className="line">
<label>기존 근무자</label>&nbsp;&nbsp;
{info.userName}
</div>
<div className="line">
<label>대체 근무자</label>
<input
className="input_box"
name="replaceUser"
ref={inputRefs.replaceUserInput}
value={info.replaceUser}
onChange={userHandleChange}
></input>
</div>
<div className="line">
<label>시간 선택</label>
<input
ref={inputRefs.startTimeInput}
className="time"
name="startTime"
type="time"
// pattern="[0-2][0-9]:[0-5][0-9]"
placeholder="00:00"
value={info.startTime}
onChange={userHandleChange}
/>
&nbsp;&nbsp;{"-"}&nbsp;&nbsp;
<input
ref={inputRefs.endTimeInput}
className="time"
name="endTime"
type="time"
// pattern="[0-2][0-9]:[0-5][0-9]"
placeholder="00:00"
value={info.endTime}
onChange={userHandleChange}
/>
</div>
<div className="line">
<label>날짜 선택</label>&nbsp;
<input
ref={inputRefs.checkDateInput}
name="checkDate"
type="date"
value={info.checkDate}
onChange={userHandleChange}
></input>
</div>
<button className="btn_record" onClick={onClickSave}>
기록하기
</button>
</div>
</div>
</div>
</div>
);
};

export default AlbaReplaceForm;
Loading

0 comments on commit 1f16d15

Please sign in to comment.