Files
calendar/packages/ui/v2/core/WizardForm.tsx
T
a9a295dc54 Admin apps UI (#5494)
* Abstract app category navigation

* Send key schema to frontend

Co-authored-by: Omar López <zomars@users.noreply.github.com>

* Render keys for apps on admin

* Add enabled col for apps

* Save app keys to DB

* Add checks for admin role

* Abstract setup components

* Add AdminAppsList to setup wizard

* Migrate to v10 tRPC

* Default hide keys

* Display enabled apps

* Merge branch 'main' into admin-apps-ui

* Toggle calendars

* WIP

* Add params and include AppCategoryNavigation

* Refactor getEnabledApps

* Add warning for disabling apps

* Fallback to cal video when a video app is disabled

* WIP send disabled email

* Send email to all users of  event types with payment app

* Disable Stripe when app is disabled

* Disable apps in event types

* Send email to users on disabled apps

* Send email based on what app was disabled

* WIP type fix

* Disable navigation to apps list if already setup

* UI import fixes

* Waits for session data before redirecting

* Updates admin seeded password

To comply with admin password requirements

* Update yarn.lock

* Flex fixes

* Adds admin middleware

* Clean up

* WIP

* WIP

* NTS

* Add dirName to app metadata

* Upsert app if not in db

* Upsert app if not in db

* Add dirName to app metadata

* Add keys to app packages w/ keys

* Merge with main

* Toggle show keys & on enable

* Fix empty keys

* Fix lark calendar metadata

* Fix some type errors

* Fix Lark metadata & check for category when upserting

* More type fixes

* Fix types & add keys to google cal

* WIP

* WIP

* WIP

* More type fixes

* Fix type errors

* Fix type errors

* More type fixes

* More type fixes

* More type fixes

* Feedback

* Fixes default value

* Feedback

* Migrate credential invalid col default value "false"

* Upsert app on saving keys

* Clean up

* Validate app keys on frontend

* Add nonempty to app keys schemas

* Add web3

* Listlocale filter on categories / category

* Grab app metadata via category or categories

* Show empty screen if no apps are enabled

* Fix type checks

* Fix type checks

* Fix type checks

* Fix type checks

* Fix type checks

* Fix type checks

* Replace .nonempty() w/ .min(1)

* Fix type error

* Address feedback

* Added migration to keep current apps enabled

* Update apps.tsx

* Fix bug

* Add keys schema to Plausible app

* Add appKeysSchema to zod.ts template

* Update AdminAppsList.tsx

Co-authored-by: Omar López <zomars@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
2022-12-07 14:47:02 -07:00

85 lines
2.6 KiB
TypeScript

import { useRouter } from "next/router";
import classNames from "@calcom/lib/classNames";
import { Button, Stepper } from "../..";
type DefaultStep = {
title: string;
description: string;
content: JSX.Element;
enabled?: boolean;
isLoading: boolean;
};
function WizardForm<T extends DefaultStep>(props: {
href: string;
steps: T[];
disableNavigation?: boolean;
containerClassname?: string;
}) {
const { href, steps } = props;
const router = useRouter();
const step = parseInt((router.query.step as string) || "1");
const currentStep = steps[step - 1];
const setStep = (newStep: number) => {
router.replace(`${href}?step=${newStep || 1}`, undefined, { shallow: true });
};
return (
<div className="mx-auto mt-4 print:w-full">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img className="mx-auto mb-8 h-8" src="https://cal.com/logo.svg" alt="Cal.com Logo" />
<div
className={classNames(
"mb-8 divide-y divide-gray-200 overflow-hidden rounded-lg bg-white shadow print:divide-transparent print:shadow-transparent",
props.containerClassname
)}>
<div className="px-4 py-5 sm:px-6">
<h1 className="font-cal text-2xl text-gray-900">{currentStep.title}</h1>
<p className="text-sm text-gray-500">{currentStep.description}</p>
</div>
<div className="print:p-none px-4 py-5 sm:p-6">{currentStep.content}</div>
{!props.disableNavigation && (
<>
{currentStep.enabled !== false && (
<div className="flex justify-end px-4 py-4 print:hidden sm:px-6">
{step > 1 && (
<Button
color="secondary"
onClick={() => {
setStep(step - 1);
}}>
Back
</Button>
)}
<Button
tabIndex={0}
loading={currentStep.isLoading}
type="submit"
color="primary"
form={`wizard-step-${step}`}
className="relative ml-2"
onClick={() => {
setStep(step + 1);
}}>
{step < steps.length ? "Next" : "Finish"}
</Button>
</div>
)}
</>
)}
</div>
{!props.disableNavigation && (
<div className="print:hidden">
<Stepper href={href} step={step} steps={steps} disableSteps />
</div>
)}
</div>
);
}
export default WizardForm;