-
Notifications
You must be signed in to change notification settings - Fork 2
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
어드민 원서 상세조회 성적 페이지 중 교과 성적 테이블 개발
- Loading branch information
Showing
16 changed files
with
285 additions
and
42 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
apps/admin/src/components/common/SideMenu/SideMenu.stories.tsx
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,21 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import SideMenu from "./SideMenu"; | ||
|
||
export default { | ||
component: SideMenu, | ||
title: "SideMenu", | ||
tags: ["autodocs"], | ||
} satisfies Meta<typeof SideMenu>; | ||
|
||
export const Default: StoryObj<typeof SideMenu> = { | ||
args: { | ||
children: '교과 성적' | ||
}, | ||
}; | ||
|
||
export const Active: StoryObj<typeof SideMenu> = { | ||
args: { | ||
children: '교과 성적', | ||
active: true | ||
}, | ||
}; |
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,42 @@ | ||
import { color, font } from '@maru/theme'; | ||
import { flex } from '@maru/utils'; | ||
import { ReactNode } from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
interface Props { | ||
children: ReactNode; | ||
active: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
const SideMenu = ({ children, active, onClick }: Props) => { | ||
return ( | ||
<StyledSideMenu $active={active} onClick={onClick}> | ||
{children} | ||
</StyledSideMenu> | ||
); | ||
}; | ||
|
||
export default SideMenu; | ||
|
||
const StyledSideMenu = styled.button<{ $active: boolean }>` | ||
${flex({ alignItems: 'center' })} | ||
${font.H5} | ||
width: 200px; | ||
height: 56px; | ||
padding: 0px 16px; | ||
border-radius: 12px; | ||
color: ${color.gray700}; | ||
background: ${color.white}; | ||
&:hover { | ||
background: ${color.gray100}; | ||
} | ||
${(props) => | ||
props.$active && | ||
css` | ||
color: ${color.maruDefault}; | ||
background: ${color.gray100}; | ||
`} | ||
`; |
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
37 changes: 37 additions & 0 deletions
37
apps/admin/src/components/form/FormDetailContent/성적/교과성적/교과성적.tsx
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,37 @@ | ||
import { useFormDetailQuery } from '@/services/form/queries'; | ||
import getAchievementLevelsGroupList from '@/utils/functions/getAchievementLevelsGroupList'; | ||
import styled from 'styled-components'; | ||
import 교과성적Header from './교과성적Header/교과성적Header'; | ||
import 교과성적Item from './교과성적Item/교과성적Item'; | ||
|
||
interface Props { | ||
id: number; | ||
} | ||
|
||
const 교과성적 = ({ id }: Props) => { | ||
const { data: formDetailData } = useFormDetailQuery(id); | ||
|
||
const achievementLevelsGroupList = getAchievementLevelsGroupList( | ||
formDetailData?.grade.subjectList, | ||
); | ||
|
||
console.log(achievementLevelsGroupList); | ||
|
||
return ( | ||
<Styled교과성적> | ||
<교과성적Header /> | ||
{achievementLevelsGroupList.map((group) => ( | ||
<교과성적Item | ||
subjectName={group.subjectName} | ||
achievementLevel21={group.achievementLevels[0]} | ||
achievementLevel22={group.achievementLevels[1]} | ||
achievementLevel31={group.achievementLevels[2]} | ||
/> | ||
))} | ||
</Styled교과성적> | ||
); | ||
}; | ||
|
||
export default 교과성적; | ||
|
||
const Styled교과성적 = styled.div``; |
39 changes: 39 additions & 0 deletions
39
apps/admin/src/components/form/FormDetailContent/성적/교과성적/교과성적Header/교과성적Header.tsx
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,39 @@ | ||
import { Column, Row, Th } from '@maru/ui'; | ||
import styled from 'styled-components'; | ||
|
||
const 교과성적Header = () => { | ||
return ( | ||
<Styled교과성적Header> | ||
<Row> | ||
<Th width={123} height={100} borderTopLeftRadius={12}> | ||
과목 | ||
</Th> | ||
<Column> | ||
<Th width={279} height={50}> | ||
2학년 | ||
</Th> | ||
<Row> | ||
<Th option="SECONDARY" width="50%" height={50}> | ||
1학기 | ||
</Th> | ||
<Th option="SECONDARY" width="50%" height={50}> | ||
2학기 | ||
</Th> | ||
</Row> | ||
</Column> | ||
<Column> | ||
<Th width={140} height={50} borderTopRightRadius={12}> | ||
3학년 | ||
</Th> | ||
<Th option="SECONDARY" width={140} height={50}> | ||
1학기 | ||
</Th> | ||
</Column> | ||
</Row> | ||
</Styled교과성적Header> | ||
); | ||
}; | ||
|
||
export default 교과성적Header; | ||
|
||
const Styled교과성적Header = styled.div``; |
35 changes: 35 additions & 0 deletions
35
apps/admin/src/components/form/FormDetailContent/성적/교과성적/교과성적Item/교과성적Item.tsx
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,35 @@ | ||
import { AchievementLevel } from '@/types/form/client'; | ||
import { CellInput, Row, Td } from '@maru/ui'; | ||
|
||
interface Props { | ||
subjectName: string; | ||
achievementLevel21: AchievementLevel; | ||
achievementLevel22: AchievementLevel; | ||
achievementLevel31: AchievementLevel; | ||
} | ||
|
||
const 교과성적Item = ({ | ||
subjectName, | ||
achievementLevel21, | ||
achievementLevel22, | ||
achievementLevel31, | ||
}: Props) => { | ||
return ( | ||
<Row height={64}> | ||
<Td option="SECONDARY" width={123} height="100%"> | ||
{subjectName} | ||
</Td> | ||
<Td width={140} height="100%"> | ||
<CellInput type="text" value={achievementLevel21} readOnly /> | ||
</Td> | ||
<Td width={140} height="100%"> | ||
<CellInput type="text" value={achievementLevel22} readOnly /> | ||
</Td> | ||
<Td width={140} height="100%"> | ||
<CellInput type="text" value={achievementLevel31} readOnly /> | ||
</Td> | ||
</Row> | ||
); | ||
}; | ||
|
||
export default 교과성적Item; |
36 changes: 36 additions & 0 deletions
36
apps/admin/src/components/form/FormDetailContent/성적/성적.tsx
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,36 @@ | ||
import SideMenu from '@/components/common/SideMenu/SideMenu'; | ||
import { GRADUATION_STEP_LIST } from '@/constants/form/data'; | ||
import { Column, Row } from '@maru/ui'; | ||
import { SwitchCase } from '@toss/react'; | ||
import { useState } from 'react'; | ||
import 교과성적 from './교과성적/교과성적'; | ||
|
||
interface Props { | ||
id: number; | ||
} | ||
|
||
const 성적 = ({ id }: Props) => { | ||
const [currentGraduationStep, setCurrentGraduationStep] = useState('교과 성적'); | ||
return ( | ||
<Row gap={48}> | ||
<Column gap={10}> | ||
{GRADUATION_STEP_LIST.map((graduationStep, index) => ( | ||
<SideMenu | ||
key={`graduation-step ${index}`} | ||
active={currentGraduationStep === graduationStep} | ||
onClick={() => setCurrentGraduationStep(graduationStep)}> | ||
{graduationStep} | ||
</SideMenu> | ||
))} | ||
</Column> | ||
<SwitchCase | ||
value={currentGraduationStep} | ||
caseBy={{ | ||
'교과 성적': <교과성적 id={id} />, | ||
}} | ||
/> | ||
</Row> | ||
); | ||
}; | ||
|
||
export default 성적; |
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
26 changes: 26 additions & 0 deletions
26
apps/admin/src/utils/functions/getAchievementLevelsGroupList.ts
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,26 @@ | ||
import { AchievementLevelsGroup, Subject } from '@/types/form/client'; | ||
|
||
/** | ||
* Subject[] 타입을 AchievementLevelsGroup[] 타입으로 변환시켜주는 함수입니다. | ||
* @param subjectList | ||
* @returns | ||
*/ | ||
function getAchievementLevelsGroupList(subjectList?: Subject[]) { | ||
if (!subjectList) return []; | ||
return subjectList.reduce((acc: AchievementLevelsGroup[], record) => { | ||
let existingSubject = acc.find((subject) => subject.subjectName === record.subjectName); | ||
|
||
if (existingSubject) { | ||
existingSubject.achievementLevels.push(record.achievementLevel); | ||
} else { | ||
acc.push({ | ||
subjectName: record.subjectName, | ||
achievementLevels: [record.achievementLevel], | ||
}); | ||
} | ||
|
||
return acc; | ||
}, []); | ||
} | ||
|
||
export default getAchievementLevelsGroupList; |
Oops, something went wrong.