2022-12-07 20:53:44 +00:00
|
|
|
import { GetServerSidePropsContext } from "next";
|
2022-09-15 09:05:26 +00:00
|
|
|
import { useState } from "react";
|
2022-08-26 00:11:41 +00:00
|
|
|
|
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-09-15 09:05:26 +00:00
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2022-11-23 02:55:25 +00:00
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
Dialog,
|
2022-11-28 19:14:38 +00:00
|
|
|
DialogClose,
|
2022-11-23 02:55:25 +00:00
|
|
|
DialogContent,
|
2022-11-28 19:14:38 +00:00
|
|
|
DialogFooter,
|
2022-11-23 02:55:25 +00:00
|
|
|
Dropdown,
|
|
|
|
DropdownMenuContent,
|
|
|
|
DropdownMenuItem,
|
|
|
|
DropdownMenuTrigger,
|
|
|
|
getSettingsLayout as getLayout,
|
|
|
|
Icon,
|
|
|
|
List,
|
|
|
|
ListItem,
|
|
|
|
ListItemText,
|
|
|
|
ListItemTitle,
|
|
|
|
Meta,
|
|
|
|
showToast,
|
|
|
|
SkeletonContainer,
|
|
|
|
SkeletonText,
|
|
|
|
} from "@calcom/ui";
|
2022-08-26 00:11:41 +00:00
|
|
|
|
2022-12-07 20:53:44 +00:00
|
|
|
import { ssrInit } from "@server/lib/ssr";
|
|
|
|
|
|
|
|
const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
|
2022-09-15 09:05:26 +00:00
|
|
|
return (
|
|
|
|
<SkeletonContainer>
|
2022-12-07 20:53:44 +00:00
|
|
|
<Meta title={title} description={description} />
|
2022-09-15 09:05:26 +00:00
|
|
|
<div className="mt-6 mb-8 space-y-6 divide-y">
|
|
|
|
<SkeletonText className="h-8 w-full" />
|
|
|
|
<SkeletonText className="h-8 w-full" />
|
|
|
|
</div>
|
|
|
|
</SkeletonContainer>
|
|
|
|
);
|
|
|
|
};
|
2022-08-26 00:11:41 +00:00
|
|
|
|
2022-09-15 09:05:26 +00:00
|
|
|
const ConferencingLayout = () => {
|
2022-08-26 00:11:41 +00:00
|
|
|
const { t } = useLocale();
|
2022-09-15 09:05:26 +00:00
|
|
|
const utils = trpc.useContext();
|
|
|
|
|
2022-11-10 23:40:01 +00:00
|
|
|
const { data: apps, isLoading } = trpc.viewer.integrations.useQuery(
|
|
|
|
{ variant: "conferencing", onlyInstalled: true },
|
2022-09-15 09:05:26 +00:00
|
|
|
{
|
|
|
|
suspense: true,
|
|
|
|
}
|
|
|
|
);
|
2022-11-10 23:40:01 +00:00
|
|
|
const deleteAppMutation = trpc.viewer.deleteCredential.useMutation({
|
2022-09-15 09:05:26 +00:00
|
|
|
onSuccess: () => {
|
|
|
|
showToast("Integration deleted successfully", "success");
|
2022-11-10 23:40:01 +00:00
|
|
|
utils.viewer.integrations.invalidate({ variant: "conferencing", onlyInstalled: true });
|
2022-09-15 09:05:26 +00:00
|
|
|
setDeleteAppModal(false);
|
|
|
|
},
|
|
|
|
onError: () => {
|
|
|
|
showToast("Error deleting app", "error");
|
|
|
|
setDeleteAppModal(false);
|
|
|
|
},
|
|
|
|
});
|
2022-08-26 00:11:41 +00:00
|
|
|
|
2022-09-15 09:05:26 +00:00
|
|
|
const [deleteAppModal, setDeleteAppModal] = useState(false);
|
|
|
|
const [deleteCredentialId, setDeleteCredentialId] = useState<number>(0);
|
2022-08-26 00:11:41 +00:00
|
|
|
|
2022-12-07 20:53:44 +00:00
|
|
|
if (isLoading)
|
|
|
|
return <SkeletonLoader title={t("conferencing")} description={t("conferencing_description")} />;
|
2022-08-26 00:11:41 +00:00
|
|
|
|
|
|
|
return (
|
2022-09-09 12:57:31 +00:00
|
|
|
<div className="w-full bg-white sm:mx-0 xl:mt-0">
|
2022-12-07 20:53:44 +00:00
|
|
|
<Meta title={t("conferencing")} description={t("conferencing_description")} />
|
2022-11-23 02:55:25 +00:00
|
|
|
<List>
|
2022-09-15 09:05:26 +00:00
|
|
|
{apps?.items &&
|
|
|
|
apps.items
|
|
|
|
.map((app) => ({ ...app, title: app.title || app.name }))
|
|
|
|
.map((app) => (
|
2022-11-23 02:55:25 +00:00
|
|
|
<ListItem className="flex-col border-0" key={app.title}>
|
2022-12-01 20:30:57 +00:00
|
|
|
<div className="flex w-full flex-1 items-center space-x-2 p-4 rtl:space-x-reverse">
|
2022-09-15 09:05:26 +00:00
|
|
|
{
|
|
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
|
|
app.logo && <img className="h-10 w-10" src={app.logo} alt={app.title} />
|
|
|
|
}
|
|
|
|
<div className="flex-grow truncate pl-2">
|
2023-01-04 07:38:45 +00:00
|
|
|
<ListItemTitle component="h3" className="mb-1 space-x-2 rtl:space-x-reverse">
|
2022-09-15 09:05:26 +00:00
|
|
|
<h3 className="truncate text-sm font-medium text-neutral-900">{app.title}</h3>
|
|
|
|
</ListItemTitle>
|
|
|
|
<ListItemText component="p">{app.description}</ListItemText>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<Dropdown>
|
|
|
|
<DropdownMenuTrigger asChild>
|
|
|
|
<Button StartIcon={Icon.FiMoreHorizontal} size="icon" color="secondary" />
|
|
|
|
</DropdownMenuTrigger>
|
|
|
|
<DropdownMenuContent>
|
|
|
|
<DropdownMenuItem>
|
|
|
|
<Button
|
|
|
|
color="destructive"
|
|
|
|
StartIcon={Icon.FiTrash}
|
|
|
|
disabled={app.isGlobal}
|
|
|
|
onClick={() => {
|
|
|
|
setDeleteCredentialId(app.credentialIds[0]);
|
|
|
|
setDeleteAppModal(true);
|
|
|
|
}}>
|
|
|
|
{t("remove_app")}
|
|
|
|
</Button>
|
|
|
|
</DropdownMenuItem>
|
|
|
|
</DropdownMenuContent>
|
|
|
|
</Dropdown>
|
|
|
|
</div>
|
2022-09-09 12:57:31 +00:00
|
|
|
</div>
|
2022-09-15 09:05:26 +00:00
|
|
|
</ListItem>
|
|
|
|
))}
|
2022-09-09 12:57:31 +00:00
|
|
|
</List>
|
2022-09-15 09:05:26 +00:00
|
|
|
|
|
|
|
<Dialog open={deleteAppModal} onOpenChange={setDeleteAppModal}>
|
|
|
|
<DialogContent
|
|
|
|
title={t("Remove app")}
|
|
|
|
description={t("are_you_sure_you_want_to_remove_this_app")}
|
|
|
|
type="confirmation"
|
2022-11-28 19:14:38 +00:00
|
|
|
Icon={Icon.FiAlertCircle}>
|
|
|
|
<DialogFooter>
|
|
|
|
<Button color="primary" onClick={() => deleteAppMutation.mutate({ id: deleteCredentialId })}>
|
|
|
|
{t("yes_remove_app")}
|
|
|
|
</Button>
|
|
|
|
<DialogClose />
|
|
|
|
</DialogFooter>
|
|
|
|
</DialogContent>
|
2022-09-15 09:05:26 +00:00
|
|
|
</Dialog>
|
2022-08-26 00:11:41 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ConferencingLayout.getLayout = getLayout;
|
|
|
|
|
2022-12-07 20:53:44 +00:00
|
|
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
|
|
|
const ssr = await ssrInit(context);
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
trpcState: ssr.dehydrate(),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-08-26 00:11:41 +00:00
|
|
|
export default ConferencingLayout;
|