feat: SW-276 Optimized code

This commit is contained in:
Hrishikesh Vaipurkar
2024-10-07 16:13:07 +02:00
parent 4c82add3bc
commit 9dbd10afdd
2 changed files with 8 additions and 11 deletions

View File

@@ -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>

View File

@@ -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 = {