Skip to content

Commit

Permalink
fix: 계좌번호 입력 확인 버튼 활성화가 되지 않는 버그, 빈 값일 때 새로운 값이 반영되지 않는 버그 (#602)
Browse files Browse the repository at this point in the history
* fix: can submit 조건이 잘못됐던 버그 수정

* fix: 새로운 데이터가 빈 값인지를 체크하는 것으로 변경
  • Loading branch information
jinhokim98 authored Sep 26, 2024
1 parent 6afae59 commit ef24cea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/src/hooks/useAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const useAccount = () => {
const getChangedField = () => {
const changedField: Partial<Event> = {};

if (bankName.trim() !== '' && bankName !== bankNameState) {
if (bankNameState.trim() !== '' && bankName !== bankNameState) {
changedField.bankName = bankNameState;
}

if (accountNumber.trim() !== '' && accountNumber !== accountNumberState) {
if (accountNumberState.trim() !== '' && accountNumber !== accountNumberState) {
changedField.accountNumber = accountNumberState;
}

Expand All @@ -46,11 +46,11 @@ const useAccount = () => {
};

useEffect(() => {
const existEmptyField = bankName.trim() === '' && accountNumber.trim() === '';
const existEmptyField = bankNameState.trim() === '' || accountNumberState.trim() === '';
const isChanged = bankName !== bankNameState || accountNumber !== accountNumberState;

setCanSubmit(!existEmptyField && isChanged);
}, [bankName, accountNumber, bankNameState, accountNumberState]);
}, [bankNameState, accountNumberState]);

return {
bankName: bankNameState,
Expand Down

0 comments on commit ef24cea

Please sign in to comment.