-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat/#77] 알바생 화면 - 대타기록 페이지 및 폼 제작
- Loading branch information
Showing
8 changed files
with
497 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
{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} | ||
/> | ||
{"-"} | ||
<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> | ||
<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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
|
||
export const AlbaReplaceSlice = createSlice({ | ||
name: "alba_replace", | ||
initialState: [ | ||
{ | ||
userName: "김민규", | ||
replaceUser: "김정환", | ||
startTime: "08:00", | ||
endTime: "13:30", | ||
checkDate: "2023-06-02", | ||
}, | ||
{ | ||
userName: "김민규", | ||
replaceUser: "김정환", | ||
startTime: "08:00", | ||
endTime: "13:30", | ||
checkDate: "2023-06-02", | ||
}, | ||
{ | ||
userName: "김민규", | ||
replaceUser: "김정환", | ||
startTime: "08:00", | ||
endTime: "13:30", | ||
checkDate: "2023-06-02", | ||
}, | ||
], | ||
reducers: { | ||
addReplace: (state, action) => { | ||
const nextId = state.length; | ||
state.push({ ...action.payload }); | ||
}, | ||
}, | ||
}); | ||
|
||
export const { addReplace } = AlbaReplaceSlice.actions; | ||
|
||
export default AlbaReplaceSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.