refactor(forms): memoize dynamic form sections with stable ids
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Add uuid-based section keys and memoized DynamicSection to reduce re-renders, fix dashboard GSAP scoping, update logo sizing, and temporarily hide notice-type and closing-soon widgets. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,8 +9,16 @@ import { FormErrorMessages } from "@/constants/Texts";
|
||||
import type { ICreateCompanyCredentials } from "@/lib/api";
|
||||
import type { ILabelValue } from "@/types/shared";
|
||||
import type { UseFormSetValue, UseFormWatch } from "react-hook-form";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import CompanyDocuments from "./documents/CompanyDocuments";
|
||||
|
||||
const companyInformationSectionId = uuidv4();
|
||||
const businessInformationSectionId = uuidv4();
|
||||
const settingsSectionId = uuidv4();
|
||||
const addressSectionId = uuidv4();
|
||||
const tagsSectionId = uuidv4();
|
||||
const documentsSectionId = uuidv4();
|
||||
|
||||
interface CompanyFormSectionsOptions {
|
||||
editMode?: boolean;
|
||||
id?: string;
|
||||
@@ -79,6 +87,7 @@ export const createCompanyFormSections = ({
|
||||
setValue,
|
||||
}: CompanyFormSectionsOptions): DynamicFormSection<ICreateCompanyCredentials>[] => [
|
||||
{
|
||||
id: companyInformationSectionId,
|
||||
title: "Company information",
|
||||
rootClassName: "lg:col-span-2",
|
||||
className: "gap-x-5 gap-y-5 sm:grid-cols-2 md:grid-cols-2",
|
||||
@@ -235,6 +244,7 @@ export const createCompanyFormSections = ({
|
||||
],
|
||||
},
|
||||
{
|
||||
id: businessInformationSectionId,
|
||||
title: "Business information",
|
||||
className: "gap-x-5 gap-y-5 sm:grid-cols-2 md:grid-cols-2",
|
||||
fields: [
|
||||
@@ -276,6 +286,7 @@ export const createCompanyFormSections = ({
|
||||
],
|
||||
},
|
||||
{
|
||||
id: settingsSectionId,
|
||||
title: "Settings",
|
||||
className: "gap-x-5 gap-y-5 sm:grid-cols-2 md:grid-cols-2",
|
||||
fields: [
|
||||
@@ -323,6 +334,7 @@ export const createCompanyFormSections = ({
|
||||
],
|
||||
},
|
||||
{
|
||||
id: addressSectionId,
|
||||
title: "Address",
|
||||
className: "gap-x-5 gap-y-5 sm:grid-cols-2 md:grid-cols-2",
|
||||
fields: [
|
||||
@@ -395,6 +407,7 @@ export const createCompanyFormSections = ({
|
||||
],
|
||||
},
|
||||
{
|
||||
id: tagsSectionId,
|
||||
title: "Tags",
|
||||
className: "gap-x-5 gap-y-5 sm:grid-cols-2 md:grid-cols-2",
|
||||
fields: [
|
||||
@@ -479,6 +492,7 @@ export const createCompanyFormSections = ({
|
||||
],
|
||||
},
|
||||
{
|
||||
id: documentsSectionId,
|
||||
title: "Documents",
|
||||
rootClassName: "lg:col-span-2",
|
||||
className: "md:grid-cols-1",
|
||||
|
||||
Reference in New Issue
Block a user