Merged in fix/sw-1897-member-price-modal (pull request #1856)
fix(sw-1897): show member price modal immediately * fix(sw-1897): show member price modal immediately * Make checkbox fully controlled * Remove action in the store that wasn't used Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
@@ -9,6 +10,8 @@ import Caption from "@/components/TempDesignSystem/Text/Caption"
|
||||
import { useRoomContext } from "@/contexts/Details/Room"
|
||||
import { formatPrice } from "@/utils/numberFormatting"
|
||||
|
||||
import MemberPriceModal from "../../MemberPriceModal"
|
||||
|
||||
import styles from "./joinScandicFriendsCard.module.css"
|
||||
|
||||
import type { JoinScandicFriendsCardProps } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
@@ -18,7 +21,19 @@ export default function JoinScandicFriendsCard({
|
||||
name = "join",
|
||||
}: JoinScandicFriendsCardProps) {
|
||||
const intl = useIntl()
|
||||
const { room, roomNr } = useRoomContext()
|
||||
const {
|
||||
room,
|
||||
roomNr,
|
||||
actions: { updateJoin },
|
||||
} = useRoomContext()
|
||||
const [isMemberPriceModalOpen, setIsMemberPriceModalOpen] = useState(false)
|
||||
|
||||
function onChange(event: { target: { value: boolean } }) {
|
||||
updateJoin(event.target.value)
|
||||
if (event.target.value) {
|
||||
setIsMemberPriceModalOpen(true)
|
||||
}
|
||||
}
|
||||
|
||||
if (!("member" in room.roomRate) || !room.roomRate.member) {
|
||||
return null
|
||||
@@ -58,7 +73,11 @@ export default function JoinScandicFriendsCard({
|
||||
|
||||
return (
|
||||
<div className={styles.cardContainer}>
|
||||
<Checkbox name={name} className={styles.checkBox}>
|
||||
<Checkbox
|
||||
name={name}
|
||||
className={styles.checkBox}
|
||||
registerOptions={{ onChange, value: room.guest.join }}
|
||||
>
|
||||
<div>
|
||||
<Caption type="label" textTransform="uppercase" color="red">
|
||||
{saveOnJoiningLabel}
|
||||
@@ -88,6 +107,10 @@ export default function JoinScandicFriendsCard({
|
||||
</Caption>
|
||||
))}
|
||||
</div>
|
||||
<MemberPriceModal
|
||||
isOpen={isMemberPriceModalOpen}
|
||||
setIsOpen={setIsMemberPriceModalOpen}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user