feat: SW-276 Optimized code
This commit is contained in:
@@ -19,14 +19,17 @@ export default function ChildSelector({ roomIndex = 0 }: ChildSelectorProps) {
|
||||
const children = guestsRoomsStore().rooms[roomIndex].children
|
||||
const { increaseChildren, decreaseChildren, childCount } = guestsRoomsStore()
|
||||
|
||||
function updateChildrenCount(direction: string, roomIndex: number) {
|
||||
if (direction == "up" && children.length < 5) {
|
||||
function increaseChildrenCount(roomIndex: number) {
|
||||
if (children.length < 5) {
|
||||
increaseChildren(roomIndex)
|
||||
setValue(`rooms.${roomIndex}.children.${children.length}`, {
|
||||
age: -1,
|
||||
bed: -1,
|
||||
})
|
||||
} else if (children.length > 0) {
|
||||
}
|
||||
}
|
||||
function decreaseChildrenCount(roomIndex: number) {
|
||||
if (children.length > 0) {
|
||||
decreaseChildren(roomIndex)
|
||||
let newChildrenList = JSON.parse(JSON.stringify(children))
|
||||
newChildrenList.pop()
|
||||
@@ -41,7 +44,7 @@ export default function ChildSelector({ roomIndex = 0 }: ChildSelectorProps) {
|
||||
<Button
|
||||
intent="text"
|
||||
size="small"
|
||||
onClick={() => updateChildrenCount("down", roomIndex)}
|
||||
onClick={() => decreaseChildrenCount(roomIndex)}
|
||||
>
|
||||
-
|
||||
</Button>
|
||||
@@ -49,7 +52,7 @@ export default function ChildSelector({ roomIndex = 0 }: ChildSelectorProps) {
|
||||
<Button
|
||||
intent="text"
|
||||
size="small"
|
||||
onClick={() => updateChildrenCount("up", roomIndex)}
|
||||
onClick={() => increaseChildrenCount(roomIndex)}
|
||||
>
|
||||
+
|
||||
</Button>
|
||||
|
||||
@@ -14,17 +14,11 @@ export type GuestsRoom = {
|
||||
}
|
||||
|
||||
export interface GuestsRoomsPickerProps {
|
||||
// handleOnSelect: (selected: GuestsRoom[]) => void
|
||||
// initialSelected?: GuestsRoom[]
|
||||
closePicker: () => void
|
||||
// isValid: boolean
|
||||
}
|
||||
|
||||
export type GuestsRoomPickerProps = {
|
||||
// handleOnSelect: (selected: GuestsRoom, index: number) => void
|
||||
// room: GuestsRoom
|
||||
index: number
|
||||
// isValid: boolean
|
||||
}
|
||||
|
||||
export type AdultSelectorProps = {
|
||||
|
||||
Reference in New Issue
Block a user