Skip to content

Commit

Permalink
new fix for sub email in GeneralSettings form
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Sep 12, 2024
1 parent 77c78b4 commit b885d0e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion editor.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@mui/material": "^5.15.10",
"@mui/utils": "^5.15.11",
"@opensystemslab/map": "1.0.0-alpha.3",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#8162d4f",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#306a172",
"@tiptap/core": "^2.4.0",
"@tiptap/extension-bold": "^2.0.3",
"@tiptap/extension-bubble-menu": "^2.1.13",
Expand Down
10 changes: 5 additions & 5 deletions editor.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import Container from "@mui/material/Container";
import Typography from "@mui/material/Typography";
import { TeamSettings } from "@opensystemslab/planx-core/types";
import {
TeamContactSettings,
TeamSettings,
} from "@opensystemslab/planx-core/types";
import { FormikConfig } from "formik";
import gql from "graphql-tag";
import { useToast } from "hooks/useToast";
import { client } from "lib/graphql";
import { useStore } from "pages/FlowEditor/lib/store";
import React, { useEffect, useState } from "react";
import SettingsSection from "ui/editor/SettingsSection";
Expand All @@ -17,6 +22,12 @@ export interface FormProps {
onSuccess: () => void;
}

interface GetTeamEmailSettings {
teams: {
teamSettings: TeamContactSettings;
}[];
}

const GeneralSettings: React.FC = () => {
const [formikConfig, setFormikConfig] = useState<
FormikConfig<TeamSettings> | undefined
Expand All @@ -26,11 +37,14 @@ const GeneralSettings: React.FC = () => {
useEffect(() => {
const fetchTeam = async () => {
try {
const fetchedTeam = await useStore.getState().fetchCurrentTeam();
if (!fetchedTeam) throw Error("Unable to find team");
const fetchedTeamSettings = await useStore
.getState()
.fetchCurrentTeamSettings();
console.log(fetchedTeamSettings);
if (!fetchedTeamSettings.settings) throw Error("Unable to find team");

setFormikConfig({
initialValues: fetchedTeam.settings,
initialValues: fetchedTeamSettings.settings,
onSubmit: () => {},
validateOnBlur: false,
validateOnChange: false,
Expand Down
6 changes: 6 additions & 0 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface TeamStore {
initTeamStore: (slug: string) => Promise<void>;
clearTeamStore: () => void;
fetchCurrentTeam: () => Promise<Team>;
fetchCurrentTeamSettings: () => Partial<Team>;
updateTeamTheme: (theme: Partial<TeamTheme>) => Promise<boolean>;
updateTeamSettings: (teamSettings: Partial<TeamSettings>) => Promise<boolean>;
createTeam: (newTeam: { name: string; slug: string }) => Promise<number>;
Expand Down Expand Up @@ -138,6 +139,11 @@ export const teamStore: StateCreator<
return await $client.team.getBySlug(teamSlug);
},

fetchCurrentTeamSettings: async () => {
const { teamSlug, $client } = get();
return await $client.team.getTeamSettings(teamSlug);
},

updateTeamTheme: async (theme: Partial<TeamTheme>) => {
const { teamId, $client } = get();
return await $client.team.updateTheme(teamId, theme);
Expand Down

0 comments on commit b885d0e

Please sign in to comment.