Skip to content

Commit

Permalink
Merge pull request #82 from jeiltodo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Dragonite-Lee authored Aug 18, 2024
2 parents 0338dce + 5b6750f commit 4a5dc3a
Show file tree
Hide file tree
Showing 79 changed files with 1,802 additions and 9,571 deletions.
3 changes: 1 addition & 2 deletions apps/admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ COPY --from=builder /app/packages ./packages
COPY --from=builder /app/node_modules ./node_modules

EXPOSE 3001

CMD ["yarn", "start"]
CMD ["yarn", "start", "--port", "3001"]
7 changes: 7 additions & 0 deletions apps/admin/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const NotFoundPage = () => {
return <h1>404 - Page Not Found</h1>;
};

export default NotFoundPage;
71 changes: 0 additions & 71 deletions apps/admin/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,3 @@
// const tableMock: User[] = [
// {
// id: 1,
// name: '가길동',
// email: 'aohn@example.com',
// createdAt: new Date(2024, 0, 1, 0, 0, 0, 0).toISOString(),
// updatedAt: new Date(2024, 0, 1, 0, 0, 0, 0).toISOString(),
// groupCount: 2,
// },
// {
// id: 2,
// name: '나길동',
// email: 'bohn@example.com',
// createdAt: new Date(2024, 0, 2, 0, 0, 0, 0).toISOString(),
// updatedAt: new Date(2024, 0, 2, 0, 0, 0, 0).toISOString(),
// groupCount: 1,
// },
// {
// id: 3,
// name: '다길동',
// email: 'cohn@example.com',
// createdAt: new Date(2024, 0, 3, 0, 0, 0, 0).toISOString(),
// updatedAt: new Date(2024, 0, 3, 0, 0, 0, 0).toISOString(),
// groupCount: 1,
// },
// ];

// const GroupBoardMock: GroupBoardProps = {
// user: {
// id: 1,
// email: 'johndoe@example.com',
// name: 'John Doe',
// createdAt: '2024-01-15T10:00:00Z',
// updatedAt: '2024-07-10T15:00:00Z',
// },
// groups: [
// {
// id: 101,
// name: 'Development Team',
// registerAt: '2024-01-20T12:00:00Z',
// },
// {
// id: 102,
// name: 'Design Team',
// registerAt: '2024-02-05T14:30:00Z',
// },
// {
// id: 103,
// name: 'A Team',
// registerAt: '2024-02-05T14:30:00Z',
// },
// {
// id: 104,
// name: 'B Team',
// registerAt: '2024-02-05T14:30:00Z',
// },
// ],
// goals: [
// {
// id: 201,
// name: 'Improve code quality',
// registerAt: '2024-03-01T09:00:00Z',
// },
// {
// id: 202,
// name: 'Increase team collaboration',
// registerAt: '2024-04-15T11:00:00Z',
// },
// ],
// };

export default function Page(): JSX.Element {
return <main className='max-w-[930px] '></main>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ interface FilterSearchProps<T> {
}

export const FilterSearch = <T,>({ queries }: FilterSearchProps<T>) => {
console.log(queries);
return (
<Button variant='primary' className='w-[84px] h-[36px]'>
검색
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/widgets/sidebar/ui/sidebar-admin.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Sidebar } from '@jeiltodo/ui/shared';
import { SidebarNav } from '../../../shared/ui/sidebar/sidebar-nav';
import { Home, Group, Post } from '@jeiltodo/icons';
import { SidebarUserInfo } from '@jeiltodo/ui/entities';
import { SidebarUserInfo } from '@jeiltodo/ui/features';

const userData = {
id: 6,
Expand Down
4 changes: 2 additions & 2 deletions apps/user/src/app/(dashboard)/goal/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IndivDetailPage } from '../../../../page/goal';
import { IndividualGoalDetailPage } from '../../../../page/goal';

export default function Page({ params }: { params: { id: number } }) {
return <IndivDetailPage params={params} />;
return <IndividualGoalDetailPage params={params} />;
}
10 changes: 7 additions & 3 deletions apps/user/src/app/(dashboard)/goal/group/[id]/[goalid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { GroupDetailPage } from '../../../../../../page/goal';
import { GroupGoalDetailPage } from '../../../../../../page/goal';

export default function Page({ params }: { params: { goalid: number } }) {
return <GroupDetailPage params={params} />;
export default function Page({
params,
}: {
params: { id: string; goalid: string };
}) {
return <GroupGoalDetailPage params={params} />;
}
7 changes: 7 additions & 0 deletions apps/user/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const NotFoundPage = () => {
return <h1>404 - Page Not Found</h1>;
};

export default NotFoundPage;
21 changes: 16 additions & 5 deletions apps/user/src/entities/goal/api/groupGoalsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
GroupGoalWithTodos,
SingleGoalResponse,
} from '../model/type';
import { client, ResponsePageListWith } from '../../../shared';
import { client, ResponsePageListWith, ResponseWith } from '../../../shared';
import { GoalProps, GroupProps } from '../../../features/group';

export const groupGoalsApi = {
getSingleGroupGoal: async (goalId: number) => {
Expand All @@ -19,11 +20,11 @@ export const groupGoalsApi = {
}
},
// GET 요청: 그룹의 목표 목록 조회
getGroupGoals: async (
groupId: null | number
): Promise<GroupGoalsResponse> => {
getGroupGoals: async (groupId: null | number) => {
try {
const response = await client.get(`/group/goals/${groupId}`);
const response = await client.get<
ResponseWith<{ groupGoals: GoalProps[] }>
>(`/group/goals/${groupId}`);
return response.data;
} catch (error) {
console.error('Fail fetch group goals:', error);
Expand Down Expand Up @@ -60,6 +61,16 @@ export const groupGoalsApi = {
}
},

deleteGroupGoal: async (groupId: number, goalId: number) => {
try {
const response = await client.delete(`/group/goals/${groupId}/${goalId}`);
return response.data;
} catch (error) {
console.error('goal API - updateGroupGoal error:', error);
throw error;
}
},

createGroupGoal: async (groupId: number, title: string) => {
try {
const response = await client.post(`/group/goals/${groupId}`, {
Expand Down
4 changes: 2 additions & 2 deletions apps/user/src/entities/goal/api/individualGoalsApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { client, ResponsePageListWith, ResponseWith } from '../../../shared';
import { SingleGoalTodoResponse } from '../../todo';
import { SingleGoalTodosResponse } from '../../todo';
import type {
Goal,
GoalWithTodos,
Expand Down Expand Up @@ -36,7 +36,7 @@ export const individualGoalsApi = {
},
getSingleGoal: async (goalId: number) => {
try {
const response = await client.get<SingleGoalTodoResponse>(
const response = await client.get<ResponseWith<Goal>>(
`/individual/goals/single/${goalId}`
);
return response.data;
Expand Down
9 changes: 5 additions & 4 deletions apps/user/src/entities/goal/hooks/queryKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ export const goalQueryKeys = {
individual: {
default: () => [...goalQueryKeys.goals, 'individual'] as const,
progress: () =>
[...goalQueryKeys.individual.default(), 'progress'] as const,
[...goalQueryKeys.individual.default(), 'progress', 'todos'] as const,
todos: () => [...goalQueryKeys.individual.default(), 'todos'] as const,
lists: () => [...goalQueryKeys.individual.default(), 'list'] as const,
lists: () =>
[...goalQueryKeys.individual.default(), 'list', 'todos'] as const,
single: (goalId: number) =>
[...goalQueryKeys.individual.todos(), 'single', goalId] as const,
[...goalQueryKeys.individual.todos(), 'single', goalId, 'todos'] as const,
},

group: {
default: () => [...goalQueryKeys.goals, 'group'] as const,
lists: () => [...goalQueryKeys.group.default(), 'list'] as const,
todos: () => [...goalQueryKeys.group.default(), 'todos'] as const,
single: (goalId: number) =>
[...goalQueryKeys.group.default(), 'single', goalId] as const,
[...goalQueryKeys.group.default(), 'single', goalId, 'todos'] as const,
detail: (groupId: number | string) =>
[...goalQueryKeys.group.default(), groupId] as const,
},
Expand Down
1 change: 1 addition & 0 deletions apps/user/src/entities/goal/model/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Goal = {
id: number;
title: string;
memberId: number;
createdAt: string;
updatedAt: string;
progress: number;
};
Expand Down
13 changes: 8 additions & 5 deletions apps/user/src/entities/group/hooks/groupOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { groupApi } from '../api/groupApi';
import { AxiosError } from 'axios';
import { groupQueryKeys } from './queryKeys';
import { useToast } from '@jeiltodo/ui/shared';

export const groupOptions = () =>
queryOptions({
Expand All @@ -15,34 +16,36 @@ export const groupOptions = () =>

export const useGroupMutation = () => {
const queryClient = useQueryClient();

const showToast = useToast();
return useMutation({
mutationFn: groupApi.createGroup,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: groupQueryKeys.all });
showToast({ message: '그룹 생성 성공!', type: 'alert' });
},
onError: (error: AxiosError) => {
if (error.response?.status === 409) {
alert('이미 사용 중인 이름입니다.');
showToast({ message: '이미 사용 중인 이름입니다.', type: 'confirm' });
}
},
});
};

export const useGroupAttendMutation = () => {
const queryClient = useQueryClient();

const showToast = useToast();
return useMutation({
mutationFn: groupApi.attendGroup,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: groupQueryKeys.all });
showToast({ message: '그룹 참여 성공!', type: 'alert' });
},
onError: (error: AxiosError) => {
if (error.response?.status === 404) {
alert('없는 그룹입니다.');
showToast({ message: '존재하지 않는 그룹입니다.', type: 'confirm' });
}
if (error.response?.status === 400) {
alert('이미 참여한 그룹입니다.');
showToast({ message: '이미 참여한 그룹입니다.', type: 'confirm' });
}
},
});
Expand Down
3 changes: 3 additions & 0 deletions apps/user/src/entities/group/hooks/useChangeLeader.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { groupQueryKeys } from './queryKeys';
import { groupApi } from '../api/groupApi';
import { useToast } from '@jeiltodo/ui/shared';

export const useChangeLeader = (groupId: number) => {
const queryClient = useQueryClient();
const showToast = useToast();
return useMutation({
mutationFn: (memberId: number) => groupApi.changeLeader(groupId, memberId),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: groupQueryKeys.detail(groupId),
});
showToast({ message: '그룹장 변경 성공!', type: 'alert' });
},
});
};
3 changes: 3 additions & 0 deletions apps/user/src/entities/group/hooks/useCreateGroupGoal.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { groupGoalsApi } from '../../goal/api/groupGoalsApi';
import { useToast } from '@jeiltodo/ui/shared';

export const useCreateGroupGoal = (groupId: number) => {
const queryClient = useQueryClient();
const showToast = useToast();
return useMutation({
mutationFn: (title: string) =>
groupGoalsApi.createGroupGoal(groupId, title),
onSuccess: () => {
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('goals'),
});
showToast({ message: '목표 작성 성공!', type: 'alert' });
},
});
};
18 changes: 18 additions & 0 deletions apps/user/src/entities/group/hooks/useDeleteGroupGoal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { groupGoalsApi } from '../../goal/api/groupGoalsApi';
import { useToast } from '@jeiltodo/ui/shared';

export const useDeleteGroupGoal = (groupId: number) => {
const queryClient = useQueryClient();
const showToast = useToast();
return useMutation({
mutationFn: ({ id }: { id: number }) =>
groupGoalsApi.deleteGroupGoal(groupId, id),
onSuccess: () => {
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('goals'),
});
showToast({ message: '목표 삭제 성공!', type: 'alert' });
},
});
};
2 changes: 2 additions & 0 deletions apps/user/src/entities/group/hooks/useGroupGoalsWithTodos.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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';

interface Props {
groupId: number;
Expand Down
3 changes: 3 additions & 0 deletions apps/user/src/entities/group/hooks/useGroupTitleAndCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { groupQueryKeys } from './queryKeys';
import { groupApi } from '../api/groupApi';
import { GroupTitleOrCode } from '@jeiltodo/ui/entities';
import { useToast } from '@jeiltodo/ui/shared';

export const useGroupCode = (id: number) => {
return useQuery({
Expand All @@ -13,13 +14,15 @@ export const useGroupCode = (id: number) => {

export const useGroupTitleAndCode = (id: number) => {
const queryClient = useQueryClient();
const showToast = useToast();
return useMutation({
mutationFn: (groupBody: GroupTitleOrCode) =>
groupApi.updateGrouppTitleOrCode(id, groupBody),
onSuccess: () => {
queryClient.invalidateQueries({
predicate: (query) => query.queryKey.includes('groups'),
});
showToast({ message: '수정 성공!', type: 'alert' });
},
});
};
3 changes: 3 additions & 0 deletions apps/user/src/entities/group/hooks/useRemoveMember.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { groupQueryKeys } from './queryKeys';
import { groupApi } from '../api/groupApi';
import { useToast } from '@jeiltodo/ui/shared';

export const useRemoveMember = (groupId: number) => {
const queryClient = useQueryClient();
const showToast = useToast();
return useMutation({
mutationFn: (memberId: number) => groupApi.removeMember(groupId, memberId),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: groupQueryKeys.detail(groupId),
});
showToast({ message: '삭제 성공!', type: 'alert' });
},
});
};
Loading

0 comments on commit 4a5dc3a

Please sign in to comment.