From 32fc5a696d0366117f2e5eabe49b9883d7bd9a1b Mon Sep 17 00:00:00 2001 From: keyy1315 Date: Wed, 6 Aug 2025 17:09:11 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A1=B0=EC=82=AC=EB=A7=A4=EB=AC=BC=20?= =?UTF-8?q?placeholder=20=EB=AC=B8=EA=B5=AC=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - selectBox 컴포넌트 기타 선택 항목이 아닌 부분 분리 - installationAvailability 항목 placeholder 문구 추가 - 분리 된 공통 컴포넌트에 placeholder 문구 작성 함수 추가 구현 --- .../survey-sale/detail/RoofForm.tsx | 132 ++++++++++++++---- 1 file changed, 107 insertions(+), 25 deletions(-) diff --git a/src/components/survey-sale/detail/RoofForm.tsx b/src/components/survey-sale/detail/RoofForm.tsx index b47df22..6ae1e12 100644 --- a/src/components/survey-sale/detail/RoofForm.tsx +++ b/src/components/survey-sale/detail/RoofForm.tsx @@ -1,8 +1,8 @@ import { useEffect, useState } from 'react' import type { Mode, SurveyDetailInfo, SurveyDetailRequest } from '@/types/Survey' import { useAlertMsg, WARNING_MESSAGE } from '@/hooks/useAlertMsg' -import { radioEtcData, supplementaryFacilities } from '@/types/Survey' import { useSurveyOptionStore } from '@/store/surveyOptionStore' +import { radioEtcData, supplementaryFacilities } from '@/types/Survey' const makeNumArr = (value: string) => { return value @@ -20,6 +20,11 @@ export default function RoofForm(props: { const { showErrorAlert } = useAlertMsg() const [isFlip, setIsFlip] = useState(true) + const { selectBoxOptions, initialized, loading, loadOptions } = useSurveyOptionStore() + useEffect(() => { + if (!initialized && !loading) loadOptions() + }, [initialized, loading]) + const handleNumberInput = (key: keyof SurveyDetailRequest, value: number | string) => { /** 지붕 경사도, 노지판 두께 처리 - 최대 5자리, 소수점 1자리 처리 */ if (key === 'roofSlope' || key === 'openFieldPlateThickness') { @@ -135,7 +140,42 @@ export default function RoofForm(props: { {/* 건축 연수 */}
築年数
- + +
+ setRoofInfo({ ...roofInfo, constructionYearEtc: e.target.value })} + /> + +
@@ -251,7 +291,39 @@ export default function RoofForm(props: {
{/* 지붕 제품명 설치 가능 여부 확인 */}
屋根製品名 設置可否確認
- + +
+ setRoofInfo({ ...roofInfo, installationAvailabilityEtc: e.target.value })} + placeholder="屋根製品名が分かる場合は入力してください" + readOnly={mode === 'READ'} + /> +
{/* 메모 */} @@ -297,14 +369,10 @@ const SelectedBox = ({ const selectedId = detailInfoData?.[column as keyof SurveyDetailInfo] const etcValue = detailInfoData?.[`${column}Etc` as keyof SurveyDetailInfo] const [isEtcSelected, setIsEtcSelected] = useState(Boolean(etcValue)) - useEffect(() => { if (!initialized && !loading) loadOptions() }, [initialized, loading]) - const isSpecialCase = column === 'constructionYear' || column === 'installationAvailability' - const showEtcOption = !isSpecialCase - /** SelectBox 값 변경 처리 */ const handleSelectChange = (e: React.ChangeEvent) => { const value = e.target.value @@ -327,18 +395,21 @@ const SelectedBox = ({ /** Input box 비활성화 처리 * - 읽기 모드 : 비활성화 - * - 설치 가능 여부 : 기타 입력 창 항상 활성화 - * - 건축 연수 : 新築 신축 (N) 체크 시 비활성화 + * - 기타 선택 해제 시 비활성화 * */ const isInputDisabled = () => { if (mode === 'READ') return true - if (column === 'installationAvailability') return false - if (column === 'constructionYear') { - return detailInfoData.constructionYear === selectBoxOptions.constructionYear[0].code || detailInfoData.constructionYear === null - } return !isEtcSelected && !etcValue } + /** placeholder 설정 처리 */ + const setPlaceholder = (column: string) => { + switch (column) { + default: + return '-' + } + } + return ( <> -
+
- {column === 'constructionYear' && }
) @@ -453,6 +521,13 @@ const RadioSelected = ({ return !etcChecked && !etcValue } + const setPlaceholder = (column: string) => { + switch (column) { + default: + return '-' + } + } + return ( <> {radioEtcData[column as keyof typeof radioEtcData].map((item) => ( @@ -489,7 +564,7 @@ const RadioSelected = ({ id={`${column}Etc`} type="text" className="input-frame" - placeholder="-" + placeholder={setPlaceholder(column)} value={detailInfoData[`${column}Etc` as keyof SurveyDetailInfo]?.toString() ?? ''} onChange={handleEtcInputChange} readOnly={isInputDisabled()} @@ -580,6 +655,13 @@ const MultiCheck = ({ return mode === 'READ' || etcValue === null } + const setPlaceholder = (column: string) => { + switch (column) { + default: + return '-' + } + } + return ( <>
@@ -604,7 +686,7 @@ const MultiCheck = ({