-
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: team_settings
form error validation
#3368
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dc975b4
alter tone of voice for error messaging
RODO94 af0ce99
remove error wrapper from SettingsForm
RODO94 bbb4efb
update theme forms, color picker, and contact form
RODO94 3b0dfa6
add error messaging to boundary form and update error messaging
RODO94 e2e191e
add changes request on colour picker
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,16 @@ import { FormProps } from "."; | |
export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | ||
const formSchema = Yup.object().shape({ | ||
helpEmail: Yup.string() | ||
.email("Please enter valid email") | ||
.required("Help Email is required"), | ||
helpPhone: Yup.string().required("Help Phone is required"), | ||
helpOpeningHours: Yup.string().required(), | ||
.email( | ||
"Enter an email address in the correct format, like [email protected]", | ||
) | ||
.required("Enter a help email address"), | ||
helpPhone: Yup.string().required("Enter a help phone number"), | ||
helpOpeningHours: Yup.string().required("Enter your opening hours"), | ||
homepage: Yup.string() | ||
.url("Please enter a valid URL for the homepage") | ||
.url( | ||
"Enter a homepage URL in the correct format, like https://www.localauthority.gov.uk/", | ||
) | ||
.required("Enter a homepage"), | ||
}); | ||
|
||
|
@@ -59,13 +63,15 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
onChangeFn("homepage", event); | ||
}} | ||
value={formik.values.homepage} | ||
errorMessage={formik.errors.homepage} | ||
id="homepage" | ||
/> | ||
</InputLabel> | ||
<InputLabel label="Contact email address" htmlFor="helpEmail"> | ||
<Input | ||
name="helpEmail" | ||
value={formik.values.helpEmail} | ||
errorMessage={formik.errors.helpEmail} | ||
onChange={(event) => { | ||
onChangeFn("helpEmail", event); | ||
}} | ||
|
@@ -76,6 +82,7 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
<Input | ||
name="helpPhone" | ||
value={formik.values.helpPhone} | ||
errorMessage={formik.errors.helpPhone} | ||
onChange={(event) => { | ||
onChangeFn("helpPhone", event); | ||
}} | ||
|
@@ -87,6 +94,7 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
multiline | ||
name="helpOpeningHours" | ||
value={formik.values.helpOpeningHours} | ||
errorMessage={formik.errors.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,16 @@ import Box, { BoxProps } from "@mui/material/Box"; | |
import ButtonBase, { ButtonBaseProps } from "@mui/material/ButtonBase"; | ||
import { styled } from "@mui/material/styles"; | ||
import Typography from "@mui/material/Typography"; | ||
import { ErrorMessage } from "formik"; | ||
import React, { useState } from "react"; | ||
import { ChromePicker, ColorChangeHandler } from "react-color"; | ||
import ErrorWrapper from "ui/shared/ErrorWrapper"; | ||
|
||
export interface Props { | ||
label?: string; | ||
inline?: boolean; | ||
color?: string; | ||
errorMessage?: string | undefined; | ||
onChange?: (newColor: string) => void; | ||
} | ||
|
||
|
@@ -93,28 +96,30 @@ export default function ColorPicker(props: Props): FCReturn { | |
}; | ||
|
||
return ( | ||
<Root inline={props.inline}> | ||
<Typography mr={2} variant="body2" component="label"> | ||
{props.label || "Background colour"}:{" "} | ||
</Typography> | ||
<StyledButtonBase show={show} onClick={handleClick} disableRipple> | ||
<Swatch sx={{ backgroundColor: props.color }} className="swatch" /> | ||
{props.color} | ||
</StyledButtonBase> | ||
{show ? ( | ||
<Popover className="popover"> | ||
<Cover | ||
onClick={handleClose} | ||
aria-label="Close Colour Picker" | ||
disableRipple | ||
/> | ||
<ChromePicker | ||
color={props.color} | ||
disableAlpha={true} | ||
onChange={handleChange} | ||
/> | ||
</Popover> | ||
) : null} | ||
</Root> | ||
<ErrorWrapper error={props.errorMessage || undefined} id="settings-error"> | ||
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. We should use a unique id here, for example |
||
<Root inline={props.inline}> | ||
<Typography mr={2} variant="body2" component="label"> | ||
{props.label || "Background colour"}:{" "} | ||
</Typography> | ||
<StyledButtonBase show={show} onClick={handleClick} disableRipple> | ||
<Swatch sx={{ backgroundColor: props.color }} className="swatch" /> | ||
{props.color} | ||
</StyledButtonBase> | ||
{show ? ( | ||
<Popover className="popover"> | ||
<Cover | ||
onClick={handleClose} | ||
aria-label="Close Colour Picker" | ||
disableRipple | ||
/> | ||
<ChromePicker | ||
color={props.color} | ||
disableAlpha={true} | ||
onChange={handleChange} | ||
/> | ||
</Popover> | ||
) : null} | ||
</Root> | ||
</ErrorWrapper> | ||
); | ||
} |
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.
nit: This is the same thing but a bit more terse and matches our code style. The
?
following the property name indicates that this property can beundefined
.