Skip to content

Commit

Permalink
feat: 정규식 체크
Browse files Browse the repository at this point in the history
  • Loading branch information
JJIIIINN committed Dec 27, 2023
1 parent 1054574 commit c4101b4
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/components/main/ExcelCashPaymentTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { cashPaymentTabType } from "../../models/response";
import ExcelValue from "./ExcelValue";
import { useEditExcelCash } from "../../utils/api/Allowance";
import { debounce } from "lodash";
import { regex } from "../../utils/functions/regex";

const ExcelCashPaymentTabBody = ({
data,
Expand Down Expand Up @@ -68,6 +69,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.serialNumber.test(serialNumber)}
/>
<ExcelValue
name="hangJungDong"
Expand All @@ -76,6 +78,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.hangjungdong.test(hangJungDong)}
/>
<ExcelValue
name="veteransNumber"
Expand All @@ -84,6 +87,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.veteransNumber.test(veteransNumber)}
/>
<ExcelValue
name="name"
Expand All @@ -92,6 +96,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.name.test(name)}
/>
<ExcelValue
name="residentRegistrationNumber"
Expand All @@ -100,6 +105,11 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={
!regex.residentRegistrationNumber.test(
residentRegistrationNumber
)
}
/>
<ExcelValue
name="address"
Expand All @@ -108,6 +118,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!address}
/>
<ExcelValue
name="depositType"
Expand All @@ -116,6 +127,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.depositType.test(depositType)}
/>
<ExcelValue
name="sibi"
Expand All @@ -124,6 +136,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!sibi}
/>
<ExcelValue
name="gubi"
Expand All @@ -132,6 +145,7 @@ const ExcelCashPaymentTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!gubi}
/>
<ExcelValue
name="note"
Expand Down
25 changes: 25 additions & 0 deletions src/components/main/ExcelPaymentStoppedTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { paymentStoppedTabType } from "../../models/response";
import ExcelValue from "./ExcelValue";
import { debounce } from "lodash";
import { useEditExcelStopped } from "../../utils/api/Allowance";
import { regex } from "../../utils/functions/regex";

const ExcelPaymentStoppedTabBody = ({
data,
Expand Down Expand Up @@ -76,6 +77,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.serialNumber.test(serialNumber)}
/>
<ExcelValue
name="hangJungDong"
Expand All @@ -84,6 +86,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.hangjungdong.test(hangJungDong)}
/>
<ExcelValue
name="veteransNumber"
Expand All @@ -92,6 +95,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.veteransNumber.test(veteransNumber)}
/>
<ExcelValue
name="name"
Expand All @@ -100,6 +104,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.name.test(name)}
/>
<ExcelValue
name="residentRegistrationNumber"
Expand All @@ -108,6 +113,11 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={
!regex.residentRegistrationNumber.test(
residentRegistrationNumber
)
}
/>
<ExcelValue
name="address"
Expand All @@ -116,6 +126,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!address}
/>
<ExcelValue
name="depositType"
Expand All @@ -124,6 +135,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.depositType.test(depositType)}
/>
<ExcelValue
name="bankName"
Expand All @@ -132,6 +144,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.bankName.test(bankName)}
/>
<ExcelValue
name="accountHolder"
Expand All @@ -140,6 +153,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.name.test(accountHolder)}
/>
<ExcelValue
name="bankAccountNumber"
Expand All @@ -148,6 +162,14 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={
!regex
.newBankAccountNumber(bankName.split(":")[0])
.test(bankAccountNumber) &&
!regex
.oldBankAccountNumber(bankName.split(":")[0])
.test(bankAccountNumber)
}
/>
<ExcelValue
name="stoppedReason"
Expand All @@ -156,6 +178,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!stoppedReason}
/>
<ExcelValue
name="stoppedDate"
Expand All @@ -164,6 +187,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.date.test(stoppedDate)}
/>
<ExcelValue
name="note"
Expand All @@ -180,6 +204,7 @@ const ExcelPaymentStoppedTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!transferAddress && stoppedReason === '전출'}
/>
</tr>
);
Expand Down
24 changes: 24 additions & 0 deletions src/components/main/ExcelPaymentTargetTabBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { paymentTargetTabType } from "../../models/response";
import ExcelValue from "./ExcelValue";
import { useEditExcelTarget } from "../../utils/api/Allowance";
import { debounce } from "lodash";
import { regex } from "../../utils/functions/regex";

const ExcelPaymentTargetTabBody = ({
data,
Expand Down Expand Up @@ -74,6 +75,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.serialNumber.test(serialNumber)}
/>
<ExcelValue
name="hangJungDong"
Expand All @@ -82,6 +84,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.hangjungdong.test(hangJungDong)}
/>
<ExcelValue
name="veteransNumber"
Expand All @@ -90,6 +93,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.veteransNumber.test(veteransNumber)}
/>
<ExcelValue
name="name"
Expand All @@ -98,6 +102,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.name.test(name)}
/>
<ExcelValue
name="residentRegistrationNumber"
Expand All @@ -106,6 +111,11 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={
!regex.residentRegistrationNumber.test(
residentRegistrationNumber
)
}
/>
<ExcelValue
name="address"
Expand All @@ -114,6 +124,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!address}
/>
<ExcelValue
name="depositType"
Expand All @@ -122,6 +133,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.depositType.test(depositType)}
/>
<ExcelValue
name="bankName"
Expand All @@ -130,6 +142,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.bankName.test(bankName)}
/>
<ExcelValue
name="accountHolder"
Expand All @@ -138,6 +151,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!regex.name.test(accountHolder)}
/>
<ExcelValue
name="bankAccountNumber"
Expand All @@ -146,6 +160,14 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={
!regex
.newBankAccountNumber(bankName.split(":")[0])
.test(bankAccountNumber) &&
!regex
.oldBankAccountNumber(bankName.split(":")[0])
.test(bankAccountNumber)
}
/>
<ExcelValue
name="sibi"
Expand All @@ -154,6 +176,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!sibi}
/>
<ExcelValue
name="gubi"
Expand All @@ -162,6 +185,7 @@ const ExcelPaymentTargetTabBody = ({
handleChange(e);
editExcelForm();
}}
error={!gubi}
/>
<ExcelValue
name="note"
Expand Down
16 changes: 10 additions & 6 deletions src/components/main/ExcelValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ const ExcelValue = ({
};

const Wrapper = styled.td<{ disabled: boolean; error: boolean }>`
border: 1px solid
${({ theme, error }) =>
error ? theme.colors.red : theme.colors.gray200};
border: 1px solid ${({ theme }) => theme.colors.gray200};
height: 56px;
background: ${({ theme, disabled }) =>
disabled ? theme.colors.gray100 : theme.colors.WHITE};
cursor: ${({ disabled }) => (disabled ? "not-allowed" : "text")};
background-color: ${({ theme, error }) =>
error ? "#FFB5B5" : theme.colors.WHITE};
cursor: "text";
&:disabled {
background: ${({ theme }) => theme.colors.gray100};
cursor: not-allowed;
}
> input {
max-width: 500px;
height: 100%;
Expand All @@ -66,6 +68,8 @@ const Wrapper = styled.td<{ disabled: boolean; error: boolean }>`
min-width: 150px;
padding: 0 20px;
color: ${({ theme }) => theme.colors.gray900};
background-color: ${({ theme, error }) =>
error ? "#FFB5B5" : theme.colors.WHITE};
&:disabled {
background: ${({ theme, disabled }) =>
disabled ? theme.colors.gray100 : theme.colors.WHITE};
Expand Down
Loading

0 comments on commit c4101b4

Please sign in to comment.