<!-- This is an auto-generated description by cubic. --> ## Summary by cubic Revamps onboarding with subtle route transitions, new org/teams illustrations, and clearer invite flows with real-time previews. Adds “Skip for now” on invites and guardrails to avoid incomplete team creation. - **New Features** - Added email invite pages for organizations and teams with shared EmailInviteForm and RoleSelector. - Built a live invite browser preview that renders a 3×3 grid and updates as you type; works for orgs and teams. - Applied route-keyed framer-motion transitions to layout, cards, and browser views for smoother page changes. - Continuation prompt now detects saved org or team and routes to the right next step; localized copy. - Added loading state to plan selection to prevent double navigation. - Refreshed Organizations welcome modal with a new animated ring illustration and better scrolling. - Added “Skip for now” to org and team invite-by-email steps to proceed without invites. - Calendar browser preview now focuses on a time window around “now” for a more realistic demo. - Added an optional floating footer to keep actions visible on long, scrollable lists. - **Refactors and Fixes** - Unified invite browser and replaced the org preview on the org email step. - Split and simplified legacy invite views; team and org routes are cleaner and easier to extend. - Streamlined the team invite step by removing a redundant action; non-admins are redirected to the email invite page. - Prevented creating teams with empty details by redirecting back to team details. - Minor UI cleanup: tighter borders, padding, and mobile max-heights across onboarding screens. - Hide team select on org invites when no teams exist. <sup>Written for commit ae7f5277ab998560ae6e2f3f9144852a7b4959a7. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
124 lines
3.7 KiB
TypeScript
124 lines
3.7 KiB
TypeScript
"use client";
|
|
|
|
import { useFormContext } from "react-hook-form";
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { Button } from "@calcom/ui/components/button";
|
|
import { Label, TextField, Select } from "@calcom/ui/components/form";
|
|
import { Icon } from "@calcom/ui/components/icon";
|
|
|
|
import type { InviteRole } from "../store/onboarding-store";
|
|
|
|
type BaseInviteFormData = {
|
|
email: string;
|
|
role: InviteRole;
|
|
};
|
|
|
|
type InviteFormDataWithOptionalTeam = BaseInviteFormData & {
|
|
team?: string;
|
|
};
|
|
|
|
type InviteFormDataWithRequiredTeam = BaseInviteFormData & {
|
|
team: string;
|
|
};
|
|
|
|
type InviteFormData = InviteFormDataWithOptionalTeam | InviteFormDataWithRequiredTeam;
|
|
|
|
type EmailInviteFormProps = {
|
|
fields: Array<{ id: string }>;
|
|
append: (value: InviteFormData) => void;
|
|
remove: (index: number) => void;
|
|
defaultRole: InviteRole;
|
|
showTeamSelect?: boolean;
|
|
teams?: Array<{ value: string; label: string }>;
|
|
emailPlaceholder?: string;
|
|
};
|
|
|
|
export function EmailInviteForm({
|
|
fields,
|
|
append,
|
|
remove,
|
|
defaultRole,
|
|
showTeamSelect = false,
|
|
teams = [],
|
|
emailPlaceholder,
|
|
}: EmailInviteFormProps) {
|
|
const { t } = useLocale();
|
|
const { register, watch, setValue } = useFormContext();
|
|
|
|
return (
|
|
<div className="flex h-full w-full flex-col gap-4">
|
|
<div className="flex flex-col gap-2">
|
|
{showTeamSelect ? (
|
|
<div className="grid grid-cols-2">
|
|
<Label className="text-emphasis mb-0 text-sm font-medium" htmlFor="invites.0.email">
|
|
{t("email")}
|
|
</Label>
|
|
<Label className="text-emphasis mb-0 text-sm font-medium" htmlFor="invites.0.team">
|
|
{t("team")}
|
|
</Label>
|
|
</div>
|
|
) : (
|
|
<Label className="text-emphasis mb-0 text-sm font-medium">{t("email")}</Label>
|
|
)}
|
|
|
|
<div
|
|
className={
|
|
showTeamSelect ? "flex flex-col gap-2" : "scroll-bar flex max-h-72 flex-col gap-1 overflow-y-auto"
|
|
}>
|
|
{fields.map((field, index) => (
|
|
<div key={field.id} className="flex items-start gap-0.5 p-0.5">
|
|
<div className={showTeamSelect ? "grid flex-1 items-start gap-2 md:grid-cols-2" : "flex-1"}>
|
|
<TextField
|
|
labelSrOnly
|
|
{...register(`invites.${index}.email`)}
|
|
placeholder={emailPlaceholder || `rick@cal.com`}
|
|
type="email"
|
|
size="sm"
|
|
/>
|
|
{showTeamSelect && (
|
|
<Select
|
|
size="sm"
|
|
options={teams}
|
|
value={teams.find((t) => t.value === watch(`invites.${index}.team`))}
|
|
onChange={(option) => {
|
|
if (option) {
|
|
setValue(`invites.${index}.team`, option.value);
|
|
}
|
|
}}
|
|
placeholder={t("select_team")}
|
|
/>
|
|
)}
|
|
</div>
|
|
<Button
|
|
type="button"
|
|
color="minimal"
|
|
variant="icon"
|
|
size="sm"
|
|
className="h-7 w-7"
|
|
disabled={fields.length === 1}
|
|
onClick={() => remove(index)}>
|
|
<Icon name="x" className="h-4 w-4" />
|
|
</Button>
|
|
</div>
|
|
))}
|
|
</div>
|
|
|
|
<Button
|
|
type="button"
|
|
color="secondary"
|
|
size="sm"
|
|
StartIcon="plus"
|
|
className={showTeamSelect ? "mt-2 w-fit" : "w-fit"}
|
|
onClick={() =>
|
|
append(
|
|
showTeamSelect ? { email: "", team: "", role: defaultRole } : { email: "", role: defaultRole }
|
|
)
|
|
}>
|
|
{t("add")}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|