-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FEATURE] 공홈 어드민 지원하기 페이지 퍼블리싱 #130
Open
eonseok-jeon
wants to merge
9
commits into
feature-org-admin-common-3
Choose a base branch
from
feature-org-admin-apply
base: feature-org-admin-common-3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+693
−175
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d9bdde8
feat: react dropzone 구현
eonseok-jeon 86164a3
feat: dropzone 적용
eonseok-jeon 6feb3db
feat: 전체적인 틀 적용
eonseok-jeon e31a916
feat: part category component 생성
eonseok-jeon 61fc7aa
feat: 파트별 커리큘럼 ui 구현
eonseok-jeon cef968b
feat: 자주 묻는 질문 ui 구현
eonseok-jeon c4b5c43
feat: react-hook-form register 등록
eonseok-jeon ec0b931
fix: 이미지 입력 시 전체 에러 메세지 뜨는 에러 해결
eonseok-jeon 40f628b
refactor: 불필요한 props 제거
eonseok-jeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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,89 @@ | ||
'use client'; | ||
|
||
import { type MouseEvent, useCallback, useState } from 'react'; | ||
import { useDropzone } from 'react-dropzone'; | ||
import type { UseFormReturn } from 'react-hook-form'; | ||
|
||
import { VALIDATION_CHECK } from '@/utils/org'; | ||
|
||
import { StErrorMessage } from '../style'; | ||
import { | ||
StImgButton, | ||
StImgButtonWrapper, | ||
StImgIcon, | ||
StImgPreview, | ||
} from './style'; | ||
|
||
interface MyDropzoneProps { | ||
method: UseFormReturn; | ||
label: string; | ||
} | ||
|
||
const MyDropzone = ({ method, label }: MyDropzoneProps) => { | ||
const [previewUrl, setPreviewUrl] = useState<string | null>(null); | ||
const { | ||
register, | ||
setValue, | ||
formState: { errors }, | ||
} = method; | ||
|
||
const onDrop = useCallback( | ||
(acceptedFiles: File[]) => { | ||
const file = acceptedFiles[0]; | ||
if (file) { | ||
const reader = new FileReader(); | ||
reader.onloadend = () => { | ||
setPreviewUrl(reader.result as string); | ||
setValue(label, reader.result, { shouldValidate: true }); | ||
}; | ||
reader.readAsDataURL(file); | ||
} | ||
}, | ||
[label, setValue], | ||
); | ||
|
||
const handleClick = (e: MouseEvent<HTMLInputElement>) => { | ||
e.preventDefault(); | ||
}; | ||
|
||
const { getRootProps, getInputProps, isDragActive } = useDropzone({ | ||
onDrop, | ||
accept: { | ||
'image/jpeg': [], | ||
'image/jpg': [], | ||
'image/png': [], | ||
}, | ||
}); | ||
|
||
return ( | ||
<StImgButtonWrapper> | ||
<StImgButton | ||
{...getRootProps({ | ||
onClick: handleClick, // input의 클릭 이벤트 핸들링 | ||
})} | ||
isError={errors[label]?.message != undefined}> | ||
<input | ||
{...getInputProps({})} | ||
{...register(label, { | ||
required: true && VALIDATION_CHECK.required.errorText, | ||
})} | ||
{...getInputProps()} | ||
/> | ||
{previewUrl ? ( | ||
<StImgPreview src={previewUrl} alt="공홈 지원하기 탭 헤더 이미지" /> | ||
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. |
||
) : isDragActive ? ( | ||
<p>이미지를 드래그 해주세요...</p> | ||
) : ( | ||
<StImgIcon /> | ||
)} | ||
</StImgButton> | ||
{errors[label] && ( | ||
<StErrorMessage> | ||
<>{errors[label].message}</> | ||
</StErrorMessage> | ||
)} | ||
</StImgButtonWrapper> | ||
); | ||
}; | ||
|
||
export default MyDropzone; |
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,43 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
import { fontsObject } from '@sopt-makers/fonts'; | ||
import { IconImage } from '@sopt-makers/icons'; | ||
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. |
||
|
||
export const StImgButtonWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
`; | ||
|
||
interface StImgButtonProps { | ||
isError: boolean; | ||
} | ||
|
||
export const StImgButton = styled.div<StImgButtonProps>` | ||
${fontsObject.BODY_2_16_M} | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 547px; | ||
height: 166px; | ||
margin-top: 13px; | ||
color: ${colors.white}; | ||
background-color: ${colors.gray800}; | ||
border: ${({ isError }) => (isError ? `1px solid ${colors.error}` : 'none')}; | ||
border-radius: 10px; | ||
cursor: pointer; | ||
`; | ||
|
||
export const StImgIcon = styled(IconImage)` | ||
width: 24px; | ||
height: 24px; | ||
color: ${colors.white}; | ||
`; | ||
|
||
export const StImgPreview = styled.img` | ||
max-width: 547px; | ||
height: 166px; | ||
color: ${colors.white}; | ||
border-radius: 10px; | ||
`; |
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 { Chip } from '@sopt-makers/ui'; | ||
|
||
import { PART_LIST } from '@/utils/org'; | ||
|
||
import { StPartCategoryWrapper } from './style'; | ||
|
||
const PartCategory = () => { | ||
return ( | ||
<StPartCategoryWrapper> | ||
{PART_LIST.map((part) => ( | ||
<Chip key={`${part}-${part}`}>{part}</Chip> | ||
))} | ||
</StPartCategoryWrapper> | ||
); | ||
}; | ||
|
||
export default PartCategory; |
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,7 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const StPartCategoryWrapper = styled.div` | ||
display: flex; | ||
gap: 6px; | ||
align-items: center; | ||
`; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
react-dropzone이 생소해서 그럴 수 있는데
여기 input태그에 getInputProps가 두번 들어가있는데 의도하신건가유?