-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathOrgForm.tsx
More file actions
61 lines (59 loc) · 1.7 KB
/
Copy pathOrgForm.tsx
File metadata and controls
61 lines (59 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type { FunctionComponent } from "react";
import Section from "./common/Section";
import {
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "./ui/form";
import { Input } from "./ui/input";
import { InputWithButton } from "./ui/input-with-button";
import { useActiveOrg } from "@/hooks/useActiveOrg";
interface OrgFormProps {
forceVertical?: boolean;
}
export const OrgForm: FunctionComponent<OrgFormProps> = ({
forceVertical = true,
}) => {
const activeOrg = useActiveOrg();
const orgID = activeOrg?.id;
return (
<Section
description="Enter the name of your organization. This will be used to identify your organization in the system."
title="General Information"
forceVertical={forceVertical}
>
<div className="mt-6">
<FormField
name="name"
rules={{
validate: (value) =>
// Allows every character as long as one letter or number is given.
/[a-z0-9]/i.test(value ?? "") ||
"The name must contain at least one letter or number.",
}}
render={({ field }) => (
<FormItem>
<FormLabel>Organization name*</FormLabel>
<FormControl>
<Input data-testid="org-name-label" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{activeOrg && (
<InputWithButton
label="Organization-ID"
value={`${orgID}`}
nameKey="settings-org-id"
variant="default"
copyable
copyToastDescription="The organization ID has been copied to your clipboard."
/>
)}
</div>
</Section>
);
};