-
Notifications
You must be signed in to change notification settings - Fork 3
initial integration of formik & formik-antd to assign badge page #24
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
Open
jontkoh
wants to merge
4
commits into
develop
Choose a base branch
from
@client/assign-badge-formik
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
734d44d
initial integration of formik & formik-antd to assign badge page
jontkoh c2cfac8
Merge branch 'develop' of https://github.com/FightPandemics/FightPand…
jontkoh 547fba5
Merge branch 'develop' of https://github.com/FightPandemics/FightPand…
jontkoh 77eb532
added htmltype to both buttons of account/nonaccount form pages
jontkoh 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
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 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 |
|---|---|---|
| @@ -1,88 +1,15 @@ | ||
| /* eslint-disable max-len */ | ||
| /* eslint-disable no-unused-vars */ | ||
| import React, { useState } from "react"; | ||
| import { Form, Input, Radio } from "antd"; | ||
| import styled from "styled-components"; | ||
| import { Form } from "antd"; | ||
| import { useFormik, FormikProvider } from "formik"; | ||
| import { Form as FormikAntdForm, Input, Radio } from "formik-antd"; | ||
| import StyledForm from "./StyledAccountHolderForm"; | ||
| import Modal from "../../components/Modals/Modal"; | ||
| import useModal from "../../hooks/useModal"; | ||
| import PrimaryFormButton from "../../components/Button/PrimaryFormButton"; | ||
| import { theme } from "../../constants/theme"; | ||
| import SearchInput from "../../components/Input/SearchInput"; | ||
| const { body } = theme.typography.font.family; | ||
| const { royalBlue } = theme.colors; | ||
| const { TextArea } = Input; | ||
|
|
||
| const StyledForm = styled(Form)` | ||
|
|
||
| width: 33%; | ||
| min-width: 250px; | ||
| margin: 2.5vh auto; | ||
|
|
||
| button { | ||
| width: 100%; | ||
| margin: 0; | ||
| } | ||
|
|
||
| span { | ||
| text-align: left; | ||
| } | ||
|
|
||
| .ant-form-item-label label { | ||
| padding: 0; | ||
| width: 100%; | ||
| min-width: 250px; | ||
| font-weight: 800; | ||
| font-size: 16px; | ||
| font-family: ${body}; | ||
| } | ||
|
|
||
| .ant-input { | ||
| width: 100%; | ||
| min-width: 250px; | ||
| } | ||
| .modal { | ||
| border-radius: 10px; | ||
| } | ||
| h4 { padding: 0; margin: 0; } | ||
|
|
||
| .ant-form-item-control-input-content { | ||
| position: relative; | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .ant-form-item-control-input-content .jpEryk { | ||
| align-self: flex-end; | ||
| width: 226px; | ||
| } | ||
|
|
||
| .radio { | ||
| display: flex | ||
| flex-direction: row | ||
| margin-bottom: 10px; | ||
| .ant-radio-wrapper { | ||
| justify-content: space-between; | ||
| } | ||
| } | ||
|
|
||
| .ant-radio-checked .ant-radio-inner{ | ||
| border-color: ${royalBlue} !important ; | ||
| } | ||
|
|
||
| .ant-radio-checked:before{ | ||
| background-color: ${royalBlue}; | ||
| } | ||
|
|
||
| .ant-radio-checked .ant-radio-inner:after{ | ||
| background-color: ${royalBlue}; | ||
| } | ||
|
|
||
| .ant-radio:hover .ant-radio-inner { | ||
| border-color: ${royalBlue} ; | ||
| } | ||
| `; | ||
|
|
||
| export default function AccountHolderForm() { | ||
| export default function NonAccountHolderForm() { | ||
| const { isShowing, toggle } = useModal(); | ||
| const [form] = Form.useForm(); | ||
| const [formLayout, setFormLayout] = useState("vertical"); | ||
|
|
@@ -122,49 +49,67 @@ export default function AccountHolderForm() { | |
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <StyledForm | ||
| id = "create-badge-form" | ||
| {...formItemLayout} | ||
| layout={formLayout} | ||
| form={form} | ||
| initialValues={{ | ||
| layout: formLayout, | ||
| }} | ||
| onValuesChange={onFormLayoutChange} | ||
| > | ||
| <Form.Item label= "Share link with a non-account holder"> | ||
| <span>Name</span> | ||
| <Input placeholder="First and Last Name" forminputs={formInputs(value)} /> | ||
| </Form.Item> | ||
| <Form.Item > | ||
| <Radio.Group className="radio" onChange={onChange} value={value} forminputs={formInputs({ value })}> | ||
| <Radio value={1}>I know the recipient's email </Radio> | ||
| <Radio value={2}>I don't know the recipient's email </Radio> | ||
| </Radio.Group> | ||
| </Form.Item> | ||
| const handleSubmit = values => { | ||
| alert(JSON.stringify(values, null, 2)); | ||
| }; | ||
|
|
||
| {value === 1 | ||
| ? ( | ||
| <Form.Item label=""> | ||
| <span>Email</span> | ||
| <Input placeholder="Email of non-account holder recipient" /> | ||
| </Form.Item>) | ||
| : null | ||
| } | ||
| const formik = useFormik({ | ||
| initialValues: { | ||
| name: "", | ||
| email: "", | ||
| }, | ||
| onSubmit: values => { | ||
| handleSubmit(values); | ||
| }, | ||
| }); | ||
|
|
||
| <Form.Item> | ||
| <PrimaryFormButton className="btn-right" type="primary" onClick={toggle} onSubmit={linkSubmitHandler()}>Generate Link to Share</PrimaryFormButton> | ||
| <Modal | ||
| isShowing={isShowing} | ||
| hide={toggle} | ||
| modalWidth={800} | ||
| title="Share Link with a non-account holder" | ||
| buttonPrimary="Copy URL" | ||
| buttonSecondary="Link" | ||
| modalBodyText="The badge link has been successfully generated for [name]. Please copy this link to send to them!" | ||
| /> | ||
| </Form.Item> | ||
| </StyledForm> | ||
| return ( | ||
| <FormikProvider value={formik}> | ||
| <StyledForm | ||
| id = "create-badge-form" | ||
| {...formItemLayout} | ||
| layout={formLayout} | ||
| form={form} | ||
| initialValues={{ | ||
| layout: formLayout, | ||
| }} | ||
| onValuesChange={onFormLayoutChange} | ||
| > | ||
| <FormikAntdForm> | ||
| <Form.Item label= "Share link with a non-account holder"> | ||
| <span>Name</span> | ||
| <Input name="name" placeholder="First and Last Name" forminputs={formInputs(value)} /> | ||
| </Form.Item> | ||
| <Form.Item > | ||
| <Radio.Group className="radio" onChange={onChange} value={value} forminputs={formInputs({ value })}> | ||
| <Radio value={1}>I know the recipient's email </Radio> | ||
| <Radio value={2}>I don't know the recipient's email </Radio> | ||
| </Radio.Group> | ||
| </Form.Item> | ||
|
|
||
| {value === 1 | ||
| ? ( | ||
| <Form.Item label=""> | ||
| <span>Email</span> | ||
| <Input name="email" placeholder="Email of non-account holder recipient" /> | ||
| </Form.Item>) | ||
| : null | ||
| } | ||
|
|
||
| <Form.Item> | ||
| <PrimaryFormButton className="btn-right" type="primary" onClick={toggle} onSubmit={handleSubmit}>Generate Link to Share</PrimaryFormButton> | ||
|
||
| <Modal | ||
| isShowing={isShowing} | ||
| hide={toggle} | ||
| modalWidth={800} | ||
| title="Share Link with a non-account holder" | ||
| buttonPrimary="Copy URL" | ||
| buttonSecondary="Link" | ||
| modalBodyText="The badge link has been successfully generated for [name]. Please copy this link to send to them!" | ||
| /> | ||
| </Form.Item> | ||
| </FormikAntdForm> | ||
| </StyledForm> | ||
| </FormikProvider> | ||
| ); | ||
| } | ||
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.
You will need to include the prop
htmlType="submit"to hook up the form values to the FormikonSubmitproperty. See Antd Button API reference and useFormik reference.