diff --git a/web/components/project/form.tsx b/web/components/project/form.tsx index f4ab3e846..5be7033a4 100644 --- a/web/components/project/form.tsx +++ b/web/components/project/form.tsx @@ -1,4 +1,4 @@ -import { FC, useEffect } from "react"; +import { FC, useEffect, useState } from "react"; import { Controller, useForm } from "react-hook-form"; // hooks import { useApplication, useProject, useWorkspace } from "hooks/store"; @@ -29,6 +29,8 @@ const projectService = new ProjectService(); export const ProjectDetailsForm: FC = (props) => { const { project, workspaceSlug, isAdmin } = props; + // states + const [isLoading, setIsLoading] = useState(false); // store hooks const { eventTracker: { postHogEventTracker }, @@ -45,7 +47,7 @@ export const ProjectDetailsForm: FC = (props) => { setValue, setError, reset, - formState: { errors, isSubmitting }, + formState: { errors }, } = useForm({ defaultValues: { ...project, @@ -114,6 +116,7 @@ export const ProjectDetailsForm: FC = (props) => { const onSubmit = async (formData: IProject) => { if (!workspaceSlug) return; + setIsLoading(true); const payload: Partial = { name: formData.name, @@ -139,6 +142,10 @@ export const ProjectDetailsForm: FC = (props) => { else await handleUpdateChange(payload); }); else await handleUpdateChange(payload); + + setTimeout(() => { + setIsLoading(false); + }, 300); }; const currentNetwork = NETWORK_CHOICES.find((n) => n.key === project?.network); @@ -308,8 +315,8 @@ export const ProjectDetailsForm: FC = (props) => {
<> - Created on {renderFormattedDate(project?.created_at)} diff --git a/web/components/workspace/settings/workspace-details.tsx b/web/components/workspace/settings/workspace-details.tsx index 3063855fd..87313c87d 100644 --- a/web/components/workspace/settings/workspace-details.tsx +++ b/web/components/workspace/settings/workspace-details.tsx @@ -32,6 +32,7 @@ const fileService = new FileService(); export const WorkspaceDetails: FC = observer(() => { // states + const [isLoading, setIsLoading] = useState(false); const [deleteWorkspaceModal, setDeleteWorkspaceModal] = useState(false); const [isImageRemoving, setIsImageRemoving] = useState(false); const [isImageUploadModalOpen, setIsImageUploadModalOpen] = useState(false); @@ -51,7 +52,7 @@ export const WorkspaceDetails: FC = observer(() => { control, reset, watch, - formState: { errors, isSubmitting }, + formState: { errors }, } = useForm({ defaultValues: { ...defaultValues, ...currentWorkspace }, }); @@ -59,6 +60,8 @@ export const WorkspaceDetails: FC = observer(() => { const onSubmit = async (formData: IWorkspace) => { if (!currentWorkspace) return; + setIsLoading(true); + const payload: Partial = { logo: formData.logo, name: formData.name, @@ -83,6 +86,9 @@ export const WorkspaceDetails: FC = observer(() => { }); console.error(err); }); + setTimeout(() => { + setIsLoading(false); + }, 300); }; const handleRemoveLogo = () => { @@ -289,8 +295,8 @@ export const WorkspaceDetails: FC = observer(() => { {isAdmin && (
-
)} diff --git a/web/pages/profile/index.tsx b/web/pages/profile/index.tsx index 3174c53f3..294ef3574 100644 --- a/web/pages/profile/index.tsx +++ b/web/pages/profile/index.tsx @@ -39,6 +39,7 @@ const fileService = new FileService(); const ProfileSettingsPage: NextPageWithLayout = observer(() => { // states + const [isLoading, setIsLoading] = useState(false); const [isRemoving, setIsRemoving] = useState(false); const [isImageUploadModalOpen, setIsImageUploadModalOpen] = useState(false); const [deactivateAccountModal, setDeactivateAccountModal] = useState(false); @@ -48,7 +49,7 @@ const ProfileSettingsPage: NextPageWithLayout = observer(() => { reset, watch, control, - formState: { errors, isSubmitting }, + formState: { errors }, } = useForm({ defaultValues }); // toast alert const { setToastAlert } = useToast(); @@ -62,6 +63,7 @@ const ProfileSettingsPage: NextPageWithLayout = observer(() => { }, [myProfile, reset]); const onSubmit = async (formData: IUser) => { + setIsLoading(true); const payload: Partial = { first_name: formData.first_name, last_name: formData.last_name, @@ -87,6 +89,9 @@ const ProfileSettingsPage: NextPageWithLayout = observer(() => { message: "There was some error in updating your profile. Please try again.", }) ); + setTimeout(() => { + setIsLoading(false); + }, 300); }; const handleDelete = (url: string | null | undefined, updateUser: boolean = false) => { @@ -388,8 +393,8 @@ const ProfileSettingsPage: NextPageWithLayout = observer(() => {
-