-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* design: 지출 추가, 인원 추가 button 퍼블리싱 * feat: 변경된 Button에 BottomSheet onClick연결 * chore: 디자인시스템 버전 업데이트 * feat: step.type이 Bill이 아니더라도 isAddEditableItem가 true라면 BillStepItem을 렌더링하여 지출 내역 추가 Input을 띄우기 * feat: onChange에 billInput 변경하기 및 blur시 조건을 충족할 경우 서버로 api 요청 보내기 * feat: 지출 내역 post api를 요청하면 지출 내역 Input을 닫기 * feat: 디자인시스템과의 병합을 위해 Input에 value 추가 * chore: 불필요한 주석 제거 * fix: 불필요한 조건문 제거 * chore: 불필요한 console.log 삭제 * feat: 마지막 BillItem에만 EditableItem.Input을 렌더링하기 * design: 관리 페이지 디자인 수정 * fix: billInput 값을 초기화 * feat: BillItem이 존재하지 않을 때, 새로운 BillItem을 생성하여 지출 input 만들기 * feat: member action 추가후, 빈 stepList가 생성되지 않는 에러 해결 * chore: 디자인시스템 업데이트 --------- Co-authored-by: 이태훈 <[email protected]>
- Loading branch information
Showing
8 changed files
with
246 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {useState} from 'react'; | ||
|
||
import validatePurchase from '@utils/validate/validatePurchase'; | ||
import {Bill} from 'types/serviceType'; | ||
|
||
import useRequestPostBillList from './queries/useRequestPostBillList'; | ||
import {BillInputType, InputPair} from './useDynamicBillActionInput'; | ||
|
||
interface UseSetBillInputProps { | ||
setIsAddEditableItem: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
interface UseSetBillInputReturns { | ||
billInput: Bill; | ||
handleChangeBillInput: (field: BillInputType, event: React.ChangeEvent<HTMLInputElement>) => void; | ||
handleBlurBillRequest: () => void; | ||
} | ||
|
||
const useSetBillInput = ({setIsAddEditableItem}: UseSetBillInputProps): UseSetBillInputReturns => { | ||
const initialInput = {title: '', price: 0}; | ||
const [billInput, setBillInput] = useState<Bill>(initialInput); | ||
|
||
const {mutate: postBillList} = useRequestPostBillList(); | ||
|
||
const handleChangeBillInput = (field: BillInputType, event: React.ChangeEvent<HTMLInputElement>) => { | ||
const {value} = event.target; | ||
const {isValid} = validatePurchase({ | ||
...billInput, | ||
[field]: value, | ||
}); | ||
|
||
if (isValid) { | ||
setBillInput(prev => ({ | ||
...prev, | ||
[field]: value, | ||
})); | ||
} | ||
}; | ||
|
||
const handleBlurBillRequest = () => { | ||
const isEmptyTitle = billInput.title.trim().length; | ||
const isEmptyPrice = Number(billInput.price); | ||
|
||
// 두 input의 값이 모두 채워졌을 때 api 요청 | ||
// api 요청을 하면 Input을 띄우지 않음 | ||
if (isEmptyTitle && isEmptyPrice) { | ||
postBillList( | ||
{billList: [billInput]}, | ||
{ | ||
onSuccess: () => { | ||
setBillInput(initialInput); | ||
setIsAddEditableItem(false); | ||
}, | ||
}, | ||
); | ||
} | ||
}; | ||
|
||
return { | ||
billInput, | ||
handleBlurBillRequest, | ||
handleChangeBillInput, | ||
}; | ||
}; | ||
|
||
export default useSetBillInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.