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

Drawer&router history/#104 #106

Merged
merged 8 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/hooks/useDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ export default function useDialog(key: DialogKey, onClose?: () => void) {
setOpenDialogList([key, true]);
};

const close = () => {
setOpenDialogList([key, false]);
onClose?.();
};

const toggle = () => {
const prevState = isOpenDialogList[key];
setOpenDialogList([key, !prevState]);

if (prevState) onClose?.();
};

return { isOpen, open, close, toggle };
return { isOpen, open, toggle };
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Button from '../../view/atom/button/button';
import { getPercentage } from '@/app/utils/chart.util';
import PieChart from '../../view/molecule/pie-chart/pie-chart';
import Responsive from '../../responsive';
import { useMediaQuery } from 'usehooks-ts';

interface ResultCategoryCardProps {
category: ResultCategoryKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function ResultCategorySkeleton() {
<div
className={cn('absolute grid grid-cols-2 gap-2 top-[30rem] w-full', 'md:max-w-[700px] md:gap-10 md:top-[33rem]')}
>
{Array.from({ length: 3 }).map((_, index) => (
{Array.from({ length: 4 }).map((_, index) => (
<ResultCategoryCardSkeleton key={index} />
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/ui/user/user-info-card/user-info-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function UserInfoCard() {
}

function renderUserInfo(data: UserInfoResponse | InitUserInfoResponse) {
isInitUser(data) ? <InitUserAnnounce /> : <UserInfoContent data={data} />;
return isInitUser(data) ? <InitUserAnnounce /> : <UserInfoContent data={data} />;
}

return <>{renderUserInfo(data)}</>;
Expand Down
4 changes: 3 additions & 1 deletion app/ui/user/user-info-card/user-info-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ interface UserInfoContentProps {
function UserInfoContent({ data }: UserInfoContentProps) {
const { studentNumber, studentName, completionDivision: majors, totalCredit, takenCredit, graduated } = data;

const percentage = getPercentage(takenCredit, totalCredit);

const displaySeveralMajor = (notation: 'major' | 'title'): React.ReactNode => {
return majors.map((major, index) => {
const { major: majorName, majorType } = major;
Expand Down Expand Up @@ -44,7 +46,7 @@ function UserInfoContent({ data }: UserInfoContentProps) {
</ul>
</div>
<div className="mr-[10%]">
<PieChart percentage={getPercentage(takenCredit, totalCredit)} />
<PieChart percentage={percentage} />
</div>
</div>
<p className="text-gray-6 md:text-xs text-[10px]">
Expand Down
6 changes: 3 additions & 3 deletions app/ui/view/molecule/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ interface DrawerProps extends React.PropsWithChildren {
}

const Drawer = ({ children, drawerKey, onClose, className }: DrawerProps) => {
const { isOpen, close } = useDialog(drawerKey, onClose);
const { isOpen, toggle } = useDialog(drawerKey, onClose);

return (
<DrawerPrimitive.Root open={isOpen} onClose={close}>
<DrawerPrimitive.Root open={isOpen} onRelease={toggle}>
<DrawerPrimitive.Portal>
<DrawerPrimitive.Overlay
onClick={close}
onClick={toggle}
className="fixed inset-0 z-50 bg-black/60"
data-testid="drawer-overlay"
/>
Expand Down
Loading