Skip to content

Commit

Permalink
fix: TitleStep에서 PriceStep으로 이동했을 때, billInfo.price 초기화되던 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Todari committed Sep 23, 2024
1 parent 103de8f commit 6cc2d9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ export type KeyboardType = 'number' | 'string' | 'amount';
interface Props {
type: KeyboardType;
maxNumber: number;
initialValue?: string;
onChange: (value: string) => void;
}

export default function NumberKeyboard({type, maxNumber, onChange}: Props) {
export default function NumberKeyboard({type, maxNumber, initialValue, onChange}: Props) {
const {theme} = useTheme();
const amountKeypads = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '00', '0', '<-'];
const numberKeypads = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '', '0', '<-'];

const {onClickKeypad, onClickDelete, onClickDeleteAll, onClickAddAmount} = useNumberKeyboard({
type,
initialValue,
maxNumber,
onChange,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import {KeyboardType} from './NumberKeyboard';
interface Props {
type: KeyboardType;
maxNumber?: number;
initialValue?: string;
onChange: (value: string) => void;
}

const useNumberKeyboard = ({type, maxNumber, onChange}: Props) => {
const [value, setValue] = useState('');
const useNumberKeyboard = ({type, maxNumber, initialValue, onChange}: Props) => {
const [value, setValue] = useState(initialValue ?? '');

const onClickKeypad = (inputValue: string) => {
const newValue = (value + inputValue).replace(/,/g, '');
Expand Down
7 changes: 6 additions & 1 deletion client/src/pages/BillPage/steps/PriceStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ const PriceStep = ({billInfo, setBillInfo, setStep}: Props) => {
bottom: 6.25rem;
`}
>
<NumberKeyboard type="amount" maxNumber={10000000} onChange={handleNumberKeyboardChange} />
<NumberKeyboard
type="amount"
maxNumber={10000000}
initialValue={billInfo.price}
onChange={handleNumberKeyboardChange}
/>
</div>
<FixedButton disabled={!billInfo.price} onClick={handleNextStep} onBackClick={() => navigate(-1)}>
다음으로
Expand Down

0 comments on commit 6cc2d9e

Please sign in to comment.