refactor: 거주자/장애인 중복 코드 제거

main
minuk926 3 years ago
parent c56debf764
commit e0648d19fe

@ -1,4 +1,5 @@
import { useState } from 'react'; import { useState } from 'react';
import _ from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
@ -151,68 +152,34 @@ const ModifyJudgeDataForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSav
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
<Grid item sm={3}> {_.range(1, 5, 1).map((idx) => (
<ImageFileTextForm labelName="단속사진1" fileName={rowData.scPicad1} handleViewImg={viewImg} methodName="getScPicad1" /> <ImageFileTextForm
</Grid> labelName={`단속사진${idx}`}
<Grid item sm={3}> fileName={rowData[`scPicad${idx}`]}
<ImageFileTextForm labelName="단속사진2" fileName={rowData.scPicad2} handleViewImg={viewImg} methodName="getScPicad2" /> handleViewImg={viewImg}
</Grid> methodName={`getScPicad${idx}`}
<Grid item sm={3}> />
<ImageFileTextForm labelName="단속사진3" fileName={rowData.scPicad3} handleViewImg={viewImg} methodName="getScPicad3" /> ))}
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="단속사진4" fileName={rowData.scPicad4} handleViewImg={viewImg} methodName="getScPicad4" />
</Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
<Grid item sm={3}> {_.range(1, 5, 1).map((idx) => (
<ImageFileTextForm labelName="진술서1" fileName={rowData.scFrecad1} handleViewImg={viewImg} methodName="getScFrecad1" /> <ImageFileTextForm
</Grid> labelName={`진술서${idx}`}
<Grid item sm={3}> fileName={rowData[`scFrecad${idx}`]}
<ImageFileTextForm labelName="진술서2" fileName={rowData.scFrecad2} handleViewImg={viewImg} methodName="getScFrecad2" /> handleViewImg={viewImg}
</Grid> methodName={`getScFrecad${idx}`}
<Grid item sm={3}> />
<ImageFileTextForm labelName="진술서3" fileName={rowData.scFrecad3} handleViewImg={viewImg} methodName="getScFrecad3" /> ))}
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="진술서4" fileName={rowData.scFrecad4} handleViewImg={viewImg} methodName="getScFrecad4" />
</Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
{/* {_.range(1, 9, 1).map((idx) => { */} {_.range(1, 9, 1).map((idx) => (
{/* // eslint-disable-next-line no-eval */} <ImageFileTextForm
{/* const fName = `rowData.scContad${idx}`; */} labelName={`첨부자료${idx}`}
{/* return ( */} fileName={rowData[`scContad${idx}`]}
{/* <Grid item sm={3}> */} handleViewImg={viewImg}
{/* <ImageFileTextForm labelName={`첨부자료${idx}`} fileName={fName} handleViewImg={viewImg} methodName={`getScContad${idx}`} /> */} methodName={`getScContad${idx}`}
{/* </Grid> */} />
{/* ); */} ))}
{/* })} */}
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료1" fileName={rowData.scContad1} handleViewImg={viewImg} methodName="getScContad1" />
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료2" fileName={rowData.scContad2} handleViewImg={viewImg} methodName="getScContad2" />
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료3" fileName={rowData.scContad3} handleViewImg={viewImg} methodName="getScContad3" />
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료4" fileName={rowData.scContad4} handleViewImg={viewImg} methodName="getScContad4" />
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료5" fileName={rowData.scContad5} handleViewImg={viewImg} methodName="getScContad5" />
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료6" fileName={rowData.scContad6} handleViewImg={viewImg} methodName="getScContad6" />
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료7" fileName={rowData.scContad7} handleViewImg={viewImg} methodName="getScContad7" />
</Grid>
<Grid item sm={3}>
<ImageFileTextForm labelName="첨부자료8" fileName={rowData.scContad8} handleViewImg={viewImg} methodName="getScContad8" />
</Grid>
</Grid> </Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>

@ -1,4 +1,5 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import _ from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
@ -309,210 +310,55 @@ const JudgeDataModifyForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSav
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
{_.range(1, 5, 1).map((idx) => (
<Grid item sm={3}> <Grid item sm={3}>
<FileInputForms <FileInputForms
isDisabled={false} isDisabled={idx === 1 ? false : typeof picads[`scPicad${idx - 1}`] === 'undefined'}
fieldName="scPicad" fieldName="scPicad"
index={1} index={idx}
labelName="단속사진1" labelName={`단속사진${idx}`}
fileName={rowData.scPicad1} fileName={rowData[`scPicad${idx}`]}
selectedFile={picads.scPicad1?.name} selectedFile={picads[`scPicad${idx}`]?.name}
handleChangeFile={handleChangeFile} handleChangeFile={handleChangeFile}
alert={alert} alert={alert}
isOrgFileInfo isOrgFileInfo
/> />
</Grid> </Grid>
<Grid item sm={3}> ))}
<FileInputForms
isDisabled={typeof picads.scPicad1 === 'undefined'}
fieldName="scPicad"
labelName="단속사진2"
index={2}
fileName={rowData.scPicad2}
selectedFile={picads.scPicad2?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof picads.scPicad2 === 'undefined'}
fieldName="scPicad"
labelName="단속사진3"
index={3}
fileName={rowData.scPicad3}
selectedFile={picads.scPicad3?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof picads.scPicad3 === 'undefined'}
fieldName="scPicad"
labelName="단속사진4"
index={4}
fileName={rowData.scPicad4}
selectedFile={picads.scPicad4?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
{_.range(1, 5, 1).map((idx) => (
<Grid item sm={3}> <Grid item sm={3}>
<FileInputForms <FileInputForms
isDisabled={false} isDisabled={idx === 1 ? false : typeof frecads[`scFrecad${idx - 1}`] === 'undefined'}
fieldName="scFrecad"
index={1}
labelName="진술서1"
fileName={rowData.scFrecad1}
selectedFile={frecads.scFrecad1?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof frecads.scFrecad1 === 'undefined'}
fieldName="scFrecad" fieldName="scFrecad"
labelName="진술서2" index={idx}
index={2} labelName={`진술서${idx}`}
fileName={rowData.scFrecad2} fileName={rowData[`scFrecad${idx}`]}
selectedFile={frecads.scFrecad2?.name} selectedFile={frecads[`scFrecad${idx}`]?.name}
handleChangeFile={handleChangeFile} handleChangeFile={handleChangeFile}
alert={alert} alert={alert}
isOrgFileInfo isOrgFileInfo
/> />
</Grid> </Grid>
<Grid item sm={3}> ))}
<FileInputForms
isDisabled={typeof frecads.scFrecad2 === 'undefined'}
fieldName="scFrecad"
labelName="진술서3"
index={3}
fileName={rowData.scFrecad3}
selectedFile={frecads.scFrecad3?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof frecads.scFrecad3 === 'undefined'}
fieldName="scFrecad"
labelName="진술서4"
index={4}
fileName={rowData.scFrecad4}
selectedFile={frecads.scFrecad4?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
{_.range(1, 9, 1).map((idx) => (
<Grid item sm={3}> <Grid item sm={3}>
<FileInputForms <FileInputForms
isDisabled={false} isDisabled={idx === 1 ? false : typeof contads[`scContad${idx - 1}`] === 'undefined'}
fieldName="scContad" fieldName="scContad"
labelName="첨부자료1" index={idx}
index={1} labelName={`첨부자료${idx}`}
fileName={rowData.scContad1} fileName={rowData[`scContad${idx}`]}
selectedFile={contads.scContad1?.name} selectedFile={contads[`scContad${idx}`]?.name}
handleChangeFile={handleChangeFile} handleChangeFile={handleChangeFile}
alert={alert} alert={alert}
isOrgFileInfo isOrgFileInfo
/> />
</Grid> </Grid>
<Grid item sm={3}> ))}
<FileInputForms
isDisabled={typeof contads.scContad1 === 'undefined'}
fieldName="scContad"
labelName="첨부자료2"
index={2}
fileName={rowData.scContad2}
selectedFile={contads.scContad2?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad2 === 'undefined'}
fieldName="scContad"
labelName="첨부자료3"
index={3}
fileName={rowData.scContad3}
selectedFile={contads.scContad3?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad3 === 'undefined'}
fieldName="scContad"
labelName="첨부자료4"
index={4}
fileName={rowData.scContad4}
selectedFile={contads.scContad4?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad4 === 'undefined'}
fieldName="scContad"
labelName="첨부자료5"
index={5}
fileName={rowData.scContad5}
selectedFile={contads.scContad5?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad5 === 'undefined'}
fieldName="scContad"
labelName="첨부자료6"
index={6}
fileName={rowData.scContad6}
selectedFile={contads.scContad6?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad6 === 'undefined'}
fieldName="scContad"
labelName="첨부자료7"
index={7}
fileName={rowData.scContad7}
selectedFile={contads.scContad7?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad7 === 'undefined'}
fieldName="scContad"
labelName="첨부자료8"
index={8}
fileName={rowData.scContad8}
selectedFile={contads.scContad8?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>

@ -1,4 +1,5 @@
import { useState } from 'react'; import { useState } from 'react';
import _ from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
@ -232,194 +233,52 @@ const JudgeDataNewForm = ({ scDatagb, contDocs, ingbs, handleModalSave }) => {
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
{_.range(1, 5, 1).map((idx) => (
<Grid item sm={3}> <Grid item sm={3}>
<FileInputForms <FileInputForms
isDisabled={false} isDisabled={idx === 1 ? false : typeof picads[`scPicad${idx - 1}`] === 'undefined'}
fieldName="scPicad" fieldName="scPicad"
index={1} index={idx}
labelName="단속사진1" labelName={`단속사진${idx}`}
selectedFile={picads.scPicad1?.name} selectedFile={picads[`scPicad${idx}`]?.name}
handleChangeFile={handleChangeFile} handleChangeFile={handleChangeFile}
alert={alert} alert={alert}
isOrgFileInfo isOrgFileInfo
/> />
</Grid> </Grid>
<Grid item sm={3}> ))}
<FileInputForms
isDisabled={typeof picads.scPicad1 === 'undefined'}
fieldName="scPicad"
labelName="단속사진2"
index={2}
selectedFile={picads.scPicad2?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof picads.scPicad2 === 'undefined'}
fieldName="scPicad"
labelName="단속사진3"
index={3}
selectedFile={picads.scPicad3?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof picads.scPicad3 === 'undefined'}
fieldName="scPicad"
labelName="단속사진4"
index={4}
selectedFile={picads.scPicad4?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
{_.range(1, 5, 1).map((idx) => (
<Grid item sm={3}> <Grid item sm={3}>
<FileInputForms <FileInputForms
isDisabled={false} isDisabled={idx === 1 ? false : typeof frecads[`scFrecad${idx - 1}`] === 'undefined'}
fieldName="scFrecad"
index={1}
labelName="진술서1"
selectedFile={frecads.scFrecad1?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof frecads.scFrecad1 === 'undefined'}
fieldName="scFrecad" fieldName="scFrecad"
labelName="진술서2" index={idx}
index={2} labelName={`진술서${idx}`}
selectedFile={frecads.scFrecad2?.name} selectedFile={frecads[`scFrecad${idx}`]?.name}
handleChangeFile={handleChangeFile} handleChangeFile={handleChangeFile}
alert={alert} alert={alert}
isOrgFileInfo isOrgFileInfo
/> />
</Grid> </Grid>
<Grid item sm={3}> ))}
<FileInputForms
isDisabled={typeof frecads.scFrecad2 === 'undefined'}
fieldName="scFrecad"
labelName="진술서3"
index={3}
selectedFile={frecads.scFrecad3?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof frecads.scFrecad3 === 'undefined'}
fieldName="scFrecad"
labelName="진술서4"
index={4}
selectedFile={frecads.scFrecad4?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>
{_.range(1, 9, 1).map((idx) => (
<Grid item sm={3}> <Grid item sm={3}>
<FileInputForms <FileInputForms
isDisabled={false} isDisabled={idx === 1 ? false : typeof contads[`scContad${idx - 1}`] === 'undefined'}
fieldName="scContad" fieldName="scContad"
index={1} index={idx}
labelName="첨부자료1" labelName={`첨부자료${idx}`}
selectedFile={contads.scContad1?.name} selectedFile={contads[`scContad${idx}`]?.name}
handleChangeFile={handleChangeFile} handleChangeFile={handleChangeFile}
alert={alert} alert={alert}
isOrgFileInfo isOrgFileInfo
/> />
</Grid> </Grid>
<Grid item sm={3}> ))}
<FileInputForms
isDisabled={typeof contads.scContad1 === 'undefined'}
fieldName="scContad"
labelName="첨부자료2"
index={2}
selectedFile={contads.scContad2?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad2 === 'undefined'}
fieldName="scContad"
labelName="첨부자료3"
index={3}
selectedFile={contads.scContad3?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad3 === 'undefined'}
fieldName="scContad"
labelName="첨부자료4"
index={4}
selectedFile={contads.scContad4?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad4 === 'undefined'}
fieldName="scContad"
index={5}
labelName="첨부자료5"
selectedFile={contads.scContad5?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad5 === 'undefined'}
fieldName="scContad"
labelName="첨부자료6"
index={6}
selectedFile={contads.scContad6?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad6 === 'undefined'}
fieldName="scContad"
labelName="첨부자료7"
index={7}
selectedFile={contads.scContad7?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={typeof contads.scContad7 === 'undefined'}
fieldName="scContad"
labelName="첨부자료8"
index={8}
selectedFile={contads.scContad8?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
<Grid container spacing={1} item xs={12} mt={1}> <Grid container spacing={1} item xs={12} mt={1}>

Loading…
Cancel
Save