Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge branch 'main' into feat/create-multiple-orgs-under-same-account

vmatsiiako912818eec816
diff --cc frontend/src/views/Org/NonePage/NonePage.tsx
index 26294a36b8,6e21c302f2..e2fd70fd21
--- a/frontend/src/views/Org/NonePage/NonePage.tsx
+++ b/frontend/src/views/Org/NonePage/NonePage.tsx
@@@ -14,18 -20,95 +14,53 @@@ const schema = yu
export type FormData = yup.InferType<typeof schema>;
export const NonePage = () => {
- const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["createOrg"] as const);
+ const { createNotification } = useNotificationContext();
- const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
++ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
+ "createOrg",
+ ] as const);
+
+ const { mutateAsync } = useCreateOrg();
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<FormData>({
+ resolver: yupResolver(schema),
+ defaultValues: {
+ name: ""
+ }
+ });
+
+ useEffect(() => {
+ handlePopUpOpen("createOrg");
+ }, []);
+
+ const onFormSubmit = async ({ name }: FormData) => {
+ try {
+
+ const organization = await mutateAsync({
+ name
+ });
+
+ localStorage.setItem("orgData.id", organization._id);
+
+ createNotification({
+ text: "Successfully created organization",
+ type: "success"
+ });
- window.location.href = `/org/${organization._id}/overview`;
-
- reset();
- handlePopUpToggle("createOrg", false);
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to created organization",
- type: "error"
- });
- }
- }
+ useEffect(() => {
+ handlePopUpOpen("createOrg");
+ }, []);
- return (
- <div className="flex justify-center bg-bunker-800 text-white w-full h-full">
- <Modal
- isOpen={popUp?.createOrg?.isOpen}
- >
- <ModalContent
- title="Create Organization"
- subTitle="Looks like you're not part of any organizations. Create one to start using Infisical"
- >
- <form onSubmit={handleSubmit(onFormSubmit)}>
- <Controller
- control={control}
- defaultValue=""
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Name"
- isError={Boolean(error)}
- errorText={error?.message}
- >
- <Input
- {...field}
- placeholder="Acme Corp"
- />
- </FormControl>
- )}
- />
- <Button
- className=""
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- Create
- </Button>
- </form>
- </ModalContent>
- </Modal>
- </div>
- );
-}
+ return (
+ <div className="flex h-full w-full justify-center bg-bunker-800 text-white">
+ <CreateOrgModal
+ isOpen={popUp.createOrg.isOpen}
+ onClose={() => handlePopUpToggle("createOrg", false)}
+ />
+ </div>
+ );
+};