Skip to content

Commit

Permalink
chore: Pull in Team types from planx-core
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Jan 10, 2024
1 parent 3c22140 commit f55499c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 61 deletions.
7 changes: 4 additions & 3 deletions editor.planx.uk/src/components/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Team } from "@opensystemslab/planx-core/types";
import { screen } from "@testing-library/react";
import { vanillaStore } from "pages/FlowEditor/lib/store";
import React from "react";
import { act } from "react-dom/test-utils";
import * as ReactNavi from "react-navi";
import { axe, setup } from "testUtils";
import { Team } from "types";

import flowWithoutSections from "../pages/FlowEditor/lib/__tests__/mocks/flowWithClones.json";
import flowWithThreeSections from "../pages/FlowEditor/lib/__tests__/mocks/flowWithThreeSections.json";
Expand All @@ -18,8 +18,9 @@ const mockTeam1: Team = {
slug: "opensystemslab",
theme: {
logo: "logo.jpg",
primary: "#0010A4",
secondary: null,
primaryColour: "#0010A4",
actionColour: "#0010A4",
linkColour: "#0010A4",
favicon: null,
},
};
Expand Down
2 changes: 1 addition & 1 deletion editor.planx.uk/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ const Header: React.FC = () => {
elevation={0}
color="transparent"
ref={headerRef}
style={{ backgroundColor: theme?.primary || "#2c2c2c" }}
style={{ backgroundColor: theme?.primaryColour || "#2c2c2c" }}
>
<Toolbar headerRef={headerRef}></Toolbar>
</Root>
Expand Down
12 changes: 7 additions & 5 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { GeoJSONObject } from "@turf/helpers";
import {
NotifyPersonalisation,
Team,
TeamSettings,
TeamTheme,
} from "@opensystemslab/planx-core/types";
import gql from "graphql-tag";
import { client } from "lib/graphql";
import { NotifyPersonalisation, TeamSettings } from "types";
import { TeamTheme } from "types";
import { Team } from "types";
import type { StateCreator } from "zustand";

export interface TeamStore {
Expand All @@ -13,7 +15,7 @@ export interface TeamStore {
teamSettings?: TeamSettings;
teamSlug: string;
notifyPersonalisation?: NotifyPersonalisation;
boundaryBBox?: GeoJSONObject;
boundaryBBox?: Team["boundaryBBox"];

setTeam: (team: Team) => void;
getTeam: () => Team;
Expand Down
3 changes: 1 addition & 2 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { User, UserTeams } from "@opensystemslab/planx-core/types";
import { Team, User, UserTeams } from "@opensystemslab/planx-core/types";
import axios from "axios";
import { _client } from "client";
import { Team } from "types";
import type { StateCreator } from "zustand";

export interface UserStore {
Expand Down
2 changes: 1 addition & 1 deletion editor.planx.uk/src/pages/Teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import Box from "@mui/material/Box";
import Card from "@mui/material/Card";
import { styled } from "@mui/material/styles";
import Typography from "@mui/material/Typography";
import { Team } from "@opensystemslab/planx-core/types";
import React from "react";
import { Link } from "react-navi";

import type { Team } from "../types";
import { useStore } from "./FlowEditor/lib/store";

interface Props {
Expand Down
12 changes: 5 additions & 7 deletions editor.planx.uk/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import createPalette, {
PaletteOptions,
} from "@mui/material/styles/createPalette";
import { deepmerge } from "@mui/utils";
import { TeamTheme } from "types";
import { TeamTheme } from "@opensystemslab/planx-core/types";

const DEFAULT_PRIMARY_COLOR = "#0010A4";
const DEFAULT_SECONDARY_COLOR = "#F3F2F1";
Expand Down Expand Up @@ -105,10 +105,7 @@ export const linkStyle = (primaryColor?: string) => ({
const getThemeOptions = (teamTheme?: TeamTheme): ThemeOptions => {
const teamPalette: Partial<PaletteOptions> = {
primary: {
main: teamTheme?.primary || DEFAULT_PRIMARY_COLOR,
},
secondary: {
main: teamTheme?.secondary || DEFAULT_SECONDARY_COLOR,
main: teamTheme?.primaryColour || DEFAULT_PRIMARY_COLOR,
},
};
const palette = createPalette(deepmerge(DEFAULT_PALETTE, teamPalette));
Expand Down Expand Up @@ -436,8 +433,9 @@ const getThemeOptions = (teamTheme?: TeamTheme): ThemeOptions => {
// Generate a MUI theme based on a team's primary color
const generateTeamTheme = (
teamTheme: TeamTheme = {
primary: DEFAULT_PRIMARY_COLOR,
secondary: DEFAULT_SECONDARY_COLOR,
primaryColour: DEFAULT_PRIMARY_COLOR,
actionColour: DEFAULT_PRIMARY_COLOR,
linkColour: DEFAULT_PRIMARY_COLOR,
logo: null,
favicon: null,
},
Expand Down
42 changes: 1 addition & 41 deletions editor.planx.uk/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { GovUKPayment } from "@opensystemslab/planx-core/types";
import { GeoJSONObject } from "@turf/helpers";
import { GovUKPayment, Team } from "@opensystemslab/planx-core/types";
import { useFormik } from "formik";

import { Store } from "./pages/FlowEditor/lib/store/index";
Expand All @@ -15,45 +14,6 @@ export interface Flow {
team: Team;
settings?: FlowSettings;
}

export interface Team {
id: number;
name: string;
slug: string;
settings?: TeamSettings;
theme?: TeamTheme;
notifyPersonalisation?: NotifyPersonalisation;
boundaryBBox?: GeoJSONObject;
}

export interface TeamTheme {
primary: string;
secondary: string | null;
logo: string | null;
favicon: string | null;
}

export interface TeamSettings {
design?: {
color?: string;
};
homepage?: string;
externalPlanningSite: {
name: string;
url: string;
};
supportEmail?: string;
boundary?: string;
hasPlanningData?: boolean;
}

export interface NotifyPersonalisation {
helpEmail: string;
helpPhone: string;
emailReplyToId: string;
helpOpeningHours: string;
}

export interface GlobalSettings {
footerContent?: { [key: string]: TextContent };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import DialogTitle from "@mui/material/DialogTitle";
import Link from "@mui/material/Link";
import Typography from "@mui/material/Typography";
import { visuallyHidden } from "@mui/utils";
import { TeamSettings } from "@opensystemslab/planx-core/types";
import { useStore } from "pages/FlowEditor/lib/store";
import React from "react";
import { useState } from "react";
import { TeamSettings } from "types";

export enum DialogPurpose {
MissingProjectType,
Expand Down

0 comments on commit f55499c

Please sign in to comment.