Skip to content

Commit

Permalink
Merge pull request #70 from Funssion-SWM/develop
Browse files Browse the repository at this point in the history
자잘한 부분 수정
  • Loading branch information
dongree authored Nov 15, 2023
2 parents 6b1f0dd + 2a7df5c commit 731ae3d
Show file tree
Hide file tree
Showing 20 changed files with 242 additions and 124 deletions.
2 changes: 1 addition & 1 deletion src/app/api/generate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function POST(req: Request): Promise<Response> {
// }
let { prompt } = await req.json();
const response = await openai.createChatCompletion({
model: 'gpt-3.5-turbo',
model: 'gpt-4-1106-preview',
messages: [
{
role: 'system',
Expand Down
8 changes: 4 additions & 4 deletions src/app/create/coverletter/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const metadata: Metadata = {
description: '자기 소개를 작성하는 곳입니다.',
};

export default async function CoverLetterPage() {
// const headersList = headers();
// const referer = headersList.get('referer');
// referer === null && redirect(MAIN_PATH);
export default async function CreateCoverLetterPage() {
const headersList = headers();
const referer = headersList.get('referer');
referer === null && redirect(MAIN_PATH);

const accessToken = cookies().get(ACCESS_TOKEN)?.value;
const refreshToken = cookies().get(REFRESH_TOKEN)?.value;
Expand Down
7 changes: 7 additions & 0 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import Link from 'next/link';
import logo from '@/assets/inforum_logo.png';
import Image from 'next/image';
import { MAIN_PATH } from '@/utils/const';
import { headers } from 'next/headers';
import { notifyToast } from '@/service/notify';

export const metadata: Metadata = {
title: '로그인',
description: '로그인을 하는 곳입니다.',
};

export default function LoginPage() {
const headersList = headers();
const referer = headersList.get('referer');
referer === 'https://accounts.google.com/' &&
notifyToast('이미 일반 회원가입으로 등록된 계정입니다.', 'error');

return (
<section className="relative flex flex-col w-full items-center max-w-screen-sm mx-auto mt-32 py-5 px-10 sm:px-32">
<Link
Expand Down
1 change: 1 addition & 0 deletions src/app/memos/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default async function MemoPage({ params: { slug } }: Props) {
createdDate={createdDate}
seriesId={seriesId}
seriesTitle={seriesTitle}
isLogin={isLogin}
/>
<MemoSideBar
authorName={authorName}
Expand Down
1 change: 1 addition & 0 deletions src/app/questions/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default async function QuestionPage({ params: { slug } }: Props) {
isLike={isLike}
userId={id}
memoTitle={memoTitle}
isLogin={isLogin}
/>
</LayoutWrapper>
</section>
Expand Down
7 changes: 7 additions & 0 deletions src/app/search/user-for-job/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import SearchUserForJobContainer from '@/components/search/user-for-job/SearchUserForJobContainer';
import LayoutWrapper from '@/components/shared/LayoutWrapper';
import { MAIN_PATH } from '@/utils/const';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';

export default function SearchUserForJobPage() {
const headersList = headers();
const referer = headersList.get('referer');
referer === null && redirect(MAIN_PATH);

return (
<section>
<LayoutWrapper paddingY="sm:py-0">
Expand Down
43 changes: 17 additions & 26 deletions src/components/create/coverletter/CoverLetterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import BlueBtn from '@/components/shared/btn/BlueBtn';
import { notifyToast } from '@/service/notify';
import { ChangeEvent, useEffect, useState } from 'react';
import { ChangeEvent, useContext, useEffect, useState } from 'react';
import { AiOutlineInfoCircle } from 'react-icons/ai';
import CoverLetterPage2 from './CoverLetterPage2';
import { DevelopmentArea, StackInfo } from '@/types/coverletter';
Expand All @@ -15,9 +15,8 @@ import { useEditor } from '@tiptap/react';
import { handleTiptapExtensions } from '@/components/editor/extensions';
import { handleTiptapEditorProps } from '@/components/editor/props';
import { useRouter } from 'next/navigation';
import { useCompletion } from 'ai/react';
import { RingLoader } from 'react-spinners';
import { developmentAreaOptions, stackOptions } from '@/utils/const';
import { ModalContext } from '@/context/ModalProvider';

const TITLE_STYLE = 'sm:text-xl font-semibold';

Expand Down Expand Up @@ -46,6 +45,7 @@ export default function CoverLetterForm({ userId }: Props) {
const [page, setPage] = useState(1);
const [isCreated, setIsCreated] = useState(true);
const router = useRouter();
const { open } = useContext(ModalContext);

const editor = useEditor({
extensions: handleTiptapExtensions('coverletter', userId),
Expand Down Expand Up @@ -107,13 +107,6 @@ export default function CoverLetterForm({ userId }: Props) {
};

const handleSave = async () => {
// if (answer1.length !== 0 && answer2.length !== 0 && answer3.length !== 0) {
// const textFormPrompt = `answer1: ${answer1}
// answer2: ${answer2}
// answer3: ${answer3}`;
// await descriptionAI.complete(textFormPrompt);

// console.log(descriptionAI.completion);
const coverletterInfo = {
introduce,
techStack: JSON.stringify(stackInfos),
Expand Down Expand Up @@ -149,16 +142,8 @@ export default function CoverLetterForm({ userId }: Props) {
};
});

// const descriptionAI = useCompletion({
// id: 'inforum4',
// api: '/api/generate/description/coverletter',
// onError: (err) => {
// notifyToast(err.message, 'error');
// },
// });

return (
<div>
<div className="relative">
{page === 1 ? (
<div>
<div className="flex flex-col gap-10 mb-5">
Expand Down Expand Up @@ -383,13 +368,19 @@ export default function CoverLetterForm({ userId }: Props) {
editor={editor}
/>
)}
{/* {descriptionAI.isLoading && (
<div className="fixed top-0 left-0 w-screen h-screen flex flex-col justify-center items-center bg-white opacity-90">
<RingLoader className="self-center" color="#4992FF" />
{/* <div className="text-center font-medium text-soma-grey-60 text-sm my-5">
AI가 description, tags를 자동생성중입니다...
</div>
</div>)} */}
<button
className="absolute top-0 right-0 text-soma-grey-50"
onClick={() =>
open(
'나가시겠습니까? 나가면 수정했던 정보는 저장되지 않습니다.',
() => {
router.back();
}
)
}
>
나가기
</button>
</div>
);
}
8 changes: 7 additions & 1 deletion src/components/create/memo/EditorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,13 @@ export default function EditorForm({ userId }: Props) {
}}
onCreateBtnClick={handleCreate}
userId={userId}
description={descriptionAI.completion}
description={
descriptionAI.completion ||
getDescription(JSON.stringify(editor?.getJSON())).substring(
0,
150
)
}
tags={tagsAI.completion}
memoId={memoId}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/guide/GuideHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ export default function GuideHeader() {
<br />
마크다운 에디터, 일반 에디터 모두 잘 동작합니다.
</div> */}
<div className="embla__slide bg-soma-grey-20 rounded-xl">
{/* <div className="embla__slide bg-soma-grey-20 rounded-xl">
인포럼에서 <span className={HIGHLIGHT_STYLE}>post 작성</span>하고
커피☕️ 받아가세요!
<br />
<span className={HIGHLIGHT_STYLE}>개발 관련 메모 또는 질문</span>을
작성하고 페이지 상단{' '}
<span className={HIGHLIGHT_STYLE}>이벤트 설문조사</span>를
참여해주시면 커피☕️를 드립니다.
</div>
</div> */}
</div>
</div>
)
Expand Down
7 changes: 3 additions & 4 deletions src/components/landing/LandingContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function LandingContainer() {

return (
<div className="snap-y snap-mandatory overflow-y-scroll h-screen">
<EventHeader />
{/* <EventHeader /> */}
<div
className="flex relative flex-col justify-center items-center h-full sm:snap-always sm:snap-center bg-gradient-to-t from-soma-blue-30 from-0% via-white via-80%"
ref={firstScreenRef}
Expand Down Expand Up @@ -57,14 +57,13 @@ export default function LandingContainer() {
블럭 기반 에디터를 활용해 개발 기록을 간편하게 작성해보세요
</p>
<button
className="bg-soma-blue-40 w-72 h-16 shadow-2xl text-white px-3.5 py-2 rounded-3xl transition hover:bg-soma-blue-50 sm:text-2xl"
onClick={() => {
router.push(MAIN_PATH);
router.refresh();
}}
>
<button className="bg-soma-blue-40 w-72 h-16 shadow-2xl text-white px-3.5 py-2 rounded-3xl transition hover:bg-soma-blue-50 sm:text-2xl">
시작하기
</button>
시작하기
</button>
</div>
<Image
Expand Down
8 changes: 4 additions & 4 deletions src/components/me/CountInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ export default function CountInfo({ isMine }: Props) {

return (
<div className="flex text-center w-full border-y my-2">
<div
<button
className="flex-1 cursor-pointer transition-all hover:bg-soma-grey-30 py-4"
onClick={() => open('follower')}
>
<p className="text-lg font-semibold">{currentFollowers.length}</p>
<p className="text-xs text-gray-400">팔로워</p>
</div>
<div
</button>
<button
className="flex-1 cursor-pointer transition-all hover:bg-soma-grey-30 py-4"
onClick={() => open('following')}
>
<p className="text-lg font-semibold">{currentFollowings.length}</p>
<p className="text-xs text-gray-400">팔로잉</p>
</div>
</button>
{/* <div className="w-1/3 py-4">
<p className="text-lg font-semibold">9999</p>
<p className="text-xs text-gray-400">좋아요</p>
Expand Down
4 changes: 3 additions & 1 deletion src/components/me/MeSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export default function MeSideBar({
<ScoreDetailModal userStats={userStats} />
</ScoreDetailProvider>
<History history={history} userId={userId} />
{myId === Number(userId) && <Setting myId={myId} />}
{myId === Number(userId) && (
<Setting myId={myId} isCoverletterCreated={isCoverletterCreated} />
)}
{myId === Number(userId) && isCoverletterCreated && (
<CoverLetterOpenToggle coverletterIsVisible={coverletterIsVisible} />
)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/me/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import { useContext } from 'react';

type Props = {
myId: number;
isCoverletterCreated: boolean;
};

export default function Setting({ myId }: Props) {
export default function Setting({ myId, isCoverletterCreated }: Props) {
const router = useRouter();
const { open } = useContext(ModalContext);

Expand All @@ -22,7 +23,7 @@ export default function Setting({ myId }: Props) {
회원 정보 수정
</Link>
<Link href={`/create/coverletter`} prefetch={false}>
자기소개서 작성
{`자기소개서 ${isCoverletterCreated ? '수정' : '작성'}`}
</Link>
<button
onClick={() => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/memo/MemoViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Props = {
type?: 'memo' | 'series';
seriesId: number;
seriesTitle: string;
isLogin: boolean;
};

export default function MemoViewer({
Expand All @@ -35,6 +36,7 @@ export default function MemoViewer({
type = 'memo',
seriesId,
seriesTitle,
isLogin,
}: Props) {
const editor = useEditor({
extensions: handleTiptapExtensions('memo', memoId),
Expand Down Expand Up @@ -86,7 +88,7 @@ export default function MemoViewer({
</div>
<div className="flex flex-wrap gap-1 mx-2 mt-10 mb-1">
{memoTags.map((tag, idx) => (
<TagView key={idx} tagText={tag} />
<TagView key={idx} tagText={tag} isLogin={isLogin} />
))}
</div>
</section>
Expand Down
9 changes: 8 additions & 1 deletion src/components/question/QuestionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Props = {
isLike: boolean;
userId: number;
memoTitle: string;
isLogin: boolean;
};

export default function QuestionDetail({
Expand All @@ -35,6 +36,7 @@ export default function QuestionDetail({
isLike,
userId,
memoTitle,
isLogin,
}: Props) {
return (
<div className="flex flex-col">
Expand Down Expand Up @@ -63,7 +65,12 @@ export default function QuestionDetail({
/>
</div>
</div>
<QuestionFooter tags={tags} memoId={memoId} memoTitle={memoTitle} />
<QuestionFooter
tags={tags}
memoId={memoId}
memoTitle={memoTitle}
isLogin={isLogin}
/>
</div>
<p className="sm:text-xl p-2 mt-10 font-semibold border-b-[1px] border-soma-grey-49 ">
<span className="text-soma-blue-40">{answersCount}</span>의 답변
Expand Down
10 changes: 8 additions & 2 deletions src/components/question/QuestionFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ type Props = {
tags: string[];
memoId: number;
memoTitle: string;
isLogin: boolean;
};

export default function QuestionFooter({ tags, memoId, memoTitle }: Props) {
export default function QuestionFooter({
tags,
memoId,
memoTitle,
isLogin,
}: Props) {
return (
<div className="flex justify-between text-xs sm:text-sm">
<div className="flex flex-wrap gap-1">
{tags.map((tag, idx) => (
<TagView key={idx} tagText={tag} />
<TagView key={idx} tagText={tag} isLogin={isLogin} />
))}
</div>
{/* <TagsList tags={tags} /> */}
Expand Down
Loading

0 comments on commit 731ae3d

Please sign in to comment.