-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d5dfd1
commit 00b43bb
Showing
30 changed files
with
343 additions
and
426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react"; | ||
import { styled } from "styled-components"; | ||
|
||
interface Props { | ||
title: string; | ||
onClick: () => void; | ||
} | ||
const List = ({ title, onClick }: Props) => { | ||
return ( | ||
<> | ||
<ListDiv onClick={onClick}> | ||
<StyledH3>{title}</StyledH3> | ||
</ListDiv> | ||
</> | ||
); | ||
}; | ||
|
||
export default List; | ||
|
||
export const ListDiv = styled.div` | ||
width: 100%; | ||
height: 100px; | ||
border-bottom: ${({ theme }) => theme.boxBorder.bookBorder}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
const StyledH3 = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 30pt; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { get } from "@/libs/api"; | ||
import { DiaryContent } from "@/types/diary"; | ||
import { queryKeys } from "@/utils/constants"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
const getDiaryByFriendId = async (friendId: number) => { | ||
const res = await get<{ data: DiaryContent[] }>( | ||
`/apis/v1/diary/read/friend/${friendId}?page=100&size=100` | ||
); | ||
|
||
return { data: res.data }; | ||
}; | ||
export const useGetListByFriendId = (friendId: number) => { | ||
const { data } = useQuery({ | ||
queryFn: () => getDiaryByFriendId(friendId), | ||
queryKey: [queryKeys.diaryList, friendId], | ||
}); | ||
|
||
return { data }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import useCurrentUser from "@/hooks/useAuth"; | ||
import { useToast } from "@/hooks/useToast"; | ||
import { post } from "@/libs/api"; | ||
import { queryClient } from "@/libs/queryClient"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
interface ISubmitDiary { | ||
title: string; | ||
content: string; | ||
sing: ""; | ||
friendId: number; | ||
} | ||
const submitDiary = async (id: number, params: ISubmitDiary) => { | ||
const res = await post(`/apis/v1/diary/create?id=${id}`, params); | ||
console.log("res"); | ||
return { res }; // 성공적인 경우 데이터 반환 | ||
}; | ||
|
||
export const useSubmitDiary = () => { | ||
const { toastOpen, toastClose, toastMessage } = useToast(); | ||
const navigate = useNavigate(); | ||
const { currentUser } = useCurrentUser(); | ||
|
||
const { mutate } = useMutation({ | ||
mutationFn: (params: ISubmitDiary) => | ||
submitDiary(currentUser.senderId, params), | ||
|
||
onSuccess: ({ res }) => { | ||
console.log("res", res); | ||
toastOpen("일기 작성에 성공했습니다"); | ||
queryClient.clear(); | ||
setTimeout(() => { | ||
navigate("/"); | ||
}, 1000); | ||
}, | ||
onError: () => { | ||
toastOpen("오류가 발생했습니다"); | ||
}, | ||
}); | ||
return { mutate, toastClose, toastMessage }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.