-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Fetch team_settings
data for Editor forms and adding Update fn
#3366
Changes from 2 commits
3be2b8b
8d103fd
1db71cd
4a5a0eb
feba3e2
bdac32d
8e891f8
a4f90f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { useFormik } from "formik"; | ||
import { useStore } from "pages/FlowEditor/lib/store"; | ||
import React, { ChangeEvent } from "react"; | ||
import InputLabel from "ui/editor/InputLabel"; | ||
import Input from "ui/shared/Input"; | ||
|
@@ -20,9 +21,16 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
const formik = useFormik({ | ||
...formikConfig, | ||
validationSchema: formSchema, | ||
onSubmit(values, { resetForm }) { | ||
onSuccess(); | ||
resetForm({ values }); | ||
onSubmit: async (values, { resetForm }) => { | ||
const isSuccess = await useStore.getState().updateTeamSettings({ | ||
helpEmail: values.helpEmail, | ||
helpOpeningHours: values.helpOpeningHours, | ||
helpPhone: values.helpPhone, | ||
Comment on lines
+27
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
if (isSuccess) { | ||
onSuccess(); | ||
resetForm({ values }); | ||
} | ||
}, | ||
}); | ||
|
||
|
@@ -47,12 +55,14 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
onChange={(event) => { | ||
onChangeFn("homepage", event); | ||
}} | ||
value={formik.values.homepage} | ||
id="homepageUrl" | ||
/> | ||
</InputLabel> | ||
<InputLabel label="Contact email address" htmlFor="helpEmail"> | ||
<Input | ||
name="helpEmail" | ||
value={formik.values.helpEmail} | ||
onChange={(event) => { | ||
onChangeFn("helpEmail", event); | ||
}} | ||
|
@@ -62,6 +72,7 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
<InputLabel label="Phone number" htmlFor="helpPhone"> | ||
<Input | ||
name="helpPhone" | ||
value={formik.values.helpPhone} | ||
onChange={(event) => { | ||
onChangeFn("helpPhone", event); | ||
}} | ||
|
@@ -72,6 +83,7 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
<Input | ||
multiline | ||
name="helpOpeningHours" | ||
value={formik.values.helpOpeningHours} | ||
onChange={(event) => { | ||
onChangeFn("helpOpeningHours", event); | ||
}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,11 +47,11 @@ const teamSettingsRoutes = compose( | |
route: "design", | ||
Component: DesignSettings, | ||
}, | ||
// { | ||
// name: "General", | ||
// route: "general", | ||
// Component: GeneralSettings, | ||
// }, | ||
{ | ||
name: "General", | ||
route: "general", | ||
Component: GeneralSettings, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think I'd reorder this array to be General → Design → Team There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DafyddLlyr do you think it is worth doing these types of changes as a final PR when error handling is all sorted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thought about it again, and tit doesn't really make it difference, so I've added it to this PR |
||
]} | ||
/> | ||
), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still missing some basic validation on this field. I appreciate there's still work to be done on the boundary field, but if we're going to unhide the menu and allow Editors to access it we should either put this in place first, or hide this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do the error handling in another PR, hopefully make it a lot cleaner. Current ones were just to test my understanding of formik and yup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added basic validation now though