* Add queries to fetch metadata and update default * Add to zod schema * Change default rules on settings page * Update query * Initall override on create event type * Working default * Change schema to save locationLink too * Update default conferncing to include link * Rename tsx to ts. Fix metadata keys * WIP on refactoring appstore installed * Add this to appstore installed apps too * Display only on conferencing apps * Add i18n strings * Change order in dropdown menu so delete is bottom * Refactor query to not expose all of metadata * Fix mr type checker * Possible e2e fix * Refactor metadata to use ctx * Refactor back to query cell * Alias schema * Adding comment for more info * Remove constant for clarity * Update nextjs-bundle-analysis.yml --------- Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: zomars <zomars@me.com>
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
import { Dispatch, SetStateAction } from "react";
|
|
import { useForm } from "react-hook-form";
|
|
|
|
import { EventLocationType } from "@calcom/app-store/locations";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import {
|
|
showToast,
|
|
Dialog,
|
|
DialogContent,
|
|
Form,
|
|
TextField,
|
|
DialogFooter,
|
|
Button,
|
|
DialogClose,
|
|
} from "@calcom/ui";
|
|
import { FiAlertCircle } from "@calcom/ui/components/icon";
|
|
|
|
type LocationTypeSetLinkDialogFormProps = {
|
|
link?: string;
|
|
type: EventLocationType["type"];
|
|
};
|
|
|
|
export function AppSetDefaultLinkDailog({
|
|
locationType,
|
|
setLocationType,
|
|
}: {
|
|
locationType: EventLocationType & { slug: string };
|
|
setLocationType: Dispatch<SetStateAction<(EventLocationType & { slug: string }) | undefined>>;
|
|
}) {
|
|
const utils = trpc.useContext();
|
|
|
|
const { t } = useLocale();
|
|
const form = useForm<LocationTypeSetLinkDialogFormProps>({});
|
|
|
|
const updateDefaultAppMutation = trpc.viewer.updateUserDefaultConferencingApp.useMutation({
|
|
onSuccess: () => {
|
|
showToast("Default app updated successfully", "success");
|
|
utils.viewer.getUsersDefaultConferencingApp.invalidate();
|
|
},
|
|
});
|
|
|
|
return (
|
|
<Dialog open={!!locationType} onOpenChange={() => setLocationType(undefined)}>
|
|
<DialogContent
|
|
title={t("default_app_link_title")}
|
|
description={t("default_app_link_description")}
|
|
type="creation"
|
|
Icon={FiAlertCircle}>
|
|
<Form
|
|
form={form}
|
|
handleSubmit={(values) => {
|
|
updateDefaultAppMutation.mutate({
|
|
appSlug: locationType.slug,
|
|
appLink: values.link,
|
|
});
|
|
setLocationType(undefined);
|
|
}}>
|
|
<>
|
|
<TextField
|
|
type="text"
|
|
required
|
|
{...form.register("link")}
|
|
placeholder={locationType.organizerInputPlaceholder ?? ""}
|
|
label={locationType.label ?? ""}
|
|
/>
|
|
|
|
<DialogFooter>
|
|
<Button color="primary" type="submit">
|
|
{t("save")}
|
|
</Button>
|
|
<DialogClose />
|
|
</DialogFooter>
|
|
</>
|
|
</Form>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|