-
-
Notifications
You must be signed in to change notification settings - Fork 40
update feedback form #710
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
Merged
Merged
update feedback form #710
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a3d1263
make feedback from custom and API insert to supbase
AnilKumar3494 5e4eb3d
fix error states
AnilKumar3494 a0d13e8
Merge branch 'develop' into fix-feedback-form
AnilKumar3494 eea5bad
add: zod, schema
AnilKumar3494 74be625
quick fixes,
AnilKumar3494 6671f54
add fomwrapper and mutation
AnilKumar3494 4d2677a
adjust formcheckboxfield
AnilKumar3494 5e39c80
add checkbox wrapper
AnilKumar3494 e39fc61
git missed
AnilKumar3494 605c0d6
remove log
AnilKumar3494 9644ff9
update fontsize for alerts
AnilKumar3494 076d277
form refactor
AnilKumar3494 0e49e50
update file struct
AnilKumar3494 7258f7c
feedbackform types organized
AnilKumar3494 e985247
add socials
AnilKumar3494 6954cc5
add socail links and mobile resp
AnilKumar3494 7eb07b2
almost final working version of form
AnilKumar3494 66d578f
more finizing
AnilKumar3494 c29e560
add: LinkedIn
AnilKumar3494 a474adc
resolved comments
AnilKumar3494 7435da4
Merge branch 'develop' into fix-feedback-form
AnilKumar3494 6c0c5e3
fix schema and type
AnilKumar3494 f60f854
fix schema and type
AnilKumar3494 9f1e7bc
Merge branch 'develop' into fix-feedback-form
AnilKumar3494 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { Stack } from '@mui/material'; | ||
| import Page from 'components/Page/Page'; | ||
| import FeedbackForm from 'components/forms/FeedbackForm/FeedbackForm'; | ||
| import SocialLinks from 'components/SocialLinks/SocialLinks'; | ||
| import EmailConnect from 'components/EmailConnect/EmailConnect'; | ||
| import useIsMobile from 'hooks/useIsMobile'; | ||
| import FeedbackFormSuccess from 'components/forms/FeedbackFromSuccess/FeedbackFormSuccess'; | ||
| import useAddFeedbackMutation from 'hooks/mutations/useAddFeedbackMutation'; | ||
|
|
||
| const TITLE = 'Contact'; | ||
|
|
||
| const Contact = () => { | ||
| const isMobile = useIsMobile(); | ||
| const { | ||
| mutate: addFeedbackMutate, | ||
| isPending, | ||
| isSuccess | ||
| } = useAddFeedbackMutation(); | ||
|
|
||
| return ( | ||
| <Page title={TITLE} data-cy="contact"> | ||
| {isSuccess ? ( | ||
| <FeedbackFormSuccess /> | ||
| ) : ( | ||
| <FeedbackForm | ||
| onSubmit={data => addFeedbackMutate(data)} | ||
| isPending={isPending} | ||
| /> | ||
| )} | ||
|
|
||
| {(isMobile || isSuccess) && ( | ||
| <Stack | ||
| gap={isMobile ? 2 : 8} | ||
| alignItems={isMobile ? 'center' : 'start'} | ||
| direction={isMobile ? 'column' : 'row'} | ||
| sx={{ | ||
| width: '100%' | ||
| }} | ||
| > | ||
| <SocialLinks /> | ||
| <EmailConnect /> | ||
| </Stack> | ||
| )} | ||
| </Page> | ||
| ); | ||
| }; | ||
|
|
||
| export default Contact; |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Link, Stack, Typography } from '@mui/material'; | ||
| import useIsMobile from 'hooks/useIsMobile'; | ||
|
|
||
| const Connect = () => { | ||
| const isMobile = useIsMobile(); | ||
| return ( | ||
| <Stack direction="column" gap={1}> | ||
| {!isMobile && <Typography variant="h6">Connect</Typography>} | ||
| <Typography textAlign={isMobile ? 'center' : 'start'}> | ||
| For all other inquiries, {isMobile && <br />}email{' '} | ||
| <Link href="mailto:phlaskecosystem@gmail.com"> | ||
| phlaskecosystem@gmail.com | ||
| </Link> | ||
| </Typography> | ||
| </Stack> | ||
| ); | ||
| }; | ||
|
|
||
| export default Connect; |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { Link, Stack, Typography } from '@mui/material'; | ||
| import { SocialFacebook, SocialInstagram, SocialLinkedin } from 'icons'; | ||
|
|
||
| const SocialContacts = () => { | ||
| return ( | ||
| <Stack direction="column" alignItems="center" gap={1}> | ||
| <Typography variant="h6">Follow PHLASK</Typography> | ||
| <Stack direction={'row'} gap={4}> | ||
|
AnilKumar3494 marked this conversation as resolved.
|
||
| <Link | ||
| sx={theme => ({ | ||
| fontSize: theme.typography.pxToRem(48) | ||
| })} | ||
| href="https://www.facebook.com/PHLASKecosystem/" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <SocialFacebook /> | ||
| </Link> | ||
| <Link | ||
| sx={theme => ({ | ||
| fontSize: theme.typography.pxToRem(48) | ||
| })} | ||
| href="https://www.instagram.com/phlaskecosystem/" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <SocialInstagram /> | ||
| </Link> | ||
| <Link | ||
| sx={theme => ({ | ||
| fontSize: theme.typography.pxToRem(48) | ||
| })} | ||
| href="https://www.linkedin.com/company/phlask/" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <SocialLinkedin /> | ||
| </Link> | ||
| </Stack> | ||
| </Stack> | ||
| ); | ||
| }; | ||
|
|
||
| export default SocialContacts; | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import { Stack, Button, Typography } from '@mui/material'; | ||
| import { zodResolver } from '@hookform/resolvers/zod'; | ||
| import { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'; | ||
| import feedbackFormSchema, { | ||
| type FeedbackFormValues | ||
| } from 'schemas/feedbackFormSchema'; | ||
| import FormTextField from 'components/forms/FormTextField/FormTextField'; | ||
| import FormCheckboxField from 'components/forms/FormCheckboxField/FormCheckboxField'; | ||
|
|
||
| type FormValues = FeedbackFormValues; | ||
|
|
||
| type FeedbackFormProps = { | ||
| onSubmit: (data: FormValues) => void; | ||
| isPending: boolean; | ||
| }; | ||
|
|
||
| const SCHEMA = feedbackFormSchema; | ||
|
|
||
| const FeedbackForm = ({ onSubmit, isPending }: FeedbackFormProps) => { | ||
| const methods = useForm<FormValues>({ | ||
| defaultValues: { | ||
| name: '', | ||
| email: '', | ||
| feedback: '', | ||
| is_interested_in_contributing: false | ||
| }, | ||
| resolver: zodResolver(SCHEMA) | ||
| }); | ||
|
|
||
| const { handleSubmit } = methods; | ||
|
|
||
| const handleFormSubmit: SubmitHandler<FormValues> = feedbackData => { | ||
| onSubmit(feedbackData); | ||
| }; | ||
|
|
||
| return ( | ||
| <FormProvider {...methods}> | ||
| <Typography variant="h6">Share Feedback</Typography> | ||
| <form onSubmit={handleSubmit(handleFormSubmit)}> | ||
| <Stack | ||
| gap={2} | ||
| sx={{ | ||
| marginBottom: 4 | ||
| }} | ||
| > | ||
| <FormTextField<FormValues> | ||
| name="name" | ||
| label="Name" | ||
| placeholder="Enter Your Name" | ||
| required | ||
| fullWidth | ||
| sx={theme => ({ | ||
| [theme.breakpoints.up('md')]: { | ||
| width: '50%' | ||
| } | ||
| })} | ||
| /> | ||
|
|
||
| <FormTextField<FormValues> | ||
| name="email" | ||
| label="Email" | ||
| placeholder="example@email.com" | ||
| required | ||
| fullWidth | ||
| sx={theme => ({ | ||
| [theme.breakpoints.up('md')]: { | ||
| width: '50%' | ||
| } | ||
| })} | ||
| /> | ||
|
|
||
| <FormTextField<FormValues> | ||
| name="feedback" | ||
| label="Feedback" | ||
| placeholder="Share your feedback and thoughts" | ||
| multiline | ||
| minRows={3} | ||
| required | ||
| fullWidth | ||
| helperText="Please do not include any sensitive personal information." | ||
| /> | ||
|
|
||
| <FormCheckboxField<FormValues> | ||
| name="is_interested_in_contributing" | ||
| label="I'm interested in helping PHLASK with future research" | ||
| labelPlacement="end" | ||
| /> | ||
|
|
||
| <Button | ||
| type="submit" | ||
| variant="contained" | ||
| loading={isPending} | ||
| sx={theme => ({ | ||
| backgroundColor: '#10B6FF', | ||
| borderRadius: '8px', | ||
| alignSelf: 'center', | ||
| [theme.breakpoints.up('md')]: { | ||
| width: '50%', | ||
| alignSelf: 'flex-start' | ||
| } | ||
| })} | ||
| > | ||
| Submit Feedback | ||
| </Button> | ||
| </Stack> | ||
| </form> | ||
| </FormProvider> | ||
| ); | ||
| }; | ||
|
|
||
| export default FeedbackForm; |
28 changes: 28 additions & 0 deletions
28
src/components/forms/FeedbackFromSuccess/FeedbackFormSuccess.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { Stack, Typography } from '@mui/material'; | ||
| import { PhillySkyline } from 'icons'; | ||
|
|
||
| const FeedbackFormSuccess = () => { | ||
| return ( | ||
| <Stack | ||
| sx={{ | ||
| height: '100%', | ||
| alignItems: 'center', | ||
| justifyContent: 'space-between', | ||
| textAlign: 'center', | ||
| paddingBlock: '20px' | ||
| }} | ||
| > | ||
| <Typography | ||
| variant="h2" // @ts-expect-error Need to fix theme declaration | ||
| sx={theme => ({ color: theme.palette.global.darkUI.darkGrey2 })} | ||
| > | ||
| Thank you for your feedback! | ||
| </Typography> | ||
| <Stack sx={{ width: '100%', paddingInline: '21px' }}> | ||
| <PhillySkyline width="100%" height="306.02" /> | ||
| </Stack> | ||
| </Stack> | ||
| ); | ||
| }; | ||
|
|
||
| export default FeedbackFormSuccess; |
28 changes: 28 additions & 0 deletions
28
src/components/forms/FormCheckboxField/FormCheckboxField.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { Checkbox, FormControl, FormControlLabel } from '@mui/material'; | ||
| import { useFormContext, type FieldValues, type Path } from 'react-hook-form'; | ||
|
|
||
| type FormCheckboxFieldProps<Values extends FieldValues> = { | ||
| name: Path<Values>; | ||
| label: string; | ||
| labelPlacement?: 'bottom' | 'end' | 'start' | 'top'; | ||
| }; | ||
|
|
||
| const FormCheckboxField = <Values extends FieldValues>({ | ||
| name, | ||
| label, | ||
| labelPlacement = 'end' | ||
| }: FormCheckboxFieldProps<Values>) => { | ||
| const { register } = useFormContext<Values>(); | ||
|
|
||
| return ( | ||
| <FormControl> | ||
| <FormControlLabel | ||
| control={<Checkbox {...register(name)} />} | ||
| label={label} | ||
| labelPlacement={labelPlacement} | ||
| /> | ||
| </FormControl> | ||
| ); | ||
| }; | ||
|
|
||
| export default FormCheckboxField; |
Oops, something went wrong.
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.
this height of 85vh for mobile to reflect figma design