* chore: refactor config files to prevent migration tool errors * refactor: upgrade with the tailwind migration tool * chore: restore pre-commit command + mc * refactor(wip): update dependencies and migrate to Tailwind CSS v4 (mainly web) * chore: resolve Tailwind v4 migration conflicts from merging main * chore: remove unused Tailwind packages from config and update dependencies for v4 migration * chore: uncomment Tailwind CSS utility classes in globals.css * fix: resolve token conflicts between calcom and coss ui * fix: textarea scrollbar * Fix CUI-16 * fix: added @tailwindcss/forms plugin and cleaned up CSS classes in various components to remove unnecessary dark mode styles * fix: selects and inputs of different sizes * fix: remove unnecessary leading-20 class from modal titles in various components * fix: update Checkbox component styles to remove unnecessary border on checked state * fix: clean up styles in RequiresConfirmationController, Checkbox, and Radio components to enhance consistency * fix: update button and filter component styles to remove unnecessary rounded classes for consistency * fix: calendar * fix: update KBarSearch * fix: refine styles in Empty and Checkbox components for improved consistency * Fix focus state email input * fix: update button hover and active states to use 'not-disabled' instead of 'enabled' * fix: line-height issues * fix: update class name for muted background in BookingListItem component * fix: sidebar spacing * chore: update class names to use new Tailwind CSS color utilities * fix embed * chore: upgrade Tailwind CSS to version 4.1.16 and update related dependencies * Map css variables and add a playground test for heavy css customization * suggestion for coss-ui * refactor: update CSS variable usage and clean up styles - Replace instances of `--cal-brand-color` with `--cal-brand` in embed-related HTML files. - Remove the now-unnecessary `addAppCssVars` function from the embed core. - Import theme tokens in the embed core styles for better consistency. - Clean up whitespace and formatting in CSS files for improved readability. - Add a comment in `tokens.css` regarding its usage in both embed and webapp contexts. * Handle within tokens.css instead of fixing coss-ui * Remove initial, not needed. Also, remove tailwind.config.js as tailwidn scans the html automaically * fix: examples app breaking * fix: modal not resizing correctly * feat: upgrade atoms to tailwind v4 * fix: atoms build breaking * fix: atoms build breaking * chore: upgrate examples/base to tailwind 4 * chore: update globals.css * fix: add missing scheduler css variables * fix: PlatformAdditionalCalendarSelector * chore: update global styles * chore: update tailwindcss and postcss dependencies to stable versions * chore: remove unneeded class * fix: dialog and toast animation * fix: replace flex-shrink-0 with shrink-0 for consistent styling in various components * fix: dialog modal for Apple connect * add margin in SaveFilterSegmentButton * Fix radix button nested states * add cursor pointer to buttons but keep dsabled state * Fix commandK selectors and adds cursor pointer * Fix teams filter * fix - round checkboxes * fix filter checkbox * fix select indicator's margin * command group font size * style: fix badge and tooltip radius * chore: remove unneeded files * Delete PR_REVIEW_MANAGED_EVENT_REASSIGNMENT.md * remove ui-playground leftover * fix: add missing react phone input styles in atoms * Delete managed-event-reassignment-flow-and-architecture.mermaid * fix: inter font not loading * Add theme to skeleton container so that it can support dark mode * fix: create custom stack-y-* utilities post tw4 upgrade * fix: typo * fix: atoms stack class + remove unused css file * fix default radius valiue * fix space-y in embed * fix skeleton background * Hardcode radius values to match production * fix border in embed * add missing externalThemeClass * feat: create a custom stack-y-* utility * fix: add stack utility to atom global css * fix: Skeleton loader class modalbox * Add stack-y utility in embed * fix: add missing stack utilities in atoms globals.css * update yarn.lock * add popover portla * update --------- Co-authored-by: Sean Brydon <sean@cal.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Ryukemeister <sahalrajiv6900@gmail.com> Co-authored-by: cal.com <morgan@cal.com> Co-authored-by: Eunjae Lee <hey@eunjae.dev> Co-authored-by: Anik Dhabal Babu <adhabal2002@gmail.com>
209 lines
6.7 KiB
TypeScript
209 lines
6.7 KiB
TypeScript
import { zodResolver } from "@hookform/resolvers/zod";
|
|
import classNames from "classnames";
|
|
import { signIn } from "next-auth/react";
|
|
import React from "react";
|
|
import { Controller, FormProvider, useForm } from "react-hook-form";
|
|
import { z } from "zod";
|
|
|
|
import { isPasswordValid } from "@calcom/lib/auth/isPasswordValid";
|
|
import { WEBSITE_URL } from "@calcom/lib/constants";
|
|
import { emailRegex } from "@calcom/lib/emailSchema";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { Button } from "@calcom/ui/components/button";
|
|
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
|
|
import { EmailField, Label, TextField, PasswordField } from "@calcom/ui/components/form";
|
|
|
|
export const AdminUserContainer = (props: React.ComponentProps<typeof AdminUser> & { userCount: number }) => {
|
|
const { t } = useLocale();
|
|
if (props.userCount > 0)
|
|
return (
|
|
<form
|
|
id="wizard-step-1"
|
|
name="wizard-step-1"
|
|
className="stack-y-4"
|
|
onSubmit={(e) => {
|
|
e.preventDefault();
|
|
props.onSuccess();
|
|
}}>
|
|
<EmptyScreen
|
|
Icon="user-check"
|
|
headline={t("admin_user_created")}
|
|
description={t("admin_user_created_description")}
|
|
/>
|
|
</form>
|
|
);
|
|
return <AdminUser {...props} />;
|
|
};
|
|
|
|
export const AdminUser = (props: {
|
|
onSubmit: () => void;
|
|
onError: () => void;
|
|
onSuccess: () => void;
|
|
nav: { onNext: () => void; onPrev: () => void };
|
|
}) => {
|
|
const { t } = useLocale();
|
|
|
|
const formSchema = z.object({
|
|
username: z
|
|
.string()
|
|
.refine((val) => val.trim().length >= 1, { message: t("at_least_characters", { count: 1 }) }),
|
|
email_address: z.string().regex(emailRegex, { message: t("enter_valid_email") }),
|
|
full_name: z.string().min(3, t("at_least_characters", { count: 3 })),
|
|
password: z.string().superRefine((data, ctx) => {
|
|
const isStrict = true;
|
|
const result = isPasswordValid(data, true, isStrict);
|
|
Object.keys(result).map((key: string) => {
|
|
if (!result[key as keyof typeof result]) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: [key],
|
|
message: key,
|
|
});
|
|
}
|
|
});
|
|
}),
|
|
});
|
|
|
|
type formSchemaType = z.infer<typeof formSchema>;
|
|
|
|
const formMethods = useForm<formSchemaType>({
|
|
mode: "onChange",
|
|
resolver: zodResolver(formSchema),
|
|
});
|
|
|
|
const onError = () => {
|
|
props.onError();
|
|
};
|
|
|
|
const onSubmit = formMethods.handleSubmit(async (data) => {
|
|
props.onSubmit();
|
|
const response = await fetch("/api/auth/setup", {
|
|
method: "POST",
|
|
body: JSON.stringify({
|
|
username: data.username.trim(),
|
|
full_name: data.full_name,
|
|
email_address: data.email_address.toLowerCase(),
|
|
password: data.password,
|
|
}),
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
});
|
|
if (response.status === 200) {
|
|
await signIn("credentials", {
|
|
redirect: false,
|
|
callbackUrl: "/",
|
|
email: data.email_address.toLowerCase(),
|
|
password: data.password,
|
|
});
|
|
props.onSuccess();
|
|
} else {
|
|
props.onError();
|
|
}
|
|
}, onError);
|
|
|
|
const longWebsiteUrl = WEBSITE_URL.length > 30;
|
|
|
|
return (
|
|
<FormProvider {...formMethods}>
|
|
<form id="wizard-step-1" name="wizard-step-1" className="stack-y-4" onSubmit={onSubmit}>
|
|
<div>
|
|
<Controller
|
|
name="username"
|
|
control={formMethods.control}
|
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
<>
|
|
<Label htmlFor="username" className={classNames(longWebsiteUrl && "mb-0")}>
|
|
<span className="block">{t("username")}</span>
|
|
{longWebsiteUrl && (
|
|
<small className="items-centerpx-3 bg-subtle border-default text-subtle mt-2 inline-flex rounded-t-md border border-b-0 px-3 py-1">
|
|
{process.env.NEXT_PUBLIC_WEBSITE_URL}
|
|
</small>
|
|
)}
|
|
</Label>
|
|
<TextField
|
|
addOnLeading={
|
|
!longWebsiteUrl && (
|
|
<span className="text-subtle inline-flex items-center rounded-none text-sm">
|
|
{process.env.NEXT_PUBLIC_WEBSITE_URL}/
|
|
</span>
|
|
)
|
|
}
|
|
id="username"
|
|
labelSrOnly={true}
|
|
value={value || ""}
|
|
className={classNames("my-0", longWebsiteUrl && "rounded-t-none")}
|
|
onBlur={onBlur}
|
|
name="username"
|
|
onChange={(e) => onChange(e.target.value)}
|
|
/>
|
|
</>
|
|
)}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<Controller
|
|
name="full_name"
|
|
control={formMethods.control}
|
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
<TextField
|
|
value={value || ""}
|
|
onBlur={onBlur}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
color={formMethods.formState.errors.full_name ? "warn" : ""}
|
|
type="text"
|
|
name="full_name"
|
|
autoCapitalize="none"
|
|
autoComplete="name"
|
|
autoCorrect="off"
|
|
className="my-0"
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<Controller
|
|
name="email_address"
|
|
control={formMethods.control}
|
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
<EmailField
|
|
value={value || ""}
|
|
onBlur={onBlur}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
className="my-0"
|
|
name="email_address"
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<Controller
|
|
name="password"
|
|
control={formMethods.control}
|
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
<PasswordField
|
|
value={value || ""}
|
|
onBlur={onBlur}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
hintErrors={["caplow", "admin_min", "num"]}
|
|
name="password"
|
|
className="my-0"
|
|
autoComplete="off"
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
<div className="flex justify-end gap-2">
|
|
<Button
|
|
type="submit"
|
|
color="primary"
|
|
loading={formMethods.formState.isSubmitting}
|
|
disabled={!formMethods.formState.isValid || formMethods.formState.isSubmitting}>
|
|
{t("next")}
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</FormProvider>
|
|
);
|
|
};
|