-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
188 additions
and
32 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,32 @@ | ||
'use client'; | ||
import { useEffect } from 'react'; | ||
import Link from 'next/link'; | ||
|
||
export default function Error({ error, reset }: { error: Error; reset: () => void }) { | ||
useEffect(() => { | ||
console.error(error); | ||
}, [error]); | ||
|
||
if (error.message === 'Unauthorized') { | ||
return ( | ||
<div> | ||
<h2>Unauthorized</h2> | ||
<Link href="/sign-in">to Login</Link> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div> | ||
<h2>Something went wrong!!!!!</h2> | ||
<button | ||
onClick={ | ||
// 세그먼트를 재 렌더링 하여 복구를 시도합니다. | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</button> | ||
</div> | ||
); | ||
} |
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,14 +1,21 @@ | ||
import LectureSearch from '@/app/ui/lecture/lecture-search'; | ||
import TakenLecture from '@/app/ui/lecture/taken-lecture'; | ||
import ContentContainer from '@/app/ui/view/atom/content-container'; | ||
import Drawer from '@/app/ui/view/molecule/drawer/drawer'; | ||
import { DIALOG_KEY } from '@/app/utils/key/dialog.key'; | ||
|
||
export default function MyPage() { | ||
return ( | ||
<ContentContainer className="flex"> | ||
<div className="hidden lg:w-[30%] lg:block">정보칸</div> | ||
<div className="w-full lg:w-[70%] lg:px-[20px]"> | ||
<TakenLecture /> | ||
</div> | ||
</ContentContainer> | ||
<> | ||
<ContentContainer className="flex"> | ||
<div className="hidden lg:w-[30%] lg:block">정보칸</div> | ||
<div className="w-full lg:w-[70%] lg:px-[20px]"> | ||
<TakenLecture /> | ||
</div> | ||
</ContentContainer> | ||
<Drawer drawerKey={DIALOG_KEY.LECTURE_SEARCH}> | ||
<LectureSearch /> | ||
</Drawer> | ||
</> | ||
); | ||
} |
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,15 @@ | ||
import { API_PATH } from '@/app/business/api-path'; | ||
import { httpErrorHandler } from '@/app/utils/http/http-error-handler'; | ||
|
||
async function trigger() { | ||
const response = await fetch(`${API_PATH.auth}/failure`, { | ||
cache: 'no-store', | ||
}); | ||
const result = await response.json(); | ||
httpErrorHandler(response, result); | ||
} | ||
|
||
export default async function ProtectedPage() { | ||
const data = await trigger(); | ||
return <div>Auth protected</div>; | ||
} |
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,27 @@ | ||
'use client'; | ||
import { useEffect } from 'react'; | ||
|
||
// https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-errors-in-root-layouts | ||
// global-error는 프로덕션에서만 활성화 | ||
export default function GlobalError({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) { | ||
useEffect(() => { | ||
// Log the error to an error reporting service | ||
console.error(error); | ||
}, [error]); | ||
|
||
return ( | ||
<html> | ||
<body> | ||
<h2>Something went wrong!!!!!</h2> | ||
<button | ||
onClick={ | ||
// 세그먼트를 재 렌더링 하여 복구를 시도합니다. | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</button> | ||
</body> | ||
</html> | ||
); | ||
} |
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
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
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,45 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { expect, userEvent, within } from '@storybook/test'; | ||
import { mockDatabase, resetMockDB } from '@/app/mocks/db.mock'; | ||
import TakenLectureList from './taken-lecture-list'; | ||
import TakenLectureAtomHydrator from '@/app/store/taken-lecture-atom-hydrator'; | ||
import { screen } from '@storybook/testing-library'; | ||
import { delay } from 'msw'; | ||
|
||
const meta = { | ||
title: 'ui/taken-lecture/TakenLecture', | ||
component: TakenLectureList, | ||
decorators: [ | ||
(Story) => { | ||
resetMockDB(); | ||
const data = mockDatabase.getTakenLectures(); | ||
return ( | ||
<TakenLectureAtomHydrator initialValue={data.takenLectures}> | ||
<Story /> | ||
</TakenLectureAtomHydrator> | ||
); | ||
}, | ||
], | ||
} as Meta<typeof TakenLectureList>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const DeleteSenario: Story = { | ||
play: async ({ step }) => { | ||
await step('사용자가 삭제를 클릭하면 alert창이 보여진다', async () => { | ||
const deleteButton = await screen.findAllByTestId('taken-lecture-delete-button'); | ||
await userEvent.click(deleteButton[0]); | ||
|
||
expect(screen.getByText('과목을 삭제하시겠습니까?')).toBeInTheDocument(); | ||
}); | ||
await step('확인 버튼을 클릭하면 과목이 삭제된다', async () => { | ||
const confirmButton = await screen.findAllByTestId('confirm-button'); | ||
await userEvent.click(confirmButton[0]); | ||
|
||
await delay(3000); | ||
|
||
expect(screen.queryByText('인공지능')).not.toBeInTheDocument(); | ||
}); | ||
}, | ||
}; |
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
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,6 +1,7 @@ | ||
export const DIALOG_KEY = { | ||
RESULT_CATEGORY: 'RESULT_CATEGORY', | ||
DIALOG_TEST: 'DIALOG_TEST', | ||
LECTURE_SEARCH: 'LECTURE_SEARCH', | ||
} as const; | ||
|
||
export type DialogKey = (typeof DIALOG_KEY)[keyof typeof DIALOG_KEY]; |