|
| 1 | +import { useServerInfo } from "@/data/server/info-query"; |
| 2 | +import { useCurrentUser } from "@/data/users/current-user-query"; |
| 3 | +import { Button, Input, Skeleton } from "@zenml-io/react-component-library/components/server"; |
| 4 | +import { useUpgradeForm } from "./useUpgradeForm"; |
| 5 | + |
| 6 | +export function UpgradeFormSection() { |
| 7 | + return ( |
| 8 | + <div className="space-y-5"> |
| 9 | + <HeadingSection /> |
| 10 | + <Form /> |
| 11 | + </div> |
| 12 | + ); |
| 13 | +} |
| 14 | + |
| 15 | +function HeadingSection() { |
| 16 | + return ( |
| 17 | + <div className="flex flex-col items-center space-y-0.5"> |
| 18 | + <h1 className="text-center text-display-xs font-semibold"> |
| 19 | + Upgrade to ZenML Pro on your own VPC |
| 20 | + </h1> |
| 21 | + <p className="text-theme-text-secondary">Direct self-deployment, no sales calls</p> |
| 22 | + </div> |
| 23 | + ); |
| 24 | +} |
| 25 | + |
| 26 | +function Form() { |
| 27 | + const serverInfo = useServerInfo(); |
| 28 | + const user = useCurrentUser(); |
| 29 | + |
| 30 | + const { form, handleSubmitForm, submitFormMutation } = useUpgradeForm(); |
| 31 | + |
| 32 | + const { |
| 33 | + register, |
| 34 | + handleSubmit, |
| 35 | + formState: { isValid, isSubmitting } |
| 36 | + } = form; |
| 37 | + |
| 38 | + const { isPending } = submitFormMutation; |
| 39 | + |
| 40 | + if (serverInfo.isPending || user.isPending) return <Skeleton className="h-[250px] w-full" />; |
| 41 | + if (serverInfo.isError || user.isError) return <p>Something went wrong....</p>; |
| 42 | + |
| 43 | + return ( |
| 44 | + <div className="space-y-5"> |
| 45 | + <form |
| 46 | + onSubmit={handleSubmit((data) => |
| 47 | + handleSubmitForm(data, user.data.id, !!serverInfo.data.debug) |
| 48 | + )} |
| 49 | + className="space-y-5" |
| 50 | + > |
| 51 | + <div className="space-y-0.5"> |
| 52 | + <label htmlFor="name" className="text-text-sm"> |
| 53 | + Your Name |
| 54 | + </label> |
| 55 | + <Input {...register("name")} id="name" className="w-full" /> |
| 56 | + </div> |
| 57 | + <div className="space-y-0.5"> |
| 58 | + <label htmlFor="company" className="text-text-sm"> |
| 59 | + Company |
| 60 | + </label> |
| 61 | + <Input {...register("company")} id="company" className="w-full" /> |
| 62 | + </div> |
| 63 | + <div className="space-y-0.5"> |
| 64 | + <label htmlFor="email" className="text-text-sm"> |
| 65 | + Email address |
| 66 | + </label> |
| 67 | + <Input {...register("email")} id="email" className="w-full" /> |
| 68 | + </div> |
| 69 | + <Button |
| 70 | + size="md" |
| 71 | + className="w-full justify-center" |
| 72 | + disabled={isSubmitting || isPending || !isValid} |
| 73 | + type="submit" |
| 74 | + > |
| 75 | + {(isPending || isSubmitting) && ( |
| 76 | + <div |
| 77 | + role="alert" |
| 78 | + aria-busy="true" |
| 79 | + className="full h-[20px] w-[20px] animate-spin rounded-rounded border-2 border-theme-text-negative border-b-theme-text-brand" |
| 80 | + ></div> |
| 81 | + )} |
| 82 | + Continue |
| 83 | + </Button> |
| 84 | + </form> |
| 85 | + <p className="text-center text-text-xs text-theme-text-secondary"> |
| 86 | + By submitting the form you accept our{" "} |
| 87 | + <a |
| 88 | + className="link" |
| 89 | + href="https://www.zenml.io/cloud-terms-and-privacy" |
| 90 | + target="_blank" |
| 91 | + rel="noopener noreferrer" |
| 92 | + > |
| 93 | + terms of use |
| 94 | + </a>{" "} |
| 95 | + and{" "} |
| 96 | + <a |
| 97 | + href="https://www.zenml.io/privacy-policy" |
| 98 | + target="_blank" |
| 99 | + rel="noopener noreferrer" |
| 100 | + className="link" |
| 101 | + > |
| 102 | + privacy policy |
| 103 | + </a> |
| 104 | + . |
| 105 | + </p> |
| 106 | + </div> |
| 107 | + ); |
| 108 | +} |
0 commit comments