feat: SW-276 Optimized code

This commit is contained in:
Hrishikesh Vaipurkar
2024-10-10 13:44:33 +02:00
parent 2c6ef3fea7
commit f1f1434c9d
8 changed files with 45 additions and 51 deletions

View File

@@ -3,7 +3,7 @@
import { useFormContext } from "react-hook-form"
import { useIntl } from "react-intl"
import { guestsRoomsStore } from "@/stores/guests-rooms"
import { useGuestsRoomsStore } from "@/stores/guests-rooms"
import { MinusIcon, PlusIcon } from "@/components/Icons"
import Button from "@/components/TempDesignSystem/Button"
@@ -20,8 +20,8 @@ export default function ChildSelector({ roomIndex = 0 }: ChildSelectorProps) {
const intl = useIntl()
const childrenLabel = intl.formatMessage({ id: "Children" })
const { setValue } = useFormContext()
const children = guestsRoomsStore().rooms[roomIndex].children
const { increaseChildren, decreaseChildren, childCount } = guestsRoomsStore()
const { children } = useGuestsRoomsStore((state) => state.rooms[roomIndex])
const { increaseChildren, decreaseChildren } = useGuestsRoomsStore()
function increaseChildrenCount(roomIndex: number) {
if (children.length < 5) {