Skip to content

Commit

Permalink
fix(qa) QA에서 발견된 오류 수정 (#58)
Browse files Browse the repository at this point in the history
* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* f

* fix

* fix
  • Loading branch information
Collection50 authored and eunbeann committed Aug 30, 2024
1 parent 236da35 commit 869a85f
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/app/(sidebar)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Sidebar } from '@/container/Sidebar/Sidebar';
import { PropsWithChildren } from 'react';
import { CardWindowLayout } from '@/components/CardWindow/context';
import AuthRedirect from '../AuthRedirect';

export default function SidebarLayout({ children }: PropsWithChildren) {
return (
<div className="flex">
<Sidebar />
<div className="flex-grow relative">
<CardWindowLayout>{children}</CardWindowLayout>
<AuthRedirect>
<CardWindowLayout>{children}</CardWindowLayout>
</AuthRedirect>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface GetCardDetailResponse {
title: string;
content: JSONContent;
updatedDate: `${string} ${string}`;
createdDate: `${string} ${string}`;
recruitTitle: string;
cardTypeValueList: Array<TypeTag>;
tagList: Array<TagType>;
cardTypeValueGroup: CardGroup;
Expand Down
12 changes: 9 additions & 3 deletions src/app/(sidebar)/write/[id]/api/usePostMemo.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { http } from '@/apis/http';
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';

export const postMemo = (cardId: number, content: string) =>
http.post({
url: `/cards/${cardId}/card-memo`,
data: { content },
});

export const usePostMemo = (cardId: number) =>
useMutation({
export const usePostMemo = (cardId: number) => {
const queryClient = useQueryClient();

return useMutation({
mutationKey: ['post-memo', cardId],
mutationFn: (content: string) => postMemo(cardId, content),
onSuccess: async () => {
await queryClient.invalidateQueries({ queryKey: ['get-memos'] });
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ export function DeleteMemoDialog({
<DialogTrigger asChild>{children}</DialogTrigger>

<DialogContent className="border-1 w-460 h-232 p-32 pt-24 flex flex-col gap-36">
<div className="mt-36 text-20 font-bold text-center">
<p className="w-360 overflow-hidden text-ellipsis whitespace-pre-wrap">{memo}</p>
<div className="mt-36 text-20 font-bold text-center flex flex-col items-center justify-center">
<div className="flex">
<span>'</span>
<p className="w-370 overflow-hidden text-ellipsis whitespace-nowrap">{memo}</p>
<span>'</span>
</div>
<p>메모를 정말 삭제하시겠습니까?</p>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import { AnimatePresence } from 'framer-motion';
import { motion } from 'framer-motion';
import { GetMemosResponse } from '../../../api/useGetMemos';
import { useMemosContext } from '../../../fetcher/MemosFetcher';
import { useDeleteMemo } from '../../../api/useDeleteMemo';
import { usePutMemo } from '@/app/(sidebar)/write/[id]/api/usesPutMemo';
import { If } from '@/system/utils/If';
import { Dialog } from '@/system/components/Dialog/Dialog';
import { DeleteMemoDialog } from './DeleteMemoDialog';

export default function Memo({ id: memoId, content, updatedDate }: GetMemosResponse[number]) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/(sidebar)/write/[id]/fetcher/CardTagFetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const [CardDetailTagsProvider, useCardDetailTagsContext] = generateContext<GetCa
tagList: [],
updatedDate: ' ',
cardTypeValueGroup: '내_정보',
createdDate: ' ',
recruitTitle: '',
},
});

Expand Down
7 changes: 7 additions & 0 deletions src/app/(sidebar)/write/[id]/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useTagsContext } from '../fetcher/TagsFetcher';
import { usePutCardType } from '@/app/(sidebar)/write/[id]/api/usePutCardType/usePutCardType';
import { useQueryClient } from '@tanstack/react-query';
import { TypeTag } from '@/types/info';
import { useDeleteCard } from '@/app/(sidebar)/(my-info)/apis/useDeleteCard';

export function useWrite(id: number) {
const {
Expand All @@ -17,6 +18,8 @@ export function useWrite(id: number) {
content,
cardTypeValueList,
cardTypeValueGroup,
createdDate,
recruitTitle,
} = useCardDetailTagsContext();
const { tags } = useTagsContext();
const isMyInfo = cardTypeValueGroup === '내_정보';
Expand All @@ -35,6 +38,7 @@ export function useWrite(id: number) {
const { mutate: mutatePostCardTag } = usePostCardTag(id);
const { mutate: mutateDeleteCardTag } = useDeleteCardTag(id);
const { mutate: mutatePutCardType } = usePutCardType(id);
const { mutate: deleteCard } = useDeleteCard();

const handlePutCardTitle = useCallback((value: string) => {
setTitle(value);
Expand Down Expand Up @@ -101,6 +105,7 @@ export function useWrite(id: number) {
handlePostCardTag,
handleDeleteCardTag,
handlePutCardType,
deleteCard,
title,
selectedTags,
selectedCategories,
Expand All @@ -109,5 +114,7 @@ export function useWrite(id: number) {
updatedDate: updatedDate.split(' ')[0].replaceAll(/-/g, '.'),
content,
disabledCount,
createdDate: createdDate.split(' ')[0].replaceAll(/-/g, '.'),
recruitTitle,
};
}
28 changes: 24 additions & 4 deletions src/app/(sidebar)/write/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,24 @@ export default function Page({ params: { id } }: { params: { id: string } }) {
updatedDate,
disabledCount,
handlePutCardType,
deleteCard,
createdDate,
recruitTitle,
} = useWrite(Number(id));

return (
<section className="h-full">
<section className="flex">
<div className="pt-64 w-full">
<div className="pt-40 w-full">
<div className="h-16 pl-80">
<If condition={recruitTitle != null}>
<div className="flex gap-4 text-12 text-neutral-30 mt-8">
<Icon name="announcementFolder" size={16} color="#CCCDD1" />
<p>{recruitTitle}</p>
</div>
</If>
</div>

<EditorProvider cardId={Number(id)} initialContent={content}>
<div className="flex justify-between px-80">
<Input
Expand All @@ -52,15 +64,23 @@ export default function Page({ params: { id } }: { params: { id: string } }) {
classNames={{ base: 'w-[552px]' }}
className="text-[24px] font-bold px-0 leading-32 tracking-[-0.0345rem] border-none"
/>
<div className="flex gap-8 items-center text-neutral-20">
<p>{updatedDate}</p>
<div className="flex gap-8 items-center text-neutral-20 whitespace-nowrap">
<div className="flex items-center gap-4">
<If condition={updatedDate != null}>
<p className="text-12 text-neutral-50">{updatedDate} 수정됨</p>
</If>

<p className="text-12">{updatedDate != null ? `(${createdDate || ''} 생성됨)` : createdDate}</p>
</div>

<DropdownMenu>
<DropdownMenuTrigger>
<Icon name="more" color="black" />
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem className="flex gap-4 w-176 h-52 pl-16 cursor-pointer">
<DropdownMenuItem
onClick={() => deleteCard(Number(id))}
className="flex gap-4 w-176 h-52 pl-16 cursor-pointer">
<Icon name="trash" size={20} color="#FF5C5C" />
<p className="text-[#FF5C5C] text-15">삭제하기</p>
</DropdownMenuItem>
Expand Down
5 changes: 3 additions & 2 deletions src/app/AuthRedirect.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Redirect } from '@/components/Redirect';
import { StrictPropsWithChildren } from '@/types';
import { cookies } from 'next/headers';
import { ACCESS_TOKEN } from './login/constants/token';
import { ACCESS_TOKEN, JOB_SELECTION } from './login/constants/token';

export default async function AuthRedirect({ children }: StrictPropsWithChildren) {
const accessToken = cookies().get(ACCESS_TOKEN)?.value;
const isJobSelection = cookies().get(JOB_SELECTION)?.value;

return (
<Redirect condition={accessToken != null} to="/login">
<Redirect condition={accessToken == null || isJobSelection == null} to="/login">
{children}
</Redirect>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '@/styles/memo.css';
import { Inter } from 'next/font/google';
import { cn } from '@/utils';
import { Suspense } from 'react';
import { GoogleProvider } from '@/app/GoogleProvider';
import { GoogleProvider } from '@/lib/GoogleProvider';

const inter = Inter({ subsets: ['latin'] });

Expand Down
14 changes: 13 additions & 1 deletion src/app/login/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { Redirect } from '@/components/Redirect';
import { StrictPropsWithChildren } from '@/types';
import { cookies } from 'next/headers';
import { Suspense } from 'react';
import { ACCESS_TOKEN } from './constants/token';

export default async function Layout({ children }: StrictPropsWithChildren) {
return <main className="h-screen flex justify-center items-center bg-neutral-95">{children}</main>;
const accessToken = cookies().get(ACCESS_TOKEN)?.value;

return (
<main className="h-screen flex justify-center items-center bg-neutral-95">
<Redirect condition={accessToken != null} to="/">
<Suspense>{children}</Suspense>
</Redirect>
</main>
);
}
3 changes: 1 addition & 2 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import { ACCESS_TOKEN, JOB_SELECTION, SELECT } from './constants/token';
export default function Page() {
const Funnel = useFunnel(['login', 'select'] as const, { initialStep: 'login', stepQueryKey: 'auth' });
const isSelectJob = getCookie(JOB_SELECTION) === SELECT;
const accessToken = !!getCookie(ACCESS_TOKEN);

return (
<Funnel mode="wait">
<Funnel.Step name="login">
<Redirect condition={accessToken}>
<Redirect condition={!isSelectJob} to="/login?auth=select">
<Login />
</Redirect>
</Funnel.Step>
Expand Down
21 changes: 19 additions & 2 deletions src/components/Editor/useEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,27 @@ import { JSONContent, useEditor as useTiptapEditor } from '@tiptap/react';
import { ExtensionKit } from './extensionKit';
import { useEffect, useState } from 'react';

export function useEditor({ readOnly, initialContent = {} }: { initialContent?: JSONContent; readOnly?: boolean }) {
const [content, setContent] = useState<JSONContent>(JSON.parse((initialContent || JSON.stringify('')) as any) || {});
export function useEditor({
readOnly = false,
initialContent = {},
}: {
initialContent?: JSONContent | string;
readOnly?: boolean;
}) {
const [content, setContent] = useState<JSONContent>(() => {
try {
const parsedContent = initialContent
? JSON.parse(typeof initialContent === 'string' ? initialContent : JSON.stringify(initialContent))
: '';

return parsedContent || {};
} catch (error) {
return {};
}
});

const editor = useTiptapEditor({
editable: !readOnly,
autofocus: true,
extensions: [...ExtensionKit()],
editorProps: {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/system/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RemoveMemo } from '@/system/components/Icon/SVG/RemoveMemo';
import { SubmitArrow } from '@/system/components/Icon/SVG/SubmitArrow';
import type { IconBaseType } from '@/system/components/Icon/SVG/type';
import { Add } from './SVG/Add';
import { AnnouncementFolder } from './SVG/AnnouncementFolder';
import { ArrowUp } from './SVG/ArrowUp';
import { Bell } from './SVG/Bell';
import { Calendar } from './SVG/Calendar';
Expand Down Expand Up @@ -99,6 +100,7 @@ const iconMap = {
profileFill: ProfileFill,
folder: Folder,
warning: Warning,
announcementFolder: AnnouncementFolder,
} as const;

export interface IconProps extends IconBaseType {
Expand Down
14 changes: 14 additions & 0 deletions src/system/components/Icon/SVG/AnnouncementFolder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { IconBaseType } from '@/system/components/Icon/SVG/type';

export function AnnouncementFolder({ size, color }: IconBaseType) {
return (
<svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} fill="none" xmlns="http://www.w3.org/2000/svg">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M4.58667 10.5599H11.4133V9.55995H4.58667V10.5599ZM8.14 3.96661L6.63333 2.11328H1.5V13.8866H14.5V3.96661H8.14Z"
fill={color}
/>
</svg>
);
}

0 comments on commit 869a85f

Please sign in to comment.