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

Add/#83/service guide(swm 344) #84

Merged
merged 8 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1,484 changes: 1,484 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
"framer-motion": "^10.12.18",
"next": "13.4.7",
"next-auth": "^4.22.1",
"notion-client": "^6.16.0",
"postcss": "8.4.24",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hot-toast": "^2.4.1",
"react-loading-skeleton": "^3.3.1",
"react-notion-x": "^6.16.0",
"react-simplemde-editor": "^5.2.0",
"react-youtube": "^10.1.0",
"sharp": "^0.32.6",
Expand Down
4 changes: 2 additions & 2 deletions src/app/@modal/(.)search/[lecture_code]/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useAuth from '@/src/hooks/useAuth';
import setErrorToast from '@/src/util/toast/setErrorToast';
import { useRouter } from 'next/navigation';

export default async function ErrorHandler({
export default function ErrorHandler({
error,
reset
}: {
Expand All @@ -19,7 +19,7 @@ export default async function ErrorHandler({
router.back();
} else if (error.cause === SESSION_ERROR) {
setErrorToast(error);
await logout();
logout();
} else {
setErrorToast(new Error(ErrorMessage.DEFAULT));
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/dashboard/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useAuth from '@/src/hooks/useAuth';
import setErrorToast from '@/src/util/toast/setErrorToast';
import { useRouter } from 'next/navigation';

export default async function ErrorHandler({
export default function ErrorHandler({
error,
reset
}: {
Expand All @@ -22,7 +22,7 @@ export default async function ErrorHandler({
setErrorToast(error);
} else if (error.cause === SESSION_ERROR) {
setErrorToast(error);
await logout();
logout();
} else {
setErrorToast(new Error(ErrorMessage.DEFAULT));
}
Expand Down
22 changes: 16 additions & 6 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import { fetchDashboardInfo } from '@/src/api/dashboards/dashboards';
import DashboardHeader from '@/src/components/dashboard/header/DashboardHeader';
import ServiceGuideModal from '@/src/components/dashboard/header/ServiceGuideModal';
import LatestLearningCoursesList from '@/src/components/dashboard/latestLearning/LatestLearningCoursesList';
import MainDashboard from '@/src/components/dashboard/main/MainDashboard';
import LectureRecommendationsList from '@/src/components/recommendations/LectureRecommendationsList';
import { SERVICE_GUIDE } from '@/src/constants/serviceGuides/serviceGuides';
import { NotionAPI } from 'notion-client';
import { ExtendedRecordMap } from 'notion-types';

export const metadata = {
title: '๋Œ€์‹œ๋ณด๋“œ',
title: '๋Œ€์‹œ๋ณด๋“œ'
};

export default async function Dashboard() {
const notion = new NotionAPI();
const recordMapList: ExtendedRecordMap[] = await Promise.all(
SERVICE_GUIDE.map((service) => notion.getPage(service.key))
);
const dashboardInfo = await fetchDashboardInfo();

const latestLearningCourses = dashboardInfo.latest_lectures;
const isEnrolled = latestLearningCourses.length > 0;
const isExistingUser = latestLearningCourses.length > 0;

return (
<div>
<DashboardHeader isEnrolled={isEnrolled} />
<div className='w-full'>
<DashboardHeader
isExistingUser={isExistingUser}
recordMapList={recordMapList}
/>
<MainDashboard dashboardInfo={dashboardInfo} />
{isEnrolled && (
{isExistingUser && (
<LatestLearningCoursesList
latestLearningCourses={latestLearningCourses}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../api/ErrorMessage';
import useAuth from '../hooks/useAuth';

export default async function ErrorHandler({
export default function ErrorHandler({
error,
reset
}: {
Expand All @@ -23,7 +23,7 @@ export default async function ErrorHandler({
router.back();
} else if (error.cause === SESSION_ERROR) {
setErrorToast(error);
await logout();
logout();
} else {
setErrorToast(new Error(ErrorMessage.DEFAULT));
}
Expand Down
5 changes: 2 additions & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import NaverAnalytics from '../components/tools/NaverAnalytics/NaverAnalytics';
const inter = Inter({ subsets: ['latin'] });

export const metadata = {
metadataBase: new URL('https://sroom.kr'),
title: {
template: '%s | ์Šค๋ฃธ',
default: '์Šค๋ฃธ'
Expand All @@ -23,10 +24,8 @@ export const metadata = {
title: '์Šค๋ฃธ',
description: '๋‚˜๋งŒ์„ ์œ„ํ•œ ์œ ํŠœ๋ธŒ ๊ฐ•์˜ ๊ด€๋ฆฌ ํ”Œ๋žซํผ ์Šค๋ฃธ',
type: 'website',
locale: 'ko_KR',
url: 'https://sroom.kr',
images: {
url: 'https://sroom.kr/image/opengraph/opengraph-image.jpg',
url: '/image/opengraph/opengraph-image.jpg',
width: 1200,
height: 630,
alt: '๋‚˜๋งŒ์„ ์œ„ํ•œ ์œ ํŠœ๋ธŒ ๊ฐ•์˜ ๊ด€๋ฆฌ ํ”Œ๋žซํผ, ์Šค๋ฃธ'
Expand Down
4 changes: 2 additions & 2 deletions src/app/search/[lecture_code]/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useAuth from '@/src/hooks/useAuth';
import setErrorToast from '@/src/util/toast/setErrorToast';
import { useRouter } from 'next/navigation';

export default async function ErrorHandler({
export default function ErrorHandler({
error,
reset
}: {
Expand All @@ -24,7 +24,7 @@ export default async function ErrorHandler({
router.refresh();
} else if (error.cause === SESSION_ERROR) {
setErrorToast(error);
await logout();
logout();
} else {
setErrorToast(new Error(ErrorMessage.DEFAULT));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function CourseMaterialContent({
}
);
return (
<div className='w-full h-full max-h-full px-3 overflow-y-scroll'>
<div className='h-full max-w-full max-h-full min-w-full px-3 overflow-y-scroll'>
<div className='sticky top-0 z-10'>
<CourseMaterialTopNav
activeTab={activeTab}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function CourseMaterialLectureNotes({
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
className={`w-full my-10 flex flex-col justify-center items-center gap-10 overflow-x-scroll`}
className={`min-w-full max-w-full my-10 flex flex-col justify-center items-center gap-10 overflow-x-scroll`}
>
<div>
{isEditMode ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function CourseMaterialQuizzes({
return (
<AnimatePresence>
<div
className={`w-full my-10 flex flex-col justify-center items-between gap-10`}
className={`min-w-full max-w-full my-10 flex flex-col justify-center items-between gap-10`}
>
{quizzes?.map((quiz, idx) => {
const selectedAnswer = selectedAnswerList.find(
Expand Down
144 changes: 92 additions & 52 deletions src/components/dashboard/header/DashboardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
'use client';
import Image from 'next/image';
import GuideBox from './GuideBox';
import { showModalHandler } from '@/src/util/modal/modalHandler';
import ServiceGuideModal from './ServiceGuideModal';
import { ExtendedRecordMap } from 'notion-types';
import { useState } from 'react';
import { SERVICE_GUIDE } from '@/src/constants/serviceGuides/serviceGuides';

type Props = {
isEnrolled: boolean;
isExistingUser: boolean;
recordMapList: ExtendedRecordMap[];
};

export default function DashboardHeader({ isEnrolled }: Props) {
if (isEnrolled) {
export default function DashboardHeader({
isExistingUser,
recordMapList
}: Props) {
const [selectedGuide, setSelectedGuide] = useState<number>(0);

const boxClickHandler = (service: (typeof SERVICE_GUIDE)[number]['type']) => {
const idx = SERVICE_GUIDE.findIndex((guide) => guide.type === service);
setSelectedGuide(() => idx);
showModalHandler('SERVICE_GUIDE');
};

if (isExistingUser) {
return (
<section className='px-4 mx-auto lg:px-24 pt-14 text-sroom-black-400 max-w-screen-2xl'>
<h2 className='text-2xl font-bold md:text-3xl lg:text-4xl md:mb-2 lg:mb-3'>
Expand All @@ -19,58 +37,80 @@ export default function DashboardHeader({ isEnrolled }: Props) {
);
} else {
return (
<div className='bg-sroom-gray-200 h-[23rem] lg:h-[36rem] text-sroom-black-400'>
<section className='flex flex-col justify-between h-full px-4 pt-12 mx-auto lg:px-24 lg:pt-20 max-w-screen-2xl'>
<div className='flex flex-col items-center'>
<h2 className='mb-5 text-3xl font-bold md:text-4xl lg:text-5xl'>๋ฐ˜๊ฐ€์›Œ์š”!</h2>
<h3 className='flex flex-col items-center text-base font-normal md:text-lg text-sroom-black-200'>
<p>์œ ํŠœ๋ธŒ์— ์ €์žฅ๋งŒ ํ•ด๋†จ๋˜ ๊ฐ•์˜, ๋“ฃ๋‹ค๊ฐ€ ์ค‘๊ฐ„์— ํฌ๊ธฐํ•ด๋ฒ„๋ฆฐ ๊ฐ•์˜</p>
<p>์ด์   ์Šค๋ฃธ๊ณผ ํ•จ๊ป˜ ์ฒด๊ณ„์ ์œผ๋กœ ํ•™์Šต์„ ์‹œ์ž‘ํ•ด ๋ณด์„ธ์š”!</p>
</h3>
</div>
<div className='flex items-end justify-between w-full gap-7'>
<GuideBox title='์Šค๋งˆํŠธํ•œ' description='์œ ํŠœ๋ธŒ ๊ฐ•์˜ ๊ฒ€์ƒ‰๏ฝฅ์ถ”์ฒœ'>
<div className='absolute bottom-4 right-4 lg:bottom-7 lg:right-7 w-[47%]'>
<div className='pb-[38.88%] relative object-cover'>
<Image
className='transition-all lg:opacity-0 group-hover:opacity-100 group-hover:-translate-y-2'
src={'/image/dashboard/search.webp'}
alt='๊ฒ€์ƒ‰์ฐฝ'
fill={true}
quality={100}
/>
<>
<div className='bg-sroom-gray-200 h-[23rem] lg:h-[36rem] text-sroom-black-400'>
<section className='flex flex-col justify-between h-full px-4 pt-12 mx-auto lg:px-24 lg:pt-20 max-w-screen-2xl'>
<div className='flex flex-col items-center'>
<h2 className='mb-3 text-3xl font-bold md:mb-5 lg:mb-10 md:text-4xl lg:text-5xl'>
๋ฐ˜๊ฐ€์›Œ์š”!
</h2>
<h3 className='flex flex-col items-center text-base font-normal md:text-lg text-sroom-black-200'>
<p>
์œ ํŠœ๋ธŒ์— ์ €์žฅ๋งŒ ํ•ด๋†จ๋˜ ๊ฐ•์˜, ๋“ฃ๋‹ค๊ฐ€ ์ค‘๊ฐ„์— ํฌ๊ธฐํ•ด๋ฒ„๋ฆฐ ๊ฐ•์˜
</p>
<p>์ด์   ์Šค๋ฃธ๊ณผ ํ•จ๊ป˜ ์ฒด๊ณ„์ ์œผ๋กœ ํ•™์Šต์„ ์‹œ์ž‘ํ•ด ๋ณด์„ธ์š”!</p>
<p className='mt-3 text-xs md:mt-4 lg:mt-7 md:text-sm text-sroom-black-100'>
์•„๋ž˜ ์„น์…˜์„ ํด๋ฆญํ•˜๋ฉด ์Šค๋ฃธ์˜ ์„œ๋น„์Šค ์ด์šฉ ๊ฐ€์ด๋“œ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์–ด์š”
</p>
</h3>
</div>
<div className='flex items-end justify-between w-full gap-7'>
<GuideBox
title='์Šค๋งˆํŠธํ•œ'
description='์œ ํŠœ๋ธŒ ๊ฐ•์˜ ๊ฒ€์ƒ‰๏ฝฅ์ถ”์ฒœ'
onClick={() => boxClickHandler('SEARCH')}
>
<div className='absolute bottom-4 right-4 lg:bottom-7 lg:right-7 w-[47%]'>
<div className='pb-[38.88%] relative object-cover'>
<Image
className='transition-all lg:opacity-0 group-hover:opacity-100 group-hover:-translate-y-2'
src={'/image/dashboard/search.webp'}
alt='๊ฒ€์ƒ‰์ฐฝ'
fill={true}
quality={100}
/>
</div>
</div>
</div>
</GuideBox>
<GuideBox title='์ฒด๊ณ„์ ์ธ' description='ํ•™์Šต ์ผ์ • ๊ด€๋ฆฌ'>
<div className='absolute bottom-4 right-4 lg:bottom-7 lg:right-7 w-[43%]'>
<div className='pb-[56.62%] relative object-cover'>
<Image
className='transition-all lg:opacity-0 group-hover:opacity-100 group-hover:-translate-y-2'
src={'/image/dashboard/calendar.webp'}
alt='๋‹ฌ๋ ฅ'
fill={true}
quality={100}
/>
</GuideBox>
<GuideBox
title='์ฒด๊ณ„์ ์ธ'
description='ํ•™์Šต ์ผ์ • ๊ด€๋ฆฌ'
onClick={() => boxClickHandler('SCHEDULING')}
>
<div className='absolute bottom-4 right-4 lg:bottom-7 lg:right-7 w-[43%]'>
<div className='pb-[56.62%] relative object-cover'>
<Image
className='transition-all lg:opacity-0 group-hover:opacity-100 group-hover:-translate-y-2'
src={'/image/dashboard/calendar.webp'}
alt='๋‹ฌ๋ ฅ'
fill={true}
quality={100}
/>
</div>
</div>
</div>
</GuideBox>
<GuideBox title='์ชฝ์ง‘๊ฒŒ AI๊ฐ€ ์ƒ์„ฑํ•œ' description='ํ€ด์ฆˆ๏ฝฅ์š”์•ฝ๋ณธ'>
<div className='absolute bottom-4 right-4 lg:bottom-7 lg:right-7 w-[42%]'>
<div className='pb-[46.30%] relative object-cover'>
<Image
className='transition-all lg:opacity-0 group-hover:opacity-100 group-hover:-translate-y-2'
src={'/image/dashboard/quiz.webp'}
alt='ํ€ด์ฆˆ'
fill={true}
quality={100}
/>
</GuideBox>
<GuideBox
title='์ชฝ์ง‘๊ฒŒ AI๊ฐ€ ์ƒ์„ฑํ•œ'
description='ํ€ด์ฆˆ๏ฝฅ์š”์•ฝ๋ณธ'
onClick={() => boxClickHandler('MATERIALS')}
>
<div className='absolute bottom-4 right-4 lg:bottom-7 lg:right-7 w-[42%]'>
<div className='pb-[46.30%] relative object-cover'>
<Image
className='transition-all lg:opacity-0 group-hover:opacity-100 group-hover:-translate-y-2'
src={'/image/dashboard/quiz.webp'}
alt='ํ€ด์ฆˆ'
fill={true}
quality={100}
/>
</div>
</div>
</div>
</GuideBox>
</div>
</section>
</div>
</GuideBox>
</div>
</section>
</div>
<ServiceGuideModal recordMap={recordMapList[selectedGuide]} />
</>
);
}
}
6 changes: 4 additions & 2 deletions src/components/dashboard/header/GuideBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import ArrowRightSVG from '@/public/icon/ArrowRight';
export default function GuideBox({
title,
description,
onClick,
children
}: {
title: string;
description: string;
onClick?: () => void;
children?: React.ReactNode;
}) {
return (
<div className='relative flex-1 h-[9.5rem] lg:h-40 hover:cursor-pointer lg:hover:h-[17rem] p-4 lg:p-7 transition-all bg-white hover:bg-gradient-to-b from-[#222222] to-sroom-black-300 hover:text-white shadow-[0_-2px_5px_1px_rgba(173,173,173,0.3)] text-sroom-black-400 group'>
<button type='button' onClick={onClick} className='flex flex-col relative flex-1 h-[9.5rem] lg:h-40 hover:cursor-pointer lg:hover:h-[17rem] p-4 lg:p-7 transition-all bg-white hover:bg-gradient-to-b from-[#222222] to-sroom-black-300 hover:text-white shadow-[0_-2px_5px_1px_rgba(173,173,173,0.3)] text-sroom-black-400 group'>
<p className='mb-1 text-xs font-normal lg:text-lg'>{title}</p>
<div className='flex items-center gap-2'>
<p className='text-base font-bold lg:text-2xl'>{description}</p>
Expand All @@ -19,6 +21,6 @@ export default function GuideBox({
</span>
</div>
<div>{children}</div>
</div>
</button>
);
}
30 changes: 30 additions & 0 deletions src/components/dashboard/header/ServiceGuideModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client';
import { NotionRenderer } from 'react-notion-x';
import 'react-notion-x/src/styles.css';
import Modal from '../../ui/Modal';
import { ModalIDs } from '@/src/constants/modal/modal';
import { closeModalHandler } from '@/src/util/modal/modalHandler';
import { ExtendedRecordMap } from 'notion-types';

type Props = {
recordMap: ExtendedRecordMap;
};

export default function ServiceGuideModal({ recordMap }: Props) {
return (
<Modal
id={ModalIDs.SERVICE_GUIDE}
className='min-w-[60vw]'
onClose={() => closeModalHandler('SERVICE_GUIDE', () => {})}
>
<NotionRenderer
className='w-full'
recordMap={recordMap}
fullPage={true}
darkMode={false}
disableHeader
isImageZoomable={false}
/>
</Modal>
);
}
Loading