Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@
}

.optionalInfo {
flex: 1;
display: flex;
justify-content: space-between;
justify-content: flex-end;
align-items: center;
}

.dueDateWrapper {
flex: 1;
display: flex;
gap: 4px;
align-items: center;
gap: 4px;
width: 125px;
}

Expand Down Expand Up @@ -116,15 +118,11 @@

.contentContainer {
flex-direction: row;
align-items: flex-end;
align-items: center;
justify-content: space-between;
gap: 0;
}

.tagContainer {
max-width: 50%;
}

.imageWrapper {
width: 91px;
height: 53px;
Expand All @@ -140,6 +138,10 @@
gap: 16px;
}

.dueDateWrapper {
justify-content: flex-end;
}

.modal {
width: 680px;
}
Expand Down Expand Up @@ -181,4 +183,8 @@
justify-content: space-between;
gap: 0;
}

.dueDateWrapper {
justify-content: flex-start;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function UpdateTaskModal() {
options={members}
setValue={setValue}
defaultAssignee={
members?.filter((member) => member.userId == card?.assignee.id)[0]
members?.filter((member) => member.userId == card?.assignee?.id)[0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‹ด๋‹น์ž์—†์„๋•Œ ์ˆ˜์ •๋ˆ„๋ฅด๋ฉด ์—๋Ÿฌ๋‚˜์„œ ์ถ”๊ฐ€ํ–ˆ์Šด๋‹ค

}
className={styles.dropdown}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export default function CardInfo({ card, columnTitle }: CardInfoProps) {

return (
<div className={styles.cardInfo}>
<div className={styles.assignmentContainer}>
<Assignment card={card} />
</div>
{card.assignee && (
<div className={styles.assignmentContainer}>
<Assignment card={card} />
</div>
)}
<div className={styles.infoContainer}>
<div className={styles.labelArea}>
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
useState,
ChangeEvent,
KeyboardEvent,
MouseEvent,
useRef,
} from 'react';
import { useState, ChangeEvent, KeyboardEvent, useRef } from 'react';
import Avatar from '@/components/Avatar';
import Button from '@/components/Button';
import { formatDateToCustomFormat } from '@/utils/dateUtils';
Expand Down Expand Up @@ -58,7 +52,6 @@ export default function CommentDetail({
e.preventDefault();
handleSave();
toggleEditing();
// todo: ์ˆ˜์ •์„ฑ๊ณต์‹œ ํ† ์ŠคํŠธ ๋ฐ•์Šค
}
};

Expand All @@ -80,7 +73,6 @@ export default function CommentDetail({
const handleDeleteOnClick = async () => {
await deleteComment(id);
onDelete(id);
// todo: ์‚ญ์ œ์„ฑ๊ณต์‹œ ํ† ์ŠคํŠธ ๋ฐ•์Šค
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
'use client';

import { useRouter } from 'next/navigation';
import useIdStore from '@/store/idStore';
import Button from '@/components/Button';
import { deleteDashboard } from '@/lib/boardService';
import styles from './DeleteButton.module.css';
import useDashboardStore from '@/store/dashboardStore';
import useDashboardTriggerStore from '@/store/dashboardTriggerStore';

export default function DeleteButton() {
const id = useIdStore((state) => state.id);
const { dashboard, setDashboard } = useDashboardStore();
const { updateTrigger } = useDashboardTriggerStore();
const router = useRouter();

const handleClick = async () => {
await deleteDashboard(id);
await deleteDashboard(dashboard!.id.toString());
setDashboard(null);
updateTrigger();
router.replace('/mydashboard');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { Dashboard, UpdateDashboardRequestParams } from '@/types/dashboards';
import Button from '@/components/Button';
import DashboardInput from '@/components/DashboardInput';
import styles from './EditForm.module.css';
import useDashboardTriggerStore from '@/store/dashboardTriggerStore';

export default function EditForm() {
const { updateTrigger } = useDashboardTriggerStore();
const [board, setBoard] = useState<Dashboard>();
const id = useIdStore((state) => state.id);
const {
Expand All @@ -26,6 +28,7 @@ export default function EditForm() {

const onSubmit = async (data: UpdateDashboardRequestParams) => {
const response = await updateBoard(id, data);
updateTrigger();
setBoard(response);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useForm } from 'react-hook-form';
import Button from '@/components/Button';
import DashboardInput from '@/components/DashboardInput';
import styles from './CreateDashboardForm.module.css';
import { CreateDashboardRequestBody } from '@/types/dashboards';
import type { CreateDashboardRequestBody } from '@/types/dashboards';
import { createDashboard } from '@/lib/boardService';
import { useRouter } from 'next/navigation';
import useDashboardTriggerStore from '@/store/dashboardTriggerStore';
import styles from './CreateDashboardForm.module.css';

interface CreateDashboardFormProps {
closeModal: () => void;
Expand All @@ -13,6 +14,8 @@ interface CreateDashboardFormProps {
export default function CreateDashboardForm({
closeModal,
}: CreateDashboardFormProps) {
const { updateTrigger } = useDashboardTriggerStore();

const {
register,
handleSubmit,
Expand All @@ -23,6 +26,7 @@ export default function CreateDashboardForm({
const onSubmit = async (newDashboard: CreateDashboardRequestBody) => {
const response = await createDashboard(newDashboard);
closeModal();
updateTrigger();
router.push(`/dashboard/${response.id}`);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type {
Invitation,
AcceptMyInvitationRequestBody,
} from '@/types/invitation';
import styles from './MyInvitationCard.module.css';
import { updateMyInvitation } from '../../_lib/myInvitationService';
import styles from './MyInvitationCard.module.css';

interface MyInvitationCardProps extends Invitation {
onActionComplete: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface UseDashboardsParams {

export default function useDashboards({ pageSize }: UseDashboardsParams) {
const [page, setPage] = useState(1);
const { data } = useApi<GetDashboardsResponse>('/dashboards', {
const { data, refetch } = useApi<GetDashboardsResponse>('/dashboards', {
method: 'GET',
params: { navigationMethod: 'pagination', page, size: pageSize },
});
Expand All @@ -25,5 +25,5 @@ export default function useDashboards({ pageSize }: UseDashboardsParams) {
});
};

return { page, dashboards, totalPages, handlePageChange };
return { page, dashboards, totalPages, handlePageChange, refetch };
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axiosInstance from '@/lib/axiosInstance';
import { toast } from '@/store/toastStore';
import {
GetMyInvitationsRequestParam,
GetMyInvitationsResponse,
Expand Down Expand Up @@ -45,6 +46,10 @@ export const updateMyInvitation = async ({
requestBody
);

toast.success({
message: `${requestBody.inviteAccepted ? '์ˆ˜๋ฝ' : '๊ฑฐ์ ˆ'} ์™„๋ฃŒ!`,
});

return response.data;
} catch (error) {
throw error;
Expand Down
15 changes: 12 additions & 3 deletions src/components/sidebar/Dashboards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ import Button from '../Button';
import useDashboards from '@/app/(with-header-sidebar)/mydashboard/_hooks/useDashboards';
import useDashboardStore from '@/store/dashboardStore';
import styles from './Dashboards.module.css';
import { useEffect } from 'react';
import useDashboardTriggerStore from '@/store/dashboardTriggerStore';

const PAGE_SIZE = 12;

export default function Dashboards() {
const { page, dashboards, totalPages, handlePageChange } = useDashboards({
pageSize: PAGE_SIZE,
});
const { trigger } = useDashboardTriggerStore();

const { page, dashboards, totalPages, handlePageChange, refetch } =
useDashboards({
pageSize: PAGE_SIZE,
});

useEffect(() => {
refetch();
Copy link
Collaborator Author

@devmanta devmanta Nov 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๊ฑด useDashboards์—์„œ ๊ฐ€์ ธ๋‹ค์“ฐ๋Š” useApi๊ฐ€ ๊ตฌ์กฐ์ ์œผ๋กœ ๋ฌธ์ œ?๊ฐ€์žˆ์–ด์„œ (useApi ๋ถˆ๋Ÿฌ์˜ค๋ฉด ๋ฐ”๋กœapi๋ฅผ ๋จผ์ € ์จ)
์ตœ์ดˆ๋ Œ๋”๋ง๋ ๋•Œ 2๋ฒˆํ˜ธ์ถœํ•˜๋Š” ์ด์Šˆ ์žˆ์Šต๋‹ˆ๋‹ค^.^

}, [trigger]);

if (dashboards.length === 0) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/boardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const updateBoard = async (
title,
color,
});
toast.success({ message: '๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.' });
toast.success({ message: '๋Œ€์‹œ๋ณด๋“œ๊ฐ€ ์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.' });
return response.data;
} catch (error) {
if (error instanceof Error) {
Expand All @@ -42,6 +42,7 @@ export const createDashboard = async ({
title,
color,
});
toast.success({ message: '๋Œ€์‹œ๋ณด๋“œ๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.' });
return response.data;
} catch (error) {
throw error;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/commentService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axiosInstance from '@/lib/axiosInstance';
import { toast } from '@/store/toastStore';
import type {
CreateCommentRequestBody,
Comment,
Expand Down Expand Up @@ -59,6 +60,7 @@ export const updateComment = async ({
export const deleteComment = async (commentId: number) => {
try {
await axiosInstance.delete(`/comments/${commentId}`);
toast.success({ message: '๋Œ“๊ธ€์ด ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.' });
} catch (error) {
throw error;
}
Expand Down
13 changes: 13 additions & 0 deletions src/store/dashboardTriggerStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { create } from 'zustand';

interface DashboardTriggerStore {
trigger: boolean;
updateTrigger: () => void;
}

const useDashboardTriggerStore = create<DashboardTriggerStore>((set) => ({
trigger: false,
updateTrigger: () => set((state) => ({ trigger: !state.trigger })),
}));

export default useDashboardTriggerStore;