Skip to content
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

fix: disable grant and poll fields on submission vp not met #1353

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/GrantRequest/GrantRequestFundingSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export default function GrantRequestFundingSection({
onChange={(value) => setValue('projectDuration', Number(value))}
label={t('page.submit_grant.funding_section.project_duration_title')}
unit="months"
disabled={isFormDisabled}
/>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/components/ProjectRequest/NumberSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ interface Props {
unit: UnitTypeLongPlural | UnitTypeLongPlural[]
subtitle?: string
onUnitChange?: (unit: UnitTypeLongPlural) => void
disabled?: boolean
}

const NumberSelector = ({ value, onChange, min, max, label, unit, onUnitChange, subtitle }: Props) => {
const NumberSelector = ({ value, onChange, min, max, label, unit, onUnitChange, subtitle, disabled }: Props) => {
const t = useFormatMessage()
const handleAddClick = useCallback(() => {
if (value === max) {
Expand Down Expand Up @@ -66,11 +67,11 @@ const NumberSelector = ({ value, onChange, min, max, label, unit, onUnitChange,
<div className="NumberSelector__Container">
<div className="NumberSelector__InputContainer">
<div className="NumberSelector__Input">
<button className="NumberSelector__Button" onClick={handleRemoveClick}>
<button className="NumberSelector__Button" onClick={handleRemoveClick} disabled={disabled}>
<Remove />
</button>
<span className="NumberSelector__Value">{value}</span>
<button className="NumberSelector__Button" onClick={handleAddClick}>
<button className="NumberSelector__Button" onClick={handleAddClick} disabled={disabled}>
<Add />
</button>
</div>
Expand All @@ -80,6 +81,7 @@ const NumberSelector = ({ value, onChange, min, max, label, unit, onUnitChange,
<Dropdown
className="NumberSelector__Dropdown"
selection
disabled={disabled}
defaultValue={unit[0]}
options={getUnitOptions(unit)}
onChange={(_, { value }) => handleUnitChange(value as UnitTypeLongPlural)}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/submit/grant.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@
}

.GrantRequest__SubmissionVpNotMetText {
margin-bottom: 24px !important;
margin-top: 24px !important;
}
26 changes: 15 additions & 11 deletions src/pages/submit/grant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export default function SubmitGrant() {
navigate(locations.submit(ProposalType.Grant), { replace: true })
}}
onValidation={handleFundingSectionValidation}
isFormDisabled={isFormDisabled}
isFormDisabled={isFormDisabled || submissionVpNotMet}
sectionNumber={getSectionNumber()}
/>

Expand All @@ -264,7 +264,7 @@ export default function SubmitGrant() {
patchGrantRequest((prevState) => ({ ...prevState, ...data }))
patchValidationState({ generalInformationSectionValid: sectionValid })
}}
isFormDisabled={isFormDisabled}
isFormDisabled={isFormDisabled || submissionVpNotMet}
sectionNumber={getSectionNumber()}
/>

Expand All @@ -274,6 +274,7 @@ export default function SubmitGrant() {
patchValidationState({ teamSectionValid: sectionValid })
}}
sectionNumber={getSectionNumber()}
isDisabled={isFormDisabled || submissionVpNotMet}
/>

<GrantRequestDueDiligenceSection
Expand All @@ -284,32 +285,26 @@ export default function SubmitGrant() {
}}
sectionNumber={getSectionNumber()}
projectDuration={grantRequest.projectDuration}
isDisabled={isFormDisabled || submissionVpNotMet}
/>

{grantRequest.category && (
<GrantRequestCategorySection
category={grantRequest.category}
onValidation={handleCategorySection}
isFormDisabled={isFormDisabled}
isFormDisabled={isFormDisabled || submissionVpNotMet}
sectionNumber={getSectionNumber()}
/>
)}

<GrantRequestFinalConsentSection
category={grantRequest.category}
onValidation={(sectionValid) => patchValidationState({ finalConsentSectionValid: sectionValid })}
isFormDisabled={isFormDisabled}
isFormDisabled={isFormDisabled || submissionVpNotMet}
sectionNumber={getSectionNumber()}
/>

<Container className="ContentLayout__Container">
{submissionVpNotMet && (
<ContentSection className="ProjectRequestSection__Content">
<Text className="GrantRequest__SubmissionVpNotMetText" size="lg" color="primary">
{t('error.grant.submission_vp_not_met', { threshold: SUBMISSION_THRESHOLD_GRANT })}
</Text>
</ContentSection>
)}
<ContentSection className="ProjectRequestSection__Content">
<div>
<Button
Expand All @@ -323,6 +318,15 @@ export default function SubmitGrant() {
</div>
</ContentSection>
</Container>
<Container className="ContentLayout__Container">
{submissionVpNotMet && (
<ContentSection className="ProjectRequestSection__Content">
<Text className="GrantRequest__SubmissionVpNotMetText" size="lg" color="primary">
{t('error.grant.submission_vp_not_met', { threshold: SUBMISSION_THRESHOLD_GRANT })}
</Text>
</ContentSection>
)}
</Container>
</>
)}
{!!submitError && (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/submit/poll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export default function SubmitPoll() {
</div>
</ContentSection>
<ContentSection>
<CoAuthors setCoAuthors={setCoAuthors} isDisabled={formDisabled} />
<CoAuthors setCoAuthors={setCoAuthors} isDisabled={formDisabled || submissionVpNotMet} />
</ContentSection>
<ContentSection>
<Button type="submit" primary disabled={formDisabled || submissionVpNotMet} loading={isSubmitting}>
Expand Down
Loading