Skip to content

Commit

Permalink
deps: Update formik
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 6, 2023
1 parent 8e7bddd commit 558d076
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 68 deletions.
20 changes: 10 additions & 10 deletions app/components/Comments/CommentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,33 +144,33 @@ class CommentForm extends React.Component {
)
}

renderCommentForm(values, setFieldValue, isValid) {
renderCommentForm(values, setFieldValue, isDisabled) {
const { replyTo, t } = this.props
const i18nParams = replyTo ? { context: 'reply' } : null

return !values.source ? (
<SubmitButton my={1} disabled={!isValid}>
<SubmitButton my={1} disabled={isDisabled}>
{t('comment.post', i18nParams)}
</SubmitButton>
) : (
<Flex flex="1 1 460px" flexWrap="wrap">
<SubmitButton my={1} mr={1} disabled={!isValid} flex="1 1 130px">
<SubmitButton my={1} mr={1} disabled={isDisabled} flex="1 1 130px">
{t('comment.post', i18nParams)}
</SubmitButton>
<Flex flex="3 1">
<SubmitButton
my={1}
mr={1}
className="is-success"
disabled={!isValid || !values.source}
disabled={isDisabled || !values.source}
onClick={() => setFieldValue('approve', true)}
>
{t('comment.approve', i18nParams)}
</SubmitButton>
<SubmitButton
my={1}
className="is-danger"
disabled={!isValid}
disabled={isDisabled}
onClick={() => setFieldValue('approve', false)}
>
{t('comment.refute', i18nParams)}
Expand All @@ -180,7 +180,7 @@ class CommentForm extends React.Component {
)
}

renderIncitate(values, setFieldValue, isValid) {
renderIncitate(values, setFieldValue, isDisabled) {
const { replyTo, inciteToParticipate } = this.props
const i18nParams = replyTo ? { context: 'reply' } : null
const name_class = inciteToParticipate == 'approve' ? 'is-success' : 'is-danger'
Expand All @@ -194,7 +194,7 @@ class CommentForm extends React.Component {
my={1}
mr={1}
className={name_class}
disabled={!isValid || !values.source}
disabled={isDisabled || !values.source}
onClick={() => setFieldValue('approve', approveField)}
>
{this.props.t(comment, i18nParams)}
Expand All @@ -210,7 +210,7 @@ class CommentForm extends React.Component {

return (
<Formik initialValues={initialValues} validate={this.validate} onSubmit={this.onSubmit}>
{({ handleBlur, handleSubmit, values, setFieldValue, isValid, errors }) => (
{({ handleBlur, handleSubmit, values, setFieldValue, isValid, dirty, errors }) => (
<Box flex="1 1" as="form" onSubmit={handleSubmit}>
<Flex flexDirection="column">
<Container mb={2} position="relative">
Expand Down Expand Up @@ -252,8 +252,8 @@ class CommentForm extends React.Component {
</Flex>

{inciteToParticipate
? this.renderIncitate(values, setFieldValue, isValid)
: this.renderCommentForm(values, setFieldValue, isValid)}
? this.renderIncitate(values, setFieldValue, !isValid || !dirty)
: this.renderCommentForm(values, setFieldValue, !isValid || !dirty)}
</Flex>
{this.renderHelpMessage()}
</Flex>
Expand Down
3 changes: 2 additions & 1 deletion app/components/Speakers/EditSpeakerFormModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class EditSpeakerFormModal extends React.PureComponent {
values,
isSubmitting,
isValid,
dirty,
submitForm,
errors,
}) => (
Expand All @@ -126,7 +127,7 @@ class EditSpeakerFormModal extends React.PureComponent {
<div className="form-buttons">
<Button
onClick={submitForm}
disabled={isSubmitting || !isValid}
disabled={isSubmitting || !isValid || !dirty}
className={classNames('is-primary', { 'is-loading': isSubmitting })}
>
<Save size="1.25em" />
Expand Down
96 changes: 40 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"diff": "~4.0.2",
"dotenv-webpack": "~7.0.3",
"faker": "~5.5.3",
"formik": "^1.4.1",
"formik": "^2.2.9",
"graphql": "^14.0.2",
"graphql-tag": "~2.10.1",
"i18next": "~19.0.2",
Expand Down

0 comments on commit 558d076

Please sign in to comment.