Skip to content

Commit bc4565b

Browse files
committed
[#96] feat: 토스트 적용
1 parent d0e2789 commit bc4565b

File tree

9 files changed

+245
-7
lines changed

9 files changed

+245
-7
lines changed

components.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "src/app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@
1111
"dependencies": {
1212
"@tanstack/react-query": "^5.82.0",
1313
"axios": "^1.10.0",
14+
"class-variance-authority": "^0.7.1",
1415
"clsx": "^2.1.1",
1516
"date-fns": "^4.1.0",
1617
"dayjs": "^1.11.13",
1718
"framer-motion": "^12.23.0",
19+
"lucide-react": "^0.534.0",
1820
"next": "15.3.5",
21+
"next-themes": "^0.4.6",
1922
"react": "^19.0.0",
2023
"react-datepicker": "^8.4.0",
2124
"react-daum-postcode": "^3.2.0",
2225
"react-dom": "^19.0.0",
2326
"react-kakao-maps-sdk": "^1.2.0",
27+
"sonner": "^2.0.6",
2428
"tailwind-merge": "^3.3.1",
2529
"zustand": "^5.0.6"
2630
},
@@ -39,6 +43,7 @@
3943
"prettier": "^3.6.2",
4044
"prettier-plugin-tailwindcss": "^0.6.13",
4145
"tailwindcss": "^4",
46+
"tw-animate-css": "^1.3.6",
4247
"typescript": "^5"
4348
}
4449
}

pnpm-lock.yaml

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/(with-header)/myactivity/[id]/components/EditActivityForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function EditActivityForm() {
2222
subImages,
2323
dates,
2424
isLoading,
25-
error,
25+
isError,
2626
setTitle,
2727
setCategory,
2828
setPrice,
@@ -39,7 +39,7 @@ export default function EditActivityForm() {
3939
} = useEditActivityForm();
4040

4141
if (isLoading) return <div>로딩 중...</div>;
42-
if (error) return <div>오류가 발생했습니다: {error.message}</div>;
42+
if (isError) return <div>오류가 발생했습니다: {isError}</div>;
4343

4444
return (
4545
<div className='min-h-screen bg-gray-50 px-4 py-8 sm:px-6 lg:px-8'>

src/app/(with-header)/myactivity/[id]/hooks/useEditActivityForm.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { privateInstance } from '@/apis/privateInstance';
77
import { uploadImage } from '../../utils/uploadImage';
88
import { ActivityDetailEdit, Schedule } from '@/types/activityDetailType';
99
import { AxiosError } from 'axios';
10+
import { toast } from 'sonner';
1011

1112
interface SubImageType {
1213
id?: number;
@@ -31,7 +32,7 @@ export const useEditActivityForm = () => {
3132
const [originalSchedules, setOriginalSchedules] = useState<Schedule[]>([]);
3233
const [dates, setDates] = useState<Schedule[]>([]);
3334

34-
const { data, isLoading, error } = useQuery<ActivityDetailEdit, Error>({
35+
const { data, isLoading, isError } = useQuery<ActivityDetailEdit, Error>({
3536
queryKey: ['edit-activity', id],
3637
queryFn: async () => {
3738
const res = await privateInstance.get(`/activities/${id}`);
@@ -151,17 +152,18 @@ export const useEditActivityForm = () => {
151152

152153
await privateInstance.patch(`/editActivity/${id}`, payload);
153154

154-
alert('수정이 완료되었습니다.'); //토스트로 대체
155+
toast.success('수정되었습니다!'); //토스트로 대체
155156
queryClient.invalidateQueries({ queryKey: ['activity', id] });
156157
router.push(`/activities/${id}`);
157158
} catch (err) {
158159
const error = err as AxiosError;
159160
const responseData = error.response?.data as
160161
| { error?: string; message?: string }
161162
| undefined;
163+
162164
console.error('전체 에러:', error);
163-
alert(
164-
//토스트로대체
165+
166+
toast.error(
165167
responseData?.error ||
166168
responseData?.message ||
167169
error.message ||
@@ -180,7 +182,7 @@ export const useEditActivityForm = () => {
180182
subImages,
181183
dates,
182184
isLoading,
183-
error,
185+
isError,
184186
setTitle,
185187
setCategory,
186188
setPrice,

0 commit comments

Comments
 (0)