-
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 :: redisualStudentPage #88
- Loading branch information
Showing
15 changed files
with
355 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as S from './style'; | ||
import { TBody, TD, TR } from '@b1nd/b1nd-dodamdodam-ui'; | ||
import profileImg from 'assets/profileImg.svg'; | ||
import { outSleepingDataFilter } from 'utils/Out/outSleepingDataFilter'; | ||
import { useGetRedisualQuery } from 'queries/Redisual/redisual.query'; | ||
|
||
interface OffBasePassProps { | ||
studentName: string; | ||
selectGrade: number; | ||
selectApproval: string | undefined; | ||
selectRoom: string; | ||
} | ||
|
||
const OffbaseRedisualItem = ({ selectApproval, selectGrade, studentName, selectRoom }: OffBasePassProps) => { | ||
const { data: redisualStudent } = useGetRedisualQuery(); | ||
|
||
return ( | ||
<> | ||
{!outSleepingDataFilter || | ||
outSleepingDataFilter(redisualStudent, studentName, selectGrade, selectApproval, selectRoom)?.length === 0 ? ( | ||
<S.NoneTile>νμ¬ μλ₯ μ€μΈ νμμ΄ μμ΅λλ€.</S.NoneTile> | ||
) : ( | ||
<> | ||
<TBody customStyle={S.OffBaseTBody}> | ||
{outSleepingDataFilter(redisualStudent, studentName, selectGrade, selectApproval, selectRoom)?.map( | ||
(redisual) => ( | ||
<TR customStyle={S.OffBaseTR}> | ||
<TD customStyle={S.OffBaseTD}> | ||
<S.MemberImage src={profileImg} /> | ||
</TD> | ||
<TD customStyle={S.OffBaseTD}>{redisual.student.name}</TD> | ||
<TD customStyle={S.OffBaseTD}> | ||
{redisual.student.grade}νλ | ||
{redisual.student.room}λ°{redisual.student.number}λ² | ||
</TD> | ||
<TD customStyle={S.OffBaseTD}> | ||
<div>{redisual.phone}</div> | ||
</TD> | ||
</TR> | ||
) | ||
)} | ||
</TBody> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default OffbaseRedisualItem; |
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,110 @@ | ||
import styled from "styled-components"; | ||
import { CSSObject } from "styled-components"; | ||
|
||
export const OffBaseTBody: CSSObject = { | ||
width: "100%", | ||
fontSize: "14px", | ||
fontWeight: "600", | ||
marginTop: "5px", | ||
display: "flex", | ||
rowGap: "5px", | ||
flexDirection: "column", | ||
whiteSpace: "normal", | ||
cursor: "pointer", | ||
tr: { | ||
"&:hover": { | ||
filter: "unset", | ||
}, | ||
}, | ||
}; | ||
|
||
export const OffBaseTR: CSSObject = { | ||
width: "100%", | ||
height: "80px", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
columnGap: "10px", | ||
borderTop: "1px solid #d9d9d9", | ||
borderBottom: "1px solid #d9d9d9", | ||
}; | ||
|
||
export const OffBaseTD: CSSObject = { | ||
width: "14%", | ||
fontSize: "16px", | ||
lineHeight: "20px", | ||
}; | ||
|
||
export const BusLeaveTime: CSSObject = { | ||
width: "14%", | ||
fontSize: "16px", | ||
lineHeight: "20px", | ||
whiteSpace: "nowrap", | ||
}; | ||
|
||
export const PassengerStyle: CSSObject = { | ||
width: "65px", | ||
height: "30px", | ||
borderRadius: "7px", | ||
transition: "all 0.2s ease-in-out", | ||
"&:hover": { | ||
boxShadow: "0 0 0 1px #fff, 0 0 0 3px rgba(50, 100, 150, 0.4)", | ||
}, | ||
}; | ||
|
||
export const ButtonContainerStyle: CSSObject = { | ||
width: "14%", | ||
display: "flex", | ||
alignItems: "center", | ||
columnGap: "5px", | ||
|
||
marginRight: "10px", | ||
}; | ||
|
||
export const EditStyle: CSSObject = { | ||
width: "5rem", | ||
height: "2rem", | ||
borderRadius: "5px", | ||
fontSize: "18px", | ||
transition: "all 0.2s ease-in-out", | ||
|
||
"&:hover": { | ||
boxShadow: "0 0 0 1px #fff, 0 0 0 3px rgba(50, 100, 150, 0.4)", | ||
}, | ||
}; | ||
|
||
export const DelStyle: CSSObject = { | ||
width: "5rem", | ||
height: "2rem", | ||
|
||
fontSize: "18px", | ||
borderRadius: "5px", | ||
transition: "all 0.2s ease-in-out", | ||
"&:hover": { | ||
boxShadow: "0 0 0 1px #fff, 0 0 0 3px #ddd", | ||
}, | ||
}; | ||
|
||
export const MemberImage = styled.img` | ||
width: 38px; | ||
height: 38px; | ||
object-fit: cover; | ||
border-radius: 4rem; | ||
`; | ||
|
||
export const NoneTile = styled.p` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 64vh; | ||
font-size: 16px; | ||
color: #212529; | ||
`; | ||
|
||
export const DateContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
margin-right: 60px; | ||
`; |
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,73 @@ | ||
import * as S from './style'; | ||
import { Suspense, useState } from 'react'; | ||
import ErrorBoundary from 'components/common/ErrorBoundary'; | ||
import TableAttribute from 'components/common/TableAttribute'; | ||
import TodayOffBaseItem from './RedisualItem/index'; | ||
import { REDISUAL_ITEMS } from 'constants/Out/offbase.constant'; | ||
import { SearchBar, Select } from '@b1nd/b1nd-dodamdodam-ui'; | ||
import { useRecoilState } from 'recoil'; | ||
import { SelectApprovalAtom, SelectGradeAtom } from 'stores/Out/out.store'; | ||
import { changeApproval } from 'utils/Out/changeApproval'; | ||
import { changeGrade } from 'utils/Member/changeGrade'; | ||
import { GRADE_ITEMS } from 'constants/Grade/grade.constant'; | ||
import { CsvButtonContainer } from 'components/Bus/BusModal/BusPassenger/style'; | ||
import CsvButton from 'components/common/ExtractCsvData'; | ||
import dayjs from 'dayjs'; | ||
import useOffBaseLeave from 'hooks/Out/OutSleeping/useOutsleeping'; | ||
import { PointSelectRoom } from 'stores/Point/point.store'; | ||
import { useGetRedisualQuery } from 'queries/Redisual/redisual.query'; | ||
import { redisualMemberCalc } from 'utils/Out/redisualMemberCalc'; | ||
import useRedisual from 'hooks/Out/Redisual/useRedisual'; | ||
|
||
const OffbaseRedisual = () => { | ||
const [studentName, setStudentName] = useState(''); | ||
const [selectGrade, setSelectGrade] = useRecoilState(SelectGradeAtom); | ||
const [selectApproval, setSelectApproval] = useRecoilState(SelectApprovalAtom); | ||
const [room, setRoom] = useRecoilState(PointSelectRoom); | ||
|
||
const { redisualStudent } = useRedisual(); | ||
|
||
const { data: redesualStudent } = useGetRedisualQuery(); | ||
|
||
return ( | ||
<> | ||
<S.OffBaseHeaderContainer> | ||
<div style={{ display: 'flex', alignItems: 'center' }}> | ||
<SearchBar value={studentName} onChange={setStudentName} /> | ||
<span style={{ marginLeft: 10 }}> | ||
{redisualMemberCalc(redesualStudent?.data!).length === 0 | ||
? 'μ€λμ μΈλ° μλ₯μκ° μμ΅λλ€.' | ||
: `μ€λμ μΈλ° μλ₯μ μ : ${redisualMemberCalc(redesualStudent?.data!).length}λͺ `} | ||
</span> | ||
</div> | ||
<S.SelectContainer> | ||
<CsvButtonContainer> | ||
<CsvButton csvData={redisualStudent} fileName={dayjs().format('YYYY-MM-DD') + 'μλ₯ μ€μΈ νμ'} /> | ||
</CsvButtonContainer> | ||
<Select items={GRADE_ITEMS} value={selectGrade} onChange={setSelectGrade} zIndex={2} /> | ||
<Select | ||
items={['λͺ¨λ νλ°', '1λ°', '2λ°', '3λ°', '4λ°']} | ||
value={room || 'νλ°μ μ νν΄μ£ΌμΈμ'} | ||
onChange={setRoom} | ||
zIndex={2} | ||
/> | ||
</S.SelectContainer> | ||
</S.OffBaseHeaderContainer> | ||
|
||
<TableAttribute constant={REDISUAL_ITEMS} thStyle={{ width: '14%' }}> | ||
<ErrorBoundary fallback={<>μ€λμ μΈλ° μλ₯μλ₯Ό λΆλ¬μ€μ§ λͺ»νμ΅λλ€.</>}> | ||
<Suspense fallback={<>λ‘λ©μ€...</>}> | ||
<TodayOffBaseItem | ||
selectRoom={room} | ||
selectApproval={changeApproval(selectApproval)} | ||
selectGrade={changeGrade(selectGrade)} | ||
studentName={studentName} | ||
/> | ||
</Suspense> | ||
</ErrorBoundary> | ||
</TableAttribute> | ||
</> | ||
); | ||
}; | ||
|
||
export default OffbaseRedisual; |
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,13 @@ | ||
import styled from "styled-components"; | ||
export const SelectContainer = styled.div` | ||
display: flex; | ||
column-gap: 10px; | ||
`; | ||
|
||
export const OffBaseHeaderContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
z-index: 900; | ||
`; |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const OUT_GOING_ITEMS = ["μ¬μ§", "μ΄λ¦", "νλ°", "μΆλ°", "λμ°©", "μ¬μ ", "μμ¬ μ¬λΆ", "μΉμΈμ¬λΆ"]; | ||
export const OUT_GOING_ITEMS = ['μ¬μ§', 'μ΄λ¦', 'νλ°', 'μΆλ°', 'λμ°©', 'μ¬μ ', 'μμ¬ μ¬λΆ', 'μΉμΈμ¬λΆ']; | ||
|
||
export const OUT_SLEEPING_ITEMS = ["μ¬μ§", "μ΄λ¦", "νλ°", "μΆλ°", "λμ°©", "μ¬μ ", "μΉμΈμ¬λΆ"]; | ||
export const OUT_SLEEPING_ITEMS = ['μ¬μ§', 'μ΄λ¦', 'νλ°', 'μΆλ°', 'λμ°©', 'μ¬μ ', 'μΉμΈμ¬λΆ']; | ||
|
||
export const REDISUAL_ITEMS = ['μ¬μ§', 'μ΄λ¦', 'νλ°', 'μ νλ²νΈ']; |
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,33 @@ | ||
import { QUERY_KEYS } from 'queries/queryKey'; | ||
import { useGetRedisualQuery } from 'queries/Redisual/redisual.query'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
const useRedisual = () => { | ||
const { data: redisual } = useGetRedisualQuery(); | ||
const [redisualStudent, setRedisualStudent] = useState([ | ||
{ | ||
μ΄λ¦: '', | ||
λ°λ²νΈ: '', | ||
μ νλ²νΈ: '', | ||
λΉκ³ : '', | ||
}, | ||
]); | ||
|
||
useEffect(() => { | ||
if (redisual?.data) { | ||
const newData = redisual.data.map((data) => ({ | ||
μ΄λ¦: data.student.name, | ||
λ°λ²νΈ: `${data.student.grade}νλ ${data.student.room}λ° ${data.student.number}λ²`, | ||
μ νλ²νΈ: data.phone, | ||
λΉκ³ : '', | ||
})); | ||
setRedisualStudent(newData); | ||
} | ||
}, [redisual]); | ||
|
||
return { | ||
redisualStudent, | ||
}; | ||
}; | ||
|
||
export default useRedisual; |
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,12 @@ | ||
import OffbaseRedisual from 'components/Out/Redisual'; | ||
import SectionHeaderProvider from 'components/common/SectionHeaderProvider'; | ||
|
||
const OffbaseRedisualPage = () => { | ||
return ( | ||
<SectionHeaderProvider title="μλ₯μ€" subTitle="νμ¬ μλ₯ μ€μΈ νμμ΄ λ³΄μ¬μ§λλ€."> | ||
<OffbaseRedisual /> | ||
</SectionHeaderProvider> | ||
); | ||
}; | ||
|
||
export default OffbaseRedisualPage; |
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,12 @@ | ||
import { AxiosError } from 'axios'; | ||
import { QUERY_KEYS } from 'queries/queryKey'; | ||
import { useQuery, UseQueryOptions } from 'react-query'; | ||
import redisualRepositoryImpl from 'repositories/Redisual/redisual.repositoryImpl'; | ||
import { OutResponse } from 'types/Out/out.type'; | ||
|
||
export const useGetRedisualQuery = (options?: UseQueryOptions<OutResponse, AxiosError, OutResponse, string>) => | ||
useQuery(QUERY_KEYS.redisual.getResidual, () => redisualRepositoryImpl.getResdisual(), { | ||
staleTime: 1000 * 60 * 60, | ||
cacheTime: 1000 * 60 * 60, | ||
...options, | ||
}); |
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,5 @@ | ||
import { OutResponse } from 'types/Out/out.type'; | ||
|
||
export interface RedisualRepository { | ||
getResdisual(): Promise<OutResponse>; | ||
} |
Oops, something went wrong.