♻️ separate org settings page into multiple forms

This commit is contained in:
Fred KISSIE
2025-12-18 04:27:24 +01:00
parent 2b3d065650
commit 1a976c78ef
3 changed files with 765 additions and 1158 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,8 @@
import { GetOrgResponse } from "@server/routers/org"; import { GetOrgResponse } from "@server/routers/org";
import { createContext } from "react"; import { createContext } from "react";
interface OrgContextType { export interface OrgContextType {
org: GetOrgResponse; org: GetOrgResponse;
updateOrg: (updateOrg: Partial<GetOrgResponse>) => void;
} }
const OrgContext = createContext<OrgContextType | undefined>(undefined); const OrgContext = createContext<OrgContextType | undefined>(undefined);

View File

@@ -10,36 +10,15 @@ interface OrgProviderProps {
org: GetOrgResponse | null; org: GetOrgResponse | null;
} }
export function OrgProvider({ children, org: serverOrg }: OrgProviderProps) { export function OrgProvider({ children, org }: OrgProviderProps) {
const [org, setOrg] = useState<GetOrgResponse | null>(serverOrg);
const t = useTranslations(); const t = useTranslations();
if (!org) { if (!org) {
throw new Error(t("orgErrorNoProvided")); throw new Error(t("orgErrorNoProvided"));
} }
const updateOrg = (updatedOrg: Partial<GetOrgResponse>) => {
if (!org) {
throw new Error(t("orgErrorNoUpdate"));
}
setOrg((prev) => {
if (!prev) {
return prev;
}
return {
...prev,
...updatedOrg
};
});
};
return ( return (
<OrgContext.Provider value={{ org, updateOrg }}> <OrgContext.Provider value={{ org }}>{children}</OrgContext.Provider>
{children}
</OrgContext.Provider>
); );
} }