-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/#175-schedulingFeed' of https://github.com/98OO…
…/colla-frontend into feature/#175-schedulingFeed
- Loading branch information
Showing
21 changed files
with
594 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { axiosInstance } from '@apis/axiosInstance'; | ||
import { END_POINTS } from '@constants/api'; | ||
import type { SubTaskResponse } from '@type/feed'; | ||
|
||
const getCollectSubTask = async ( | ||
teamspaceId: number, | ||
feedId: number, | ||
userId: number | ||
): Promise<SubTaskResponse> => { | ||
const response = await axiosInstance.get( | ||
`${END_POINTS.GET_COLLECT_SUB_TASK(teamspaceId, feedId, userId)}` | ||
); | ||
|
||
return response.data.content; | ||
}; | ||
|
||
export default getCollectSubTask; |
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,28 @@ | ||
import { axiosInstance } from '@apis/axiosInstance'; | ||
import { END_POINTS } from '@constants/api'; | ||
|
||
export interface CollectSubTaskParams { | ||
teamspaceId: number | undefined; | ||
feedId: number; | ||
title: string | null; | ||
content: string | null; | ||
} | ||
|
||
const patchCollectSubTask = async ({ | ||
teamspaceId, | ||
feedId, | ||
title, | ||
content, | ||
}: CollectSubTaskParams) => { | ||
const response = await axiosInstance.patch( | ||
`${END_POINTS.PATCH_COLLECT_SUB_TASK(teamspaceId!, feedId)}`, | ||
{ | ||
title, | ||
content, | ||
} | ||
); | ||
|
||
return response.data; | ||
}; | ||
|
||
export default patchCollectSubTask; |
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,25 @@ | ||
import { axiosInstance } from '@apis/axiosInstance'; | ||
import { END_POINTS } from '@constants/api'; | ||
import type { CollectFeedForm } from '@type/feed'; | ||
|
||
const postCollectFeed = async ({ | ||
teamspaceId, | ||
title, | ||
images, | ||
attachments, | ||
details, | ||
}: CollectFeedForm) => { | ||
const response = await axiosInstance.post( | ||
`${END_POINTS.POST_COLLECT_FEED(teamspaceId)}`, | ||
{ | ||
title, | ||
images, | ||
attachments, | ||
details, | ||
} | ||
); | ||
|
||
return response.data; | ||
}; | ||
|
||
export default postCollectFeed; |
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
24 changes: 24 additions & 0 deletions
24
src/components/Feed/Detail/SubTask/SubTaskDetail.styled.ts
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,24 @@ | ||
import { styled } from 'styled-components'; | ||
import { editorStyles } from '@styles/editorStyles'; | ||
import theme from '@styles/theme'; | ||
|
||
export const SubTaskPostContainer = styled.form` | ||
display: flex; | ||
flex-direction: column; | ||
width: 680px; | ||
gap: ${theme.units.spacing.space32}; | ||
`; | ||
|
||
export const PostInput = styled.input` | ||
font-size: ${theme.typography.fontSize.header.sm}; | ||
font-weight: ${theme.typography.fontWeight.semiBold}; | ||
border: none; | ||
outline: none; | ||
`; | ||
|
||
export const DetailWrapper = styled.div` | ||
${editorStyles} | ||
margin-bottom: ${theme.units.spacing.space48}; | ||
width: 732px; | ||
min-height: 150px; | ||
`; |
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,103 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { Button } from '@components/common/Button/Button'; | ||
import Divider from '@components/common/Divider/Divider'; | ||
import Flex from '@components/common/Flex/Flex'; | ||
import Heading from '@components/common/Heading/Heading'; | ||
import FeedAuthor from '@components/Feed/FeedAuthors/FeedAuthor'; | ||
import Editor from '@components/Post/Editor/Editor'; | ||
import usePostEditor from '@hooks/post/usePostEditor'; | ||
import useCollectSubTaskMutation from '@hooks/queries/Feed/Collect/useCollectSubTaskMutation'; | ||
import useCollectSubTaskQuery from '@hooks/queries/Feed/Collect/useCollectSubTaskQuery'; | ||
import useUserStatusQuery from '@hooks/queries/useUserStatusQuery'; | ||
import { getFormattedDate } from '@utils/getFormattedDate'; | ||
import type { Author } from '@type/feed'; | ||
import * as S from './SubTaskDetail.styled'; | ||
|
||
interface SubTaskPostProps { | ||
subTaskAuthor: Author; | ||
feedId: number; | ||
} | ||
|
||
const SubTaskDetail = ({ subTaskAuthor, feedId }: SubTaskPostProps) => { | ||
const { id } = subTaskAuthor; | ||
const { editorRef, appendImageFile } = usePostEditor(); | ||
const { userStatus } = useUserStatusQuery(); | ||
const { subTask } = useCollectSubTaskQuery( | ||
userStatus?.profile.lastSeenTeamspaceId, | ||
feedId, | ||
id | ||
); | ||
const [title, setTitle] = useState<string | null>(null); | ||
const { mutateCollectSubTask } = useCollectSubTaskMutation( | ||
userStatus?.profile.lastSeenTeamspaceId, | ||
feedId | ||
); | ||
|
||
useEffect(() => { | ||
if (subTask) setTitle(subTask.title); | ||
}, [subTask]); | ||
|
||
const handleTitleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setTitle(event.target.value); | ||
}; | ||
|
||
const handleSubmitSubTask = async () => { | ||
if (editorRef.current && editorRef.current.getHTML() !== undefined) { | ||
const content = editorRef.current.getHTML(); | ||
|
||
await mutateCollectSubTask({ | ||
teamspaceId: userStatus?.profile.lastSeenTeamspaceId, | ||
feedId, | ||
title, | ||
content: content === '<p></p>' ? null : content, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<Flex> | ||
{id === userStatus?.profile.userId ? ( | ||
<S.SubTaskPostContainer> | ||
<S.PostInput | ||
placeholder='제목을 입력해주세요' | ||
value={title || ''} | ||
onChange={handleTitleChange} | ||
maxLength={50} | ||
/> | ||
<Editor editorRef={editorRef} appendImageFile={appendImageFile} /> | ||
<Flex justify='flex-end'> | ||
<Button | ||
label='수정' | ||
variant='primary' | ||
size='md' | ||
onClick={handleSubmitSubTask} | ||
/> | ||
</Flex> | ||
</S.SubTaskPostContainer> | ||
) : ( | ||
subTask && ( | ||
<Flex direction='column' gap='24'> | ||
<FeedAuthor | ||
profile={subTask.author.profileImageUrl} | ||
initial={subTask.author.username.charAt(0)} | ||
title={subTask.author.username} | ||
createdAt={getFormattedDate(subTask.updatedAt, 'detail')} | ||
tag={subTask.author.tag?.name || ''} | ||
/> | ||
<Flex direction='column' gap='12'> | ||
{subTask.title && <Heading size='xs'>{subTask.title}</Heading>} | ||
<Divider size='sm' /> | ||
<S.DetailWrapper> | ||
<div | ||
dangerouslySetInnerHTML={{ __html: subTask.content || '' }} | ||
/> | ||
</S.DetailWrapper> | ||
</Flex> | ||
</Flex> | ||
) | ||
)} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default SubTaskDetail; |
Oops, something went wrong.