Skip to content

Commit

Permalink
chore: Sort store, add defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Feb 12, 2024
1 parent bc08f97 commit b48ab78
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import type { StateCreator } from "zustand";
import { SharedStore } from "./shared";

export interface TeamStore {
boundaryBBox?: Team["boundaryBBox"];
notifyPersonalisation?: NotifyPersonalisation;
teamId: number;
teamTheme: TeamTheme;
teamIntegrations: TeamIntegrations;
teamName: string;
teamSettings?: TeamSettings;
teamIntegrations?: TeamIntegrations;
teamSlug: string;
notifyPersonalisation?: NotifyPersonalisation;
boundaryBBox?: Team["boundaryBBox"];
teamTheme: TeamTheme;

setTeam: (team: Team) => void;
getTeam: () => Team;
Expand All @@ -35,24 +35,25 @@ export const teamStore: StateCreator<
[],
TeamStore
> = (set, get) => ({
boundaryBBox: undefined,
notifyPersonalisation: undefined,
teamId: 0,
teamTheme: {} as TeamTheme,
teamIntegrations: {} as TeamIntegrations,
teamName: "",
teamSettings: undefined,
teamSlug: "",
notifyPersonalisation: undefined,
boundaryBBox: undefined,
teamTheme: {} as TeamTheme,

setTeam: (team) => {
set({
boundaryBBox: team.boundaryBBox,
notifyPersonalisation: team.notifyPersonalisation,
teamId: team.id,
teamTheme: team.theme,
teamName: team.name,
teamIntegrations: team.integrations,
teamName: team.name,
teamSettings: team.settings,
teamSlug: team.slug,
notifyPersonalisation: team.notifyPersonalisation,
boundaryBBox: team.boundaryBBox,
teamTheme: team.theme,
});

if (team.theme?.favicon) {
Expand All @@ -62,14 +63,14 @@ export const teamStore: StateCreator<
},

getTeam: () => ({
boundaryBBox: get().boundaryBBox,
id: get().teamId,
integrations: get().teamIntegrations,
name: get().teamName,
slug: get().teamSlug,
notifyPersonalisation: get().notifyPersonalisation,
settings: get().teamSettings,
slug: get().teamSlug,
theme: get().teamTheme,
notifyPersonalisation: get().notifyPersonalisation,
boundaryBBox: get().boundaryBBox,
integrations: get().teamIntegrations,
}),

initTeamStore: async (slug) => {
Expand Down Expand Up @@ -108,13 +109,14 @@ export const teamStore: StateCreator<

clearTeamStore: () =>
set({
boundaryBBox: undefined,
notifyPersonalisation: undefined,
teamId: 0,
teamTheme: undefined,
teamIntegrations: undefined,
teamName: "",
teamSettings: undefined,
teamSlug: "",
notifyPersonalisation: undefined,
boundaryBBox: undefined,
teamTheme: undefined,
}),

/**
Expand Down

0 comments on commit b48ab78

Please sign in to comment.