Skip to content

Commit

Permalink
fix(nrm-booking): selecting logged in user in case of self service wh…
Browse files Browse the repository at this point in the history
…ile creating booking
  • Loading branch information
rockingrohit9639 committed Jun 10, 2024
1 parent d1a3db0 commit 9c1b4a5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/routes/_layout+/bookings.new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,15 @@ export async function loader({ context, request }: LoaderFunctionArgs) {
});
}

const selfServiceUser = isSelfService
? teamMembers.find((member) => member.userId === authSession.userId)
: undefined;

return json(
data({
showModal: true,
isSelfService,
selfServiceId: authSession.userId,
selfServiceUser,
teamMembers,
}),
{
Expand Down Expand Up @@ -192,8 +196,9 @@ export const handle = {

export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }];
export default function NewBooking() {
const { isSelfService, selfServiceId } = useLoaderData<typeof loader>();
const { isSelfService, selfServiceUser } = useLoaderData<typeof loader>();
const { startDate, endDate } = getBookingDefaultStartEndTimes();

return (
<div className="booking-inner-wrapper">
<header className="mb-5">
Expand All @@ -208,7 +213,15 @@ export default function NewBooking() {
<BookingForm
startDate={startDate}
endDate={endDate}
custodianUserId={isSelfService ? selfServiceId : undefined}
custodianUserId={
isSelfService
? JSON.stringify({
id: selfServiceUser?.id,
name: selfServiceUser?.name,
userId: selfServiceUser?.userId,
})
: undefined
}
/>
</div>
</div>
Expand Down

0 comments on commit 9c1b4a5

Please sign in to comment.