Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result refactor/#137 #140

Merged
merged 14 commits into from
Sep 7, 2024
4 changes: 2 additions & 2 deletions app/(sub-page)/sign-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export default function SignInPage() {
</div>
<SignInForm />
<div className="flex mt-12 space-x-4 h-6 items-center justify-center">
<Link href={'/'}>
<Link href={'/find-id'}>
<Button className="text-xs" label="์•„์ด๋”” ์ฐพ๊ธฐ" variant={'text'} />
</Link>
<Separator orientation={'vertical'} />
<Link href={'/'}>
<Link href={'/find-password'}>
<Button className="text-xs" label="๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •" variant={'text'} />
</Link>
<Separator orientation={'vertical'} />
Expand Down
Binary file removed app/favicon.ico
Binary file not shown.
76 changes: 32 additions & 44 deletions app/mocks/data.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const resultCategoryDetailInfo = JSON.parse(`{
"completed": false
}
],
"completed": false
"completed": false
}`);

export const users = JSON.parse(`[
Expand All @@ -206,75 +206,63 @@ export const users = JSON.parse(`[

export const credits = JSON.parse(`[
{
"category": "COMMON_CULTURE",
"totalCredit" : 70,
"takenCredit" : 40,
"completed": false
},
{
"category": "CORE_CULTURE",
"totalCredit" : 70,
"takenCredit" : 40,
"completed": false
},
{
"category": "PRIMARY_MANDATORY_MAJOR",
"totalCredit" : 70,
"takenCredit" : 40,
"completed": false
"category": "DUAL_BASIC_ACADEMICAL_CULTURE",
"totalCredit": 6,
"takenCredit": 6.0,
"completed": true
},
{
"category": "PRIMARY_ELECTIVE_MAJOR",
"totalCredit" : 70,
"takenCredit" : 40,
"totalCredit": 24,
"takenCredit": 21.0,
"completed": false
},
{
"category": "DUAL_MANDATORY_MAJOR",
"totalCredit" : 70,
"takenCredit" : 40,
"totalCredit": 21,
"takenCredit": 18.0,
"completed": false
},
{
"category": "DUAL_ELECTIVE_MAJOR",
"totalCredit" : 70,
"takenCredit" : 40,
"completed": false
"category": "CORE_CULTURE",
"totalCredit": 12,
"takenCredit": 12.0,
"completed": true
},
{
"category": "SUB_MAJOR",
"totalCredit" : 70,
"takenCredit" : 40,
"category": "PRIMARY_BASIC_ACADEMICAL_CULTURE",
"totalCredit": 18,
"takenCredit": 15.0,
"completed": false
},
{
"category": "PRIMARY_BASIC_ACADEMICAL_CULTURE",
"totalCredit" : 70,
"takenCredit" : 40,
"category": "COMMON_CULTURE",
"totalCredit": 17,
"takenCredit": 16.5,
"completed": false
},
{
"category": "DUAL_BASIC_ACADEMICAL_CULTURE",
"totalCredit" : 70,
"takenCredit" : 40,
"completed": false
"category": "PRIMARY_MANDATORY_MAJOR",
"totalCredit": 18,
"takenCredit": 18.0,
"completed": true
},
{
"category": "NORMAL_CULTURE",
"totalCredit" : 70,
"takenCredit" : 40,
"category": "DUAL_ELECTIVE_MAJOR",
"totalCredit": 24,
"takenCredit": 0.0,
"completed": false
},
{
"category": "FREE_ELECTIVE",
"totalCredit" : 70,
"takenCredit" : 40,
"category": "CHAPEL",
"totalCredit": 2,
"takenCredit": 1.5,
"completed": false
},
{
"category": "CHAPEL",
"totalCredit" : 4,
"takenCredit" : 1,
"category": "SUB_MAJOR",
"totalCredit" : 70,
"takenCredit" : 40,
"completed": false
}
]`);
Expand Down
11 changes: 6 additions & 5 deletions app/ui/result/result-category-card/result-category-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ function ResultCategoryCard({ category, totalCredit, takenCredit }: ResultCatego
setIsOpenDialog(true);
};

const getCategoryCredit = (category: ResultCategoryKey, credit: number): number => {
return category === RESULT_CATEGORY.CHAPEL ? credit * 2 : credit;
};
const getCategoryCredit = (category: ResultCategoryKey, credit: number) =>
category === RESULT_CATEGORY.CHAPEL ? credit * 2 : credit;

const getCategoryCountWay = (category: ResultCategoryKey) => (category === RESULT_CATEGORY.CHAPEL ? 'ํšŸ์ˆ˜' : 'ํ•™์ ');

const filterCategoryExistStandard = (category: ResultCategoryKey) => {
const NONEXIST_STANDARD_CATEGORY = ['FREE_ELECTIVE', 'NORMAL_CULTURE', 'CHAPEL'];
Expand All @@ -96,11 +97,11 @@ function ResultCategoryCard({ category, totalCredit, takenCredit }: ResultCatego
<div className={cn('w-full flex text-xs font-medium justify-between items-end', 'md:gap-4 md:text-base')}>
<div>
<div className="flex gap-2">
<span>๊ธฐ์ค€ํ•™์ </span>
<span>๊ธฐ์ค€{getCategoryCountWay(category)}</span>
<span className="font-bold">{getCategoryCredit(category, totalCredit)}</span>
</div>
<div className="flex gap-2">
<span>์ด์ˆ˜ํ•™์ </span>
<span>์ด์ˆ˜{getCategoryCountWay(category)}</span>
<span className={cn('font-bold', percentage === 100 ? 'text-point-blue' : 'text-etc-red')}>
{getCategoryCredit(category, takenCredit)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ export default function ResultCategoryDetailContentSkeleton() {
</div>
<Skeleton className="h-10 w-28" />
</div>
{Array.from({ length: 3 }).map((_, index) => (
<div className="my-4 flex flex-col gap-4" key={index}>
<LabelContainerSkeleton rightElement={<Skeleton className="h-10 w-28" />} />
<Skeleton className="h-40 w-30" />
</div>
))}
<div className="my-4 flex flex-col gap-4">
<LabelContainerSkeleton rightElement={<Skeleton className="h-10 w-28" />} />
<Skeleton className="h-40 w-30" />
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useState } from 'react';
import { ResultCategoryDetailLectureToggle } from '../result-category-detail-lecture/result-category-detail-lecture-toggle';
import ResultCagegoryDetailLecture from '../result-category-detail-lecture/result-cagegory-detail-lecture';
import { ResultCategoryDetailResponse } from '@/app/store/querys/result';
import { RESULT_CATEGORY_KO, ResultCategoryKey } from '@/app/utils/key/result-category.key';
import { RESULT_CATEGORY, RESULT_CATEGORY_KO, ResultCategoryKey } from '@/app/utils/key/result-category.key';

interface ResultCategoryDetailContentProps extends ResultCategoryDetailResponse {
category: ResultCategoryKey;
Expand All @@ -19,12 +19,14 @@ function ResultCategoryDetailContent({
}: ResultCategoryDetailContentProps) {
const [isTakenLecture, setIsTakenLectrue] = useState(false);

const includeChaple = (category: ResultCategoryKey) => category === RESULT_CATEGORY.COMMON_CULTURE;

return (
<div className="md:w-[80vw] max-w-[1200px] p-2 overflow-scroll">
<div className={cn('flex justify-between mb-6', 'md:mb-10')}>
<div>
<h1 className={cn('text-2xl font-bold', 'md:text-4xl')}>{RESULT_CATEGORY_KO[category]}</h1>
<div className={cn('relative flex items-center gap-2 text-sm text-gray-6 font-medium my-2', 'md:text-lg')}>
<div className={cn('relative flex items-center gap-2 text-sm text-gray-6 font-medium my-2', 'md:text-lg')}>
<span className="hidden md:block"> {RESULT_CATEGORY_KO[category]} ๊ณผ๋ชฉ ์ค‘</span>
<div className="w-20 h-10">
<ResultCategoryDetailLectureToggle
Expand All @@ -37,11 +39,15 @@ function ResultCategoryDetailContent({
</div>
<span>๊ณผ๋ชฉ์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.</span>
</div>
<div className={includeChaple(category) ? 'font-light text-gray-5 text-xs my-2 md:text-sm' : 'hidden'}>
* ์ฑ„ํ”Œ์ด ํฌํ•จ๋œ ํ•™์ ์œผ๋กœ, ์ฑ„ํ”Œ๊ณผ๋ชฉ์˜ ์ด์ˆ˜์œจ์€ ์ฑ„ํ”Œ ์นดํ…Œ๊ณ ๋ฆฌ์—์„œ ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
</div>
</div>
<div className={cn('text-2xl font-bold', 'md:text-4xl')}>
<div className={cn('min-w-fit text-2xl font-bold', 'md:text-4xl')}>
<span className="text-point-blue">{takenCredit}</span> / {totalCredit}
</div>
</div>

{detailCategory.map((categoryInfo, index) => (
<ResultCagegoryDetailLecture isTakenLecture={isTakenLecture} detailCategory={categoryInfo} key={index} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import AnnounceMessageBox from '@/app/ui/view/molecule/announce-message-box/anno
import LabelContainer from '@/app/ui/view/atom/label-container/label-container';
import { cn } from '@/app/utils/shadcn/utils';
import { ResultCategoryDetailLecturesResponse } from '@/app/store/querys/result';
import CompletedImage from '@/public/assets/completed-category.png';
import Image from 'next/image';
import searchResultIcon from '@/public/assets/searchResultIcon.svg';

const headerInfo = ['๊ณผ๋ชฉ์ฝ”๋“œ', '๊ณผ๋ชฉ๋ช…', 'ํ•™์ '];

Expand All @@ -11,6 +14,17 @@ interface ResultCagegoryDetailLectureProps {
isTakenLecture: boolean;
}

const emptyDataRender = () => {
return (
<div className="flex justify-center gap-4 p-6 md:p-12">
<Image src={searchResultIcon} alt="search-result-icon" width={20} height={20} />
<span className="text-sm font-medium text-gray-400 text-center whitespace-pre-wrap md:text-base">
์ด์ˆ˜ํ•œ ๊ณผ๋ชฉ ์ •๋ณด๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
</span>
</div>
);
};

function ResultCagegoryDetailLecture({ detailCategory, isTakenLecture }: ResultCagegoryDetailLectureProps) {
const { categoryName, totalCredit, takenCredit, takenLectures, haveToLectures, completed } = detailCategory;

Expand All @@ -27,9 +41,13 @@ function ResultCagegoryDetailLecture({ detailCategory, isTakenLecture }: ResultC
}
/>
{showCompleted ? (
<AnnounceMessageBox message="ํ•ด๋‹น ํŒŒํŠธ์˜ ์กธ์—…์š”๊ฑด์„ ์ถฉ์กฑํ•˜์…จ์Šต๋‹ˆ๋‹ค!" />
<AnnounceMessageBox message="ํ•ด๋‹น ํŒŒํŠธ์˜ ์กธ์—…์š”๊ฑด์„ ์ถฉ์กฑํ•˜์…จ์Šต๋‹ˆ๋‹ค!" background_image={CompletedImage} />
) : (
<Table headerInfo={headerInfo} data={isTakenLecture ? takenLectures : haveToLectures} />
<Table
headerInfo={headerInfo}
data={isTakenLecture ? takenLectures : haveToLectures}
emptyDataRender={emptyDataRender}
/>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ResultCategoryDetailLectureToggle = React.forwardRef<
>(({ className, ...props }, ref) => (
<SwitchPrimitives.Root
className={cn(
'relative peer p-1 inline-flex h-10 w-20 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 focus-visible:ring-offset-white disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-slate-200 ',
'relative peer p-1 inline-flex h-10 w-20 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-slate-200',
className,
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion app/ui/user/find-password-from/find-password-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function FindPasswordForm({ authId }: FindPasswordFormProps) {
};

return (
<Form id="๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •" action={resetPassword} onSuccess={onSuccess}>
<Form id="๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ •" action={resetPassword} onSuccess={onSuccess} className="flex flex-col gap-4">
<Form.PasswordInput
required={true}
label="๋น„๋ฐ€๋ฒˆํ˜ธ"
Expand Down
16 changes: 7 additions & 9 deletions app/ui/user/find-password-from/find-password-validate-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ interface FindPasswordValidateFormProps {
}
function FindPasswordValidateForm({ onNext }: FindPasswordValidateFormProps) {
return (
<div>
<Form id="๊ฐ€์ž…์ž ๊ฒ€์ฆ" onSuccess={onNext} action={validateUser}>
<Form.TextInput required={true} label="์•„์ด๋””" id="authId" placeholder="์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”." />
<Form.TextInput required={true} label="ํ•™๋ฒˆ" id="studentNumber" placeholder="ex ) 60xxxxxx" />
<div className="py-6">
<Form.SubmitButton label="๊ฒ€์‚ฌํ•˜๊ธฐ" position="center" variant="primary" />
</div>
</Form>
</div>
<Form id="๊ฐ€์ž…์ž ๊ฒ€์ฆ" onSuccess={onNext} action={validateUser} className="flex flex-col gap-4">
<Form.TextInput required={true} label="์•„์ด๋””" id="authId" placeholder="์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”." />
<Form.TextInput required={true} label="ํ•™๋ฒˆ" id="studentNumber" placeholder="ex ) 60xxxxxx" />
<div className="py-6">
<Form.SubmitButton label="๊ฒ€์‚ฌํ•˜๊ธฐ" position="center" variant="primary" />
</div>
</Form>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import React from 'react';
import CompletedImage from '@/public/assets/completed-category.png';
import CheckImage from '@/public/assets/check.svg';
import Image from 'next/image';
import { cn } from '@/app/utils/shadcn/utils';
import { StaticImport } from 'next/dist/shared/lib/get-img-props';

interface AnnounceMessageBoxProp {
message: string;
background_image?: string | StaticImport;
}

function AnnounceMessageBox({ message }: AnnounceMessageBoxProp) {
function AnnounceMessageBox({ message, background_image }: AnnounceMessageBoxProp) {
return (
<div className="relative flex justify-center items-center p-2 bg-yellow-5">
<Image
src={CompletedImage}
width={1200}
height={270}
alt="category-fullfill-image"
className={cn('min-h-20 max-h-40', 'md:min-h-32')}
/>
<div className="relative flex justify-center items-center p-2 bg-gray-1 min-h-24 rounded-3xl">
{background_image && (
<Image
src={background_image}
width={1200}
height={270}
alt="announcebox_background_image"
className={cn('min-h-20 max-h-40', 'md:min-h-32')}
/>
)}
<div className="absolute">
<Image
className={cn('m-auto w-[30px]', 'md:w-[50px]')}
Expand Down
7 changes: 3 additions & 4 deletions app/ui/view/molecule/pie-chart/pie-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ export interface PieChartProp {
}

function PieChart({ percentage }: PieChartProp) {
const filterdPercentage = percentage > 100 ? 100 : percentage;

const isDesktop = useMediaQuery('(min-width: 767px)');

return (
<div
className={cn(
'piechart relative aspect-square rounded-full w-[6.5rem] h-[6.5rem]',
'relative aspect-square rounded-full w-[6.5rem] h-[6.5rem]',
percentage > 0 && 'piechart',
percentage === 100 ? 'bg-light-blue-1 complete' : 'bg-etc-pink',
'md:w-[9rem] md:h-[9rem]',
)}
Expand All @@ -33,7 +32,7 @@ function PieChart({ percentage }: PieChartProp) {
'md:w-[6rem] md:h-[6rem] md:text-xl ',
)}
>
{filterdPercentage}%
{percentage}%
</div>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion app/ui/view/molecule/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import List from '../list';
import Grid from '../grid';
import { ListRow } from '../list/list-root';
import SwipeToDelete from '../swipe/swipe-to-delete';
import { ReactNode } from 'react';

interface TableProps<T extends ListRow> {
headerInfo: string[];
data: T[];
renderActionButton?: (id: number) => JSX.Element;
swipeable?: boolean;
emptyDataRender?: () => ReactNode;
}

interface SwipeableTableProps<T extends ListRow> extends TableProps<T> {
Expand All @@ -35,6 +37,7 @@ export function Table<T extends ListRow>({
renderActionButton,
swipeable = false,
onSwipeAction,
emptyDataRender,
}: SwipeableTableProps<T> | BasicTableProps<T>) {
const cols = renderActionButton && !swipeable ? 'render-button' : headerInfo.length;

Expand Down Expand Up @@ -75,7 +78,7 @@ export function Table<T extends ListRow>({
return (
<div className="flex flex-col gap-2.5 w-full" data-testid="table-data">
<TableHeader headerInfo={headerInfo} cols={isCol(cols) ? cols : 6} />
<List data={data} render={swipeable ? swipeableRender : render} />
<List data={data} render={swipeable ? swipeableRender : render} emptyDataRender={emptyDataRender} />
</div>
);
}
Loading
Loading