Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
StSNSWrapper,
} from './style';

const EXEC_INTRODUCTION_MAX_LENGTH = 23;

interface ExecInfoProps {
selectedExec: EXEC_TYPE;
isEditable?: boolean;
Expand Down Expand Up @@ -90,6 +92,7 @@ const ExecInfo = ({
placeholder="ex. 새로운 도전을 위해 과감히 용기내는 사람"
required
disabled={!isEditable}
maxLength={EXEC_INTRODUCTION_MAX_LENGTH}
/>

<StSNSWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import {
import {
EMPTY_REVIEW,
REVIEW_CONTENT_MAX_HEIGHT,
REVIEW_CONTENT_MAX_LENGTH,
REVIEW_CONTENT_MIN_HEIGHT,
REVIEW_TITLE_MAX_LENGTH,
} from '@/components/org/OrgAdmin/HomeSection/_constants/constants';
import { ReviewForm } from '@/components/org/OrgAdmin/HomeSection/_types/types';
import type { ReviewForm } from '@/components/org/OrgAdmin/HomeSection/_types/types';
import {
useEditReviewMutation,
useReviewQuery,
Expand Down Expand Up @@ -81,7 +83,14 @@ export const EditReviewModal = ({
};

const handleSubmit = () => {
if (!reviewId || !review.title || !review.content || !review.authorInfo) {
if (
!reviewId ||
!review.title ||
!review.content ||
!review.authorInfo ||
review.title.length > REVIEW_TITLE_MAX_LENGTH ||
(review.content?.length ?? 0) > REVIEW_CONTENT_MAX_LENGTH
) {
return;
}

Expand All @@ -99,7 +108,9 @@ export const EditReviewModal = ({
!reviewId ||
!review.title ||
!review.content ||
!review.authorInfo;
!review.authorInfo ||
review.title.length > REVIEW_TITLE_MAX_LENGTH ||
(review.content?.length ?? 0) > REVIEW_CONTENT_MAX_LENGTH;

return (
isOpen && (
Expand All @@ -114,6 +125,7 @@ export const EditReviewModal = ({
required
labelText="리뷰 제목"
descriptionText="공백 포함 최대 10자까지 작성할 수 있어요"
maxLength={REVIEW_TITLE_MAX_LENGTH}
placeholder="ex. 후회없는 활동"
/>
<StTextAreaWrapper ref={contentTextAreaRef}>
Expand All @@ -128,6 +140,7 @@ export const EditReviewModal = ({
descriptionText: '공백 포함 최대 200자까지 작성할 수 있어요',
}}
placeholder="ex. 좋은 사람들도 많이 만났고 기획분야를 제대로 배울 수 있었던 기회였어요. 대학생활 마지막 대외 활동이었지만, 회사 일을 하면서도 미련을 못버리고 메이커스나 솝텀을 기웃거려요. 엄청 오랜 기간동안 애정을 담고 있는 단체예요."
maxLength={REVIEW_CONTENT_MAX_LENGTH}
maxHeight={REVIEW_CONTENT_MAX_HEIGHT}
/>
</StTextAreaWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const DEPLOY_TOAST_OPTION: Record<'success' | 'error', ToastOptionType> =

export const REVIEW_CONTENT_MIN_HEIGHT = 104;
export const REVIEW_CONTENT_MAX_HEIGHT = 220;
export const REVIEW_TITLE_MAX_LENGTH = 10;
export const REVIEW_CONTENT_MAX_LENGTH = 200;

export const EMPTY_REVIEW: ReviewForm = {
title: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ const PartIntroSection = ({

const handleOneLineValidation = useCallback(
(value: string) => {
if (!value.trim()) {
setError(oneLineFieldName, {
type: 'required',
message: ERROR_MESSAGES.required,
});
return;
}

if (value.length > ONE_LINE_MAX_LENGTH) {
setError(oneLineFieldName, {
type: 'maxLength',
Expand Down
1 change: 1 addition & 0 deletions src/components/org/OrgAdmin/RecruitSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const RecruitSectionContent = () => {
return validationRecruitInputs(
getValues,
setError,
onChangeIntroPart,
onChangeCurriculumPart,
onChangeFnaPart,
);
Expand Down
36 changes: 33 additions & 3 deletions src/components/org/OrgAdmin/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { FieldValues } from 'react-hook-form';

import {
ONE_LINE_MAX_LENGTH,
ONE_LINE_MAX_LENGTH_ERROR_MESSAGE,
} from '@/components/org/OrgAdmin/RecruitSection/_constants/constants';
import { type PART_KO, PART_LIST, VALIDATION_CHECK } from '@/utils/org';

import { EXEC_ROLE_LIST, toMemberRole } from './AboutSection/memberRole';
Expand Down Expand Up @@ -206,14 +210,24 @@ export const validationAboutInputs = (
export const validationRecruitInputs = (
getValues: (payload?: string | string[]) => FieldValues,
setError: (name: string, error: { type: string; message: string }) => void,
setIntroPart: (introPart: PART_KO) => void,
setCurriculumPart: (curriculumPart: PART_KO) => void,
setFnaPart: (fnaPart: PART_KO) => void,
) => {
const { recruitHeaderImage, recruitPartCurriculum, recruitQuestion } =
getValues();

const fieldsToValidate = [
const fieldsToValidate: {
name: string;
value: unknown;
maxLength?: number;
}[] = [
{ name: 'recruitHeaderImage', value: recruitHeaderImage },
...PART_LIST.map((part) => ({
name: `partIntroduction${part}`,
value: getValues(`partIntroduction${part}`),
maxLength: ONE_LINE_MAX_LENGTH,
})),
...PART_LIST.flatMap((part) =>
['content', 'preference'].map((item) => ({
name: `recruitPartCurriculum.${part}.${item}`,
Expand All @@ -237,15 +251,31 @@ export const validationRecruitInputs = (

let isAllFilled = true;

for (const { name, value } of fieldsToValidate) {
if (!value) {
for (const { name, value, maxLength } of fieldsToValidate) {
if (typeof value === 'string' && maxLength && value.length > maxLength) {
isAllFilled = false;

setError(name, {
type: 'maxLength',
message: ONE_LINE_MAX_LENGTH_ERROR_MESSAGE,
});

if (name.startsWith('partIntroduction'))
setIntroPart(name.replace('partIntroduction', '') as PART_KO);

break;
}

if (!value || (typeof value === 'string' && !value.trim())) {
isAllFilled = false;

setError(name, {
type: 'required',
message: VALIDATION_CHECK.required.errorText,
});

if (name.startsWith('partIntroduction'))
setIntroPart(name.replace('partIntroduction', '') as PART_KO);
if (name.includes('recruitPartCurriculum'))
setCurriculumPart(name.split('.')[1] as PART_KO);
if (name.includes('recruitQuestion'))
Expand Down
Loading