Skip to content

Commit

Permalink
Merge pull request #85 from jeiltodo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Dragonite-Lee committed Aug 19, 2024
2 parents 4a5dc3a + bd04f80 commit 1f40461
Show file tree
Hide file tree
Showing 71 changed files with 1,097 additions and 701 deletions.
16 changes: 14 additions & 2 deletions apps/user/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
module.exports = {
extends: ['@jeiltodo/eslint-config/next.js'],
};
extends: ['@jeiltodo/eslint-config/next.js'],
rules: {
'react/function-component-definition': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'eslint-disable tsdoc/syntax': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'react/jsx-no-leaked-render': 'off',
'react/jsx-sort-props': 'off',
},
};
1 change: 0 additions & 1 deletion apps/user/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
// pageExtensions: [],
transpilePackages: ['@jeiltodo/ui'],
eslint: {
ignoreDuringBuilds: true,
Expand Down
1 change: 1 addition & 0 deletions apps/user/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^9.13.0",
"react-quill": "^2.0.0",
"tailwind-scrollbar-hide": "^1.1.7"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/user/src/app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoginPage } from '../../../page/auth';

export default function Login() {
export default function Page() {
return <LoginPage />;
}
2 changes: 1 addition & 1 deletion apps/user/src/app/(auth)/signup/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SignUpPage } from '../../../page/auth';

export default function Signup() {
export default function Page() {
return <SignUpPage />;
}
2 changes: 1 addition & 1 deletion apps/user/src/app/(dashboard)/goal/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default function GoalRootLayout({
}: {
children: React.ReactNode;
}): JSX.Element {
return <>{children}</>;
return <main className='common-layout bg-slate-100'>{children}</main>
}
7 changes: 7 additions & 0 deletions apps/user/src/app/(dashboard)/group/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function GroupRootLayout({
children,
}: {
children: React.ReactNode;
}): JSX.Element {
return <main className='common-layout bg-slate-100'>{children}</main>
}
36 changes: 19 additions & 17 deletions apps/user/src/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@ import { getQueryClient } from '../../entities/goal/get-query-client';
import { SidebarUser } from '../../widgets/user';
import { groupOptions } from '../../entities/group/index';
import { userOptions } from '../../entities/user';
import { individualGoalsOptions, progressAllOptions } from '../../entities/goal';

import {
individualGoalsOptions,
progressAllOptions,
} from '../../entities/goal';

export default async function DashboardLayout({
children,
children,
}: {
children: React.ReactNode;
children: React.ReactNode;
}) {
const queryClient = getQueryClient();
const queryClient = getQueryClient();

await queryClient.prefetchQuery(userOptions());
await queryClient.prefetchQuery(individualGoalsOptions());
await queryClient.prefetchQuery(groupOptions());
await queryClient.prefetchQuery(progressAllOptions());
await queryClient.prefetchQuery(userOptions());
await queryClient.prefetchQuery(individualGoalsOptions());
await queryClient.prefetchQuery(groupOptions());
await queryClient.prefetchQuery(progressAllOptions());

return (
<>
<HydrationBoundary state={dehydrate(queryClient)}>
<SidebarUser />
<main className='common-layout bg-slate-100'>{children}</main>
</HydrationBoundary>
</>
);
return (
<>
<HydrationBoundary state={dehydrate(queryClient)}>
<SidebarUser />
<main>{children}</main>
</HydrationBoundary>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export default function NoteEditorLayout({
}: {
children: React.ReactNode;
}): JSX.Element {
return <div className='bg-white'>{children}</div>;
return <main className='common-layout bg-white'>{children}</main>;
}
2 changes: 1 addition & 1 deletion apps/user/src/app/(dashboard)/note/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default function NoteRootLayout({
}: {
children: React.ReactNode;
}): JSX.Element {
return <>{children}</>;
return <main>{children}</main>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export default function NoteListLayout({
}: {
children: React.ReactNode;
}): JSX.Element {
return <>{children}</>;
return <main className='common-layout bg-slate-100'>{children}</main>;
}
14 changes: 0 additions & 14 deletions apps/user/src/app/(dashboard)/note/temporary-note/layout.tsx

This file was deleted.

34 changes: 0 additions & 34 deletions apps/user/src/app/(dashboard)/note/temporary-note/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/user/src/app/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UserDashboardPage } from '../../page/user/user-dashboard-page';

export default function Page() {
return (
<main className="pt-4">
<main className="pt-4 common-layout bg-slate-100">
<UserDashboardPage />
</main>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/user/src/app/(dashboard)/todo/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function todoLayout({
}) {
return (
<>
<main className=''>{children}</main>
<main className='common-layout bg-slate-100'>{children}</main>
</>
);
}
6 changes: 1 addition & 5 deletions apps/user/src/app/(dashboard)/todo/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { TodoPage } from '../../../page/todo';

export default function Page() {
return (
<main className='pt-4'>
<TodoPage />
</main>
);
return <TodoPage />;
}
12 changes: 1 addition & 11 deletions apps/user/src/entities/group/hooks/useGroupGoalsWithTodos.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useInfiniteQuery } from '@tanstack/react-query';
import { goalQueryKeys } from '../../goal/hooks/queryKey';
import { groupGoalsApi } from '../../goal/api/groupGoalsApi';
import { ResponsePageListWith } from '../../todo';
import { GroupGoalWithTodos } from '../../goal';
import { calculateTotalPages } from '../../../shared';

interface Props {
groupId: number;
Expand Down Expand Up @@ -31,12 +30,3 @@ export const useGroupGoalsWithTodos = ({ groupId, limit }: Props) => {
},
});
};

/*
////////////////////////////////////////////////////////////////////////////////
*/
function calculateTotalPages(totalCount: number, itemsPerPage: number): number {
const fullPages = Math.floor(totalCount / itemsPerPage);
const hasPartialPage = totalCount % itemsPerPage !== 0;
return fullPages + (hasPartialPage ? 1 : 0);
}
63 changes: 23 additions & 40 deletions apps/user/src/entities/note/api/noteApi.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { client } from '../../../shared';
import { Note } from '@jeiltodo/ui/shared';
import { client, ResponseWith } from '../../../shared';
import type { NoteGetResponse, NoteResponse } from '../model/type';

// GET 요청 : 목표에 따른 노트 리스트 조회
export const getGoalNotes = async ({
goalId,
page = 1,
limit = 0,
}: GetGoalNotesParam) => {
const queryParams = [
page ? `page=${page}` : '',
limit ? `limit=${limit}` : '',
]
.filter(Boolean)
.join('&');

const url = `/note/list/goal/${goalId}${queryParams ? `?${queryParams}` : ''}`;

export const getGoalNotes = async (
goalId: number,
params: { page: number; limit: number }
) => {
try {
const response = await client.get<NoteResponse>(url);
const response = await client.get<
ResponseWith<{ totalCount: number; currentPage: number; notes: Note[] }>
>(`/note/list/goal/${goalId}`, {
params,
});
return response.data;
} catch (error) {
console.error('Failed to fetch notes:', error);
Expand All @@ -33,13 +28,10 @@ export const getNoteDetail = async (noteId: number) => {
return response.data;
};

//CREATE 요청 : 노트 생성
export const createNote = async ({
todoId,
title,
content,
linkUrl,
}: NotePostParam) => {
export const createNote = async (
todoId: number,
{ title, content, linkUrl }: Omit<NotePostParam, 'todoId'>
) => {
try {
const response = await client.post('note/create', {
todoId,
Expand All @@ -54,13 +46,10 @@ export const createNote = async ({
}
};

//PATCH 요청 : 노트 수정
export const patchNote = async ({
noteId,
title,
content,
linkUrl,
}: NotePatchParam) => {
export const patchNote = async (
noteId: number,
{ title, content, linkUrl }: Omit<NotePatchParam, 'noteId'>
) => {
try {
const response = await client.patch(`note/update/${noteId}`, {
title,
Expand All @@ -74,8 +63,7 @@ export const patchNote = async ({
}
};

// DELETE 요청 : 노트 삭제
export const deleteNote = async ({ noteId }: DeleteNoteParam) => {
export const deleteNote = async (noteId: number) => {
try {
const response = await client.delete(`/note/delete/${noteId}`);
return response.data;
Expand All @@ -90,24 +78,19 @@ export const deleteNote = async ({ noteId }: DeleteNoteParam) => {
*/

export interface GetGoalNotesParam {
goalId: string | string[];
page: number;
goalId: number;
limit: number;
}

export interface NotePostParam {
todoId: string;
todoId: number;
title: string;
content: string;
linkUrl?: string;
}
export interface NotePatchParam {
noteId: string;
noteId: number;
title: string;
content: string;
linkUrl?: string;
}

interface DeleteNoteParam {
noteId: number;
}
15 changes: 15 additions & 0 deletions apps/user/src/entities/note/hooks/useCreateNote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { createNote, NotePostParam } from '../api/noteApi';

export const useCreateNote = (todoId: number) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (note: Omit<NotePostParam, 'todoId'>) =>
createNote(todoId, note),
onSuccess: () => {
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('notes'),
});
},
});
};
17 changes: 17 additions & 0 deletions apps/user/src/entities/note/hooks/useDeleteNote.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { deleteNote } from '../api/noteApi';

export const useDeleteNote = (noteId: number) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => deleteNote(noteId),
onSuccess: () => {
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('notes'),
});
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('todos'),
});
},
});
};
Loading

0 comments on commit 1f40461

Please sign in to comment.