-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3be2b8b
add update fn to store and forms
RODO94 8d103fd
add fetch values to forms
RODO94 1db71cd
add homepage to formik and reorder setting order
RODO94 4a5a0eb
basic validation for boundary url field
RODO94 feba3e2
add input based error wrapping to settingsForm and team settings forms
RODO94 bdac32d
remove console log from Contact Form
RODO94 8e891f8
Revert "basic validation for boundary url field"
RODO94 a4f90f4
revert additions for error handling in settings form
RODO94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
@@ -13,16 +14,26 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
.email("Please enter valid email") | ||
.required("Help Email is required"), | ||
helpPhone: Yup.string().required("Help Phone is required"), | ||
helpOpeningHours: Yup.string(), | ||
homepage: Yup.string().url("Please enter a valid URL for the homepage"), | ||
helpOpeningHours: Yup.string().required(), | ||
homepage: Yup.string() | ||
.url("Please enter a valid URL for the homepage") | ||
.required("Enter a homepage"), | ||
}); | ||
|
||
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.
|
||
homepage: values.homepage, | ||
}); | ||
if (isSuccess) { | ||
onSuccess(); | ||
resetForm({ values }); | ||
} | ||
}, | ||
}); | ||
|
||
|
@@ -41,18 +52,20 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
} | ||
input={ | ||
<> | ||
<InputLabel label="Homepage URL" htmlFor="homepageUrl"> | ||
<InputLabel label="Homepage URL" htmlFor="homepage"> | ||
<Input | ||
name="homepage" | ||
onChange={(event) => { | ||
onChangeFn("homepage", event); | ||
}} | ||
id="homepageUrl" | ||
value={formik.values.homepage} | ||
id="homepage" | ||
/> | ||
</InputLabel> | ||
<InputLabel label="Contact email address" htmlFor="helpEmail"> | ||
<Input | ||
name="helpEmail" | ||
value={formik.values.helpEmail} | ||
onChange={(event) => { | ||
onChangeFn("helpEmail", event); | ||
}} | ||
|
@@ -62,6 +75,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 +86,7 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
<Input | ||
multiline | ||
name="helpOpeningHours" | ||
value={formik.values.helpOpeningHours} | ||
onChange={(event) => { | ||
onChangeFn("helpOpeningHours", event); | ||
}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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