+9








a9af2fb255
* Implementation * i18n * More i18n * extracted i18n, needs api to get most recent price, added hint: update later * Fixing i18n var * Fix booking filters not working for admin (#6576) * fix: react-select overflow issue in some modals. (#6587) * feat: add a disable overflow prop * feat: use the disable overflow prop * Tailwind Merge (#6596) * Tailwind Merge * Fix merge classNames * [CAL-808] /availability/single - UI issue on buttons beside time inputs (#6561) * [CAL-808] /availability/single - UI issue on buttons beside time inputs * Update apps/web/public/static/locales/en/common.json * Update packages/features/schedules/components/Schedule.tsx * create new translation for tooltip Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> * Bye bye submodules (#6585) * WIP * Uses ssh instead * Update .gitignore * Update .gitignore * Update Makefile * Update git-setup.sh * Update git-setup.sh * Replaced Makefile with bash script * Update package.json * fix: show button on empty string (#6601) Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * fix: add delete in dropdown (#6599) Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * Update README.md * Update README.md * Changed a neutral- classes to gray (#6603) * Changed a neutral- classes to gray * Changed all border-1 to border * Update package.json * Test fixes * Yarn lock fixes * Fix string equality check in git-setup.sh * [CAL-811] Avatar icon not redirecting user back to the main page (#6586) * Remove cursor-pointer, remove old Avatar* files * Fixed styling for checkedSelect + some cleanup Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> * Harsh/add member invite (#6598) Co-authored-by: Guest <guest@pop-os.localdomain> Co-authored-by: root <harsh.singh@gocomet.com> * Regenerated lockfile without upgrade (#6610) * fix: remove annoying outline when <Button /> clicked (#6537) * fix: remove annoying outline when <Button /> clicked * Delete yarn.lock * remove 1 on 1 icon (#6609) * removed 1-on-1 badge * changed user to users for group events * fix: case-sensitivity in apps path (#6552) * fix: lowercase slug * fix: make fallback blocking * Fix FAB (#6611) * feat: add LocationSelect component (#6571) * feat: add LocationSelect component Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * fix: type error Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * chore: type error Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> * Update booking filters design (#6543) * Update booking filters * Add filter on YOUR bookings * Fix pending members showing up in list * Reduce the avatar size to 'sm' for now * Bugfix/dropdown menu trigger as child remove class names (#6614) * Fix UsernameTextfield to take right height * Remove className side-effect * Incorrect resolution version fixed * Converted mobile DropdownMenuTrigger styles into Button * v2.5.3 * fix: use items-center (#6618) * fix tooltip and modal stacking issues (#6491) * fix tooltip and modal stacking issues * use z-index in larger screens and less Co-authored-by: Alex van Andel <me@alexvanandel.com> * Temporary fix (#6626) * Fix Ga4 tracking (#6630) * generic <UpgradeScreen> component (#6594) * first attempt of <UpgradeScreen> * changes to icons * reverted changes back to initial state, needs fix: teams not showing * WIP * Fix weird reactnode error * Fix loading text * added upgradeTip to routing forms * icon colors * create and use hook to check if user has team plan * use useTeamPlan for upgradeTeamsBadge * replace huge svg with compressed jpeg * responsive fixes * Update packages/ui/components/badge/UpgradeTeamsBadge.tsx Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> * Give team plan features to E2E tests * Allow option to make a user part of team int ests * Remove flash of paywall for team user * Add team user for typeform tests as well Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> * Removing env var to rely on db * Restoring i18n keys, set loading moved * Fixing tailwind-preset glob * Wizard width fix for md+ screens * Converting licenses options to radix radio * Applying feedback + other tweaks * Reverting this, not this PR related * Unneeded code removal * Reverting unneeded style change * Applying feedback * Removing licenseType * Upgrades typescript * Update yarn lock * Typings * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) * Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713) * Adds deployment settings to DB (#6706) * WIP * Adds DeploymentTheme * Add missing migrations * Adds client extensions for deployment * Cleanup * Delete migration.sql * Relying on both, env var and new model * Restoring env example doc for backward compat * Maximum call stack size exceeded fix? * Revert upgrade * Update index.ts * Delete index.ts * Not exposing license key, fixed radio behavior * Covering undefined env var * Self contained checkLicense * Feedback * Moar feedback * Feedback * Feedback * Feedback * Cleanup --------- Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in> Co-authored-by: Peer Richelsen <peer@cal.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com> Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com> Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Harsh Singh <51085015+harshsinghatz@users.noreply.github.com> Co-authored-by: Guest <guest@pop-os.localdomain> Co-authored-by: root <harsh.singh@gocomet.com> Co-authored-by: Luis Cadillo <luiscaf3r@gmail.com> Co-authored-by: Mohammed Cherfaoui <hi@cherfaoui.dev> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
204 lines
6.8 KiB
TypeScript
204 lines
6.8 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 * as z from "zod";
|
|
|
|
import { isPasswordValid } from "@calcom/lib/auth";
|
|
import { WEBSITE_URL } from "@calcom/lib/constants";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { EmailField, EmptyScreen, Label, PasswordField, TextField } from "@calcom/ui";
|
|
import { FiUserCheck } from "@calcom/ui/components/icon";
|
|
|
|
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="space-y-4" onSubmit={props.onSuccess}>
|
|
<EmptyScreen
|
|
Icon={FiUserCheck}
|
|
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 }) => {
|
|
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().email({ 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,
|
|
});
|
|
}
|
|
});
|
|
}),
|
|
});
|
|
|
|
const formMethods = useForm<{
|
|
username: string;
|
|
email_address: string;
|
|
full_name: string;
|
|
password: string;
|
|
}>({
|
|
resolver: zodResolver(formSchema),
|
|
});
|
|
|
|
const onError = () => {
|
|
props.onError();
|
|
};
|
|
|
|
const onSubmit = formMethods.handleSubmit(async (data: z.infer<typeof formSchema>) => {
|
|
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="space-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 mt-2 inline-flex rounded-t-md border border-b-0 border-gray-300 bg-gray-100 py-1 px-3 text-gray-500">
|
|
{process.env.NEXT_PUBLIC_WEBSITE_URL}
|
|
</small>
|
|
)}
|
|
</Label>
|
|
<TextField
|
|
addOnLeading={
|
|
!longWebsiteUrl && (
|
|
<span className="inline-flex items-center rounded-none px-3 text-sm text-gray-500">
|
|
{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={async (e) => {
|
|
onChange(e.target.value);
|
|
formMethods.setValue("username", e.target.value);
|
|
await formMethods.trigger("username");
|
|
}}
|
|
/>
|
|
</>
|
|
)}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<Controller
|
|
name="full_name"
|
|
control={formMethods.control}
|
|
render={({ field: { onBlur, onChange, value } }) => (
|
|
<TextField
|
|
value={value || ""}
|
|
onBlur={onBlur}
|
|
onChange={async (e) => {
|
|
onChange(e.target.value);
|
|
formMethods.setValue("full_name", e.target.value);
|
|
await formMethods.trigger("full_name");
|
|
}}
|
|
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={async (e) => {
|
|
onChange(e.target.value);
|
|
formMethods.setValue("email_address", e.target.value);
|
|
await formMethods.trigger("email_address");
|
|
}}
|
|
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={async (e) => {
|
|
onChange(e.target.value);
|
|
formMethods.setValue("password", e.target.value);
|
|
await formMethods.trigger("password");
|
|
}}
|
|
hintErrors={["caplow", "admin_min", "num"]}
|
|
name="password"
|
|
className="my-0"
|
|
autoComplete="off"
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
</form>
|
|
</FormProvider>
|
|
);
|
|
};
|