-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat/CK-149] 골룸 인증피드 내부 전체 인증피드 도출 로직을 구현한다 #102
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,19 @@ import InputField from '@components/roadmapCreatePage/input/inputField/InputFiel | |
import { useValidateInput } from '@hooks/_common/useValidateInput'; | ||
import { CERTIFICATION_FEED } from '@constants/goalRoom/regex'; | ||
import TextCount from '@components/roadmapCreatePage/input/textCount/TextCount'; | ||
import { useCreateCertificationFeed } from '@hooks/queries/goalRoom'; | ||
import { | ||
useCertificationFeeds, | ||
useCreateCertificationFeed, | ||
} from '@hooks/queries/goalRoom'; | ||
import { useGoalRoomDashboardContext } from '@/context/goalRoomDashboardContext'; | ||
import { BASE_URL } from '@apis/axios/client'; | ||
|
||
const CertificationFeedModal = () => { | ||
const { goalroomId } = useGoalRoomDashboardContext(); | ||
const { certificationFeeds } = useCertificationFeeds(goalroomId); | ||
|
||
const [imagePreview, setImagePreview] = useState<string | null>(''); | ||
const [imageFile, setImageFile] = useState<File | null>(null); // add this state for file | ||
const [imageFile, setImageFile] = useState<File | null>(null); | ||
const { handleInputChange, validateInput, errorMessage, resetErrorMessage, value } = | ||
useValidateInput(CERTIFICATION_FEED); | ||
|
||
|
@@ -52,42 +57,68 @@ const CertificationFeedModal = () => { | |
<S.CertificationModalWrapper> | ||
<S.CertificationHeader>인증피드</S.CertificationHeader> | ||
<S.CertificationText>새로운 인증피드 등록</S.CertificationText> | ||
{imagePreview && ( | ||
<S.PreviewWrapper> | ||
<S.PreviewImage src={imagePreview} alt='업로드한 인증 피드 이미지' /> | ||
<S.PreviewDeleteButton onClick={handleRemoveImage}>X</S.PreviewDeleteButton> | ||
</S.PreviewWrapper> | ||
)} | ||
|
||
<form action='' onSubmit={handleFormSubmit}> | ||
{!imagePreview && ( | ||
<S.FileUploadCard htmlFor='fileInput'> | ||
<S.PlusButton>인증피드 사진 업로드</S.PlusButton> | ||
<input | ||
id='fileInput' | ||
type='file' | ||
onChange={handleImageChange} | ||
style={{ display: 'none' }} | ||
<S.CertificationFeedsWrapper> | ||
<form onSubmit={handleFormSubmit}> | ||
{imagePreview && ( | ||
<S.PreviewWrapper> | ||
<S.PreviewImage src={imagePreview} alt='업로드한 인증 피드 이미지' /> | ||
<S.PreviewDeleteButton onClick={handleRemoveImage}>X</S.PreviewDeleteButton> | ||
</S.PreviewWrapper> | ||
)} | ||
{!imagePreview && ( | ||
<S.FileUploadCard htmlFor='fileInput'> | ||
<S.PlusButton>인증피드 사진 업로드</S.PlusButton> | ||
<input | ||
id='fileInput' | ||
type='file' | ||
onChange={handleImageChange} | ||
style={{ display: 'none' }} | ||
/> | ||
</S.FileUploadCard> | ||
)} | ||
<S.InputFieldWrapper> | ||
<InputField | ||
placeholder='컨텐츠를 소개하는 문장을 작성해주세요' | ||
handleInputChange={handleInputChange} | ||
maxLength={250} | ||
validateInput={validateInput} | ||
resetErrorMessage={resetErrorMessage} | ||
name='introduction' | ||
data-valid={validateInput} | ||
/> | ||
</S.FileUploadCard> | ||
)} | ||
<S.InputFieldWrapper> | ||
<InputField | ||
placeholder='컨텐츠를 소개하는 문장을 작성해주세요' | ||
handleInputChange={handleInputChange} | ||
maxLength={250} | ||
validateInput={validateInput} | ||
resetErrorMessage={resetErrorMessage} | ||
name='introduction' | ||
data-valid={validateInput} | ||
/> | ||
</S.InputFieldWrapper> | ||
<TextCount maxCount={250} currentCount={value.length} /> | ||
<S.ErrorMessage>{errorMessage}</S.ErrorMessage> | ||
<S.CertificationSubmitButton type='submit'> | ||
인증피드 등록 | ||
</S.CertificationSubmitButton> | ||
</form> | ||
</S.InputFieldWrapper> | ||
<TextCount maxCount={250} currentCount={value.length} /> | ||
<S.ErrorMessage>{errorMessage}</S.ErrorMessage> | ||
<S.CertificationSubmitButton type='submit'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type='submit'은 없어도 무방할 것 같아요🤩 |
||
인증피드 등록 | ||
</S.CertificationSubmitButton> | ||
</form> | ||
|
||
{certificationFeeds.map((feed) => { | ||
return ( | ||
<S.CertificationFeedCard key={feed.checkFeed.id}> | ||
<S.CertificationFeedImage | ||
src={BASE_URL + feed.checkFeed.imageUrl} | ||
alt='인증피드 이미지' | ||
/> | ||
<S.CertificationFeedDescription> | ||
{feed.checkFeed.description} | ||
</S.CertificationFeedDescription> | ||
<S.CertificationFeedsUserInfo> | ||
<S.CertificationFeedsUserImage | ||
src={BASE_URL + feed.member.imageUrl} | ||
alt='유저 이미지' | ||
/> | ||
<S.CertificationFeedsUserName> | ||
{feed.member.nickname} | ||
</S.CertificationFeedsUserName> | ||
</S.CertificationFeedsUserInfo> | ||
<S.CreatedAtText>{feed.checkFeed.createdAt}</S.CreatedAtText> | ||
</S.CertificationFeedCard> | ||
); | ||
})} | ||
</S.CertificationFeedsWrapper> | ||
</S.CertificationModalWrapper> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,23 @@ export type JoinGoalRoomRequest = { | |
goalRoomId: string; | ||
roadmapId: string; | ||
}; | ||
|
||
export type UserType = { | ||
id: number; | ||
nickname: string; | ||
imageUrl: string; | ||
}; | ||
|
||
export type CheckFeedType = { | ||
id: number; | ||
imageUrl: string; | ||
description: string; | ||
createdAt: string; | ||
}; | ||
|
||
export type CertificationFeedType = { | ||
member: UserType; | ||
checkFeed: CheckFeedType; | ||
}; | ||
|
||
export type GoalRoomCertificationFeedsResponse = Array<CertificationFeedType>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
현재는 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
으으 이거 진짜진짜 어떤 느낌인지 아는데ㅠㅠ
그래도 스타일은 styled component에서 주는걸로 통일시키는 것은 어떨까요?