fix: notify the backoffice of new booking

This commit is contained in:
Nathnael
2026-07-20 11:28:18 +00:00
parent 6420c72e89
commit 5bf82bf531
5 changed files with 64 additions and 13 deletions

View File

@@ -9,10 +9,11 @@ import {
Stack,
Text,
TextInput,
Tooltip,
} from "@mantine/core";
import { zodResolver } from "@hookform/resolvers/zod";
import { useQuery } from "@tanstack/react-query";
import { AlertCircle, ArrowLeft, ArrowRight } from "lucide-react";
import { AlertCircle, ArrowLeft, ArrowRight, Info } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { Controller, useForm } from "react-hook-form";
@@ -293,22 +294,28 @@ export default function CompanyProfileForm({
const [contactSameAsGm, setContactSameAsGm] = useState(false);
const [poaSameAsContact, setPoaSameAsContact] = useState(false);
// General Manager source: the eTrade-registered business owner when a TIN
// lookup found one, otherwise the registering user's own account details.
// General Manager source. The company step's email/phone are seeded from
// eTrade (and the account email) but stay editable, so the link reads the
// CURRENT form values rather than the frozen eTrade snapshot — an edit on the
// company step propagates here, the same way "Same as General Manager" tracks
// the general manager's live values. eTrade's owner name has no editable
// field of its own, so it falls back to the registering user's account name.
const companyEmail = watch("companyEmail");
const companyPhone = watch("companyPhone");
const gmSourceName = etradeOwner?.name ?? user.name?.en ?? "";
const gmSourcePhone = etradeOwner
? etradeOwner.phone
: toEthiopianE164(user.phoneNumber);
const gmSourceEmail = companyEmail || user.email || "";
const gmSourcePhone =
companyPhone || etradeOwner?.phone || toEthiopianE164(user.phoneNumber) || "";
useEffect(() => {
if (!gmSameAsOwner) return;
setValue("generalManagerName", gmSourceName, { shouldValidate: true });
setValue("generalManagerEmail", user.email ?? "", { shouldValidate: true });
setValue("generalManagerPhone", gmSourcePhone ?? "", {
setValue("generalManagerEmail", gmSourceEmail, { shouldValidate: true });
setValue("generalManagerPhone", gmSourcePhone, {
shouldValidate: true,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [gmSameAsOwner, gmSourceName, gmSourcePhone, user.email]);
}, [gmSameAsOwner, gmSourceName, gmSourceEmail, gmSourcePhone]);
const toggleGmSameAsOwner = (checked: boolean) => {
setGmSameAsOwner(checked);
@@ -624,7 +631,24 @@ export default function CompanyProfileForm({
{...register("vatNumber")}
/>
<TextInput
label="FAN Number (16 digits)"
label={
<Group gap={6} align="center" wrap="nowrap">
<span>FAN Number (16 digits)</span>
<Tooltip
label="The FAN must belong to the person with power of attorney. If the company has no power of attorney, use the general manager's FAN."
multiline
w={260}
withArrow
position="top-start"
>
<Info
size={14}
color="var(--mantine-color-gray-6)"
className="cursor-help"
/>
</Tooltip>
</Group>
}
placeholder="1234567890123456"
maxLength={16}
error={errors.fanNumber?.message}
@@ -743,8 +767,8 @@ export default function CompanyProfileForm({
title="Same as business owner"
description={
etradeOwner
? "Reuse the eTrade-registered owner's name and phone (email from your account). Uncheck to enter different details."
: "Reuse your account's name, email and phone. Uncheck to enter different details."
? "Reuse the eTrade-registered owner's name, plus the company email and phone as you entered them. Uncheck to enter different details."
: "Reuse your account's name and the company email and phone as you entered them. Uncheck to enter different details."
}
/>
<TextInput