From 7087c701e64f5bf9c4192942018b43c19b5ed122 Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Thu, 20 Oct 2022 23:58:47 +0530 Subject: [PATCH 1/8] PROD-2643 #comment Wrong icon shown for bug hunt self-service --- .../lib/icon-wrapper/IconWrapper.module.scss | 18 ++++++++++ src-ts/lib/icon-wrapper/index.tsx | 17 +++++++++ .../work-factory/work.factory.ts | 5 ++- .../WorkServicePrice.module.scss | 14 -------- .../work-service-price/WorkServicePrice.tsx | 9 +++-- .../WorkTableTitleRenderer.module.scss | 9 +++++ .../WorkTableTitleRenderer.tsx | 35 ++++++++++++------- 7 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 src-ts/lib/icon-wrapper/IconWrapper.module.scss create mode 100644 src-ts/lib/icon-wrapper/index.tsx diff --git a/src-ts/lib/icon-wrapper/IconWrapper.module.scss b/src-ts/lib/icon-wrapper/IconWrapper.module.scss new file mode 100644 index 000000000..e182ce53f --- /dev/null +++ b/src-ts/lib/icon-wrapper/IconWrapper.module.scss @@ -0,0 +1,18 @@ +@import '../styles/includes'; + +.iconWrapper { + height: 48px; + width: 48px; + margin: 0 $space-lg $space-lg $space-lg; + background: $tc-grad12; + border-radius: 24px; + display: flex; + align-items: center; + justify-content: center; + + svg { + @include icon-xl; + color: $tc-white; + } +} + diff --git a/src-ts/lib/icon-wrapper/index.tsx b/src-ts/lib/icon-wrapper/index.tsx new file mode 100644 index 000000000..b1036868e --- /dev/null +++ b/src-ts/lib/icon-wrapper/index.tsx @@ -0,0 +1,17 @@ +import { FC } from 'react' +import classNames from 'classnames' + +import styles from './IconWrapper.module.scss' + +interface IconWrapperProps { + className?: string + icon: JSX.Element +} + +const IconWrapper: FC = ({ className, icon }: IconWrapperProps) => ( +
+ <>{icon} +
+) + +export default IconWrapper diff --git a/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts b/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts index af613f1b6..688fb0fd0 100644 --- a/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts +++ b/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts @@ -694,7 +694,10 @@ function getTypeCategory(type: WorkType): WorkTypeCategory { case WorkType.designLegacy: return WorkTypeCategory.design - // TOOD: other categories: qa and dev + case WorkType.bugHunt: + return WorkTypeCategory.qa + + // TOOD: other categories: dev default: return WorkTypeCategory.unknown } diff --git a/src-ts/tools/work/work-service-price/WorkServicePrice.module.scss b/src-ts/tools/work/work-service-price/WorkServicePrice.module.scss index d07266f40..71aeb5e19 100644 --- a/src-ts/tools/work/work-service-price/WorkServicePrice.module.scss +++ b/src-ts/tools/work/work-service-price/WorkServicePrice.module.scss @@ -4,20 +4,6 @@ margin-top: $space-xl; - .iconWrapper { - height: 48; - width: 48; - margin: 0 $space-lg $space-lg $space-lg; - background: $tc-grad12; - border-radius: 24px; - - svg { - @include icon-xl; - margin: $space-md; - color: $tc-white; - } - } - .inline { display: flex; flex-direction: row; diff --git a/src-ts/tools/work/work-service-price/WorkServicePrice.tsx b/src-ts/tools/work/work-service-price/WorkServicePrice.tsx index 2082b065f..0b6bfa3c1 100644 --- a/src-ts/tools/work/work-service-price/WorkServicePrice.tsx +++ b/src-ts/tools/work/work-service-price/WorkServicePrice.tsx @@ -1,6 +1,7 @@ import { FC } from 'react' import { IconOutline, textFormatMoneyLocaleString, Tooltip } from '../../../lib' +import IconWrapper from '../../../lib/icon-wrapper' import styles from './WorkServicePrice.module.scss' @@ -20,11 +21,9 @@ const ServicePrice: FC = (props: WorkServicePriceProps) = return (
-
- {!!showIcon && !!icon && ( - <>{icon} - )} -
+ {!!showIcon && !!icon && ( + + )}
{!hideTitle && (

diff --git a/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.module.scss b/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.module.scss index 759aff46c..5138e0082 100644 --- a/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.module.scss +++ b/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.module.scss @@ -27,4 +27,13 @@ margin-top: 6px; @include text-clamp(3); } + + .qa-icon { + margin: 0px 12px 0px 0px; + + svg { + min-width: unset; + margin: 0px; + } + } } diff --git a/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx b/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx index e413f74b6..20c64a5e3 100644 --- a/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx +++ b/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx @@ -1,37 +1,46 @@ -import { FC, SVGProps } from 'react' - +import { IconOutline } from '../../../../lib' +import IconWrapper from '../../../../lib/icon-wrapper' import { - Work, - WorkTypeCategory, - WorkTypeCategoryDataIcon, - WorkTypeCategoryDesignIcon, - WorkTypeCategoryUnknownIcon, + Work, + WorkTypeCategory, + WorkTypeCategoryDataIcon, + WorkTypeCategoryDesignIcon, + WorkTypeCategoryUnknownIcon, } from '../../work-lib' import styles from './WorkTableTitleRenderer.module.scss' function WorkTableTitleRenderer(data: Work): JSX.Element { - let Icon: FC> + let Icon: JSX.Element switch (data.typeCategory) { case WorkTypeCategory.data: - Icon = WorkTypeCategoryDataIcon + Icon = break case WorkTypeCategory.design: - Icon = WorkTypeCategoryDesignIcon + Icon = break - // TODO: qa and dev work categories + case WorkTypeCategory.qa: + Icon = ( + } + /> + ) + break + + // TODO: dev work categories default: - Icon = WorkTypeCategoryUnknownIcon + Icon = break } return (
- + {Icon}
{data.title} From 85cbfd68185039687c232ff766321ded5ccca833 Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Fri, 21 Oct 2022 00:02:15 +0530 Subject: [PATCH 2/8] PROD-2619 #comment Fix the back button on the first page is opening the previously visited page, not the Start Work page --- .../intake-forms/bug-hunt/BugHuntIntakeForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx index b0440119f..b10c5d6d6 100644 --- a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx +++ b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx @@ -52,7 +52,7 @@ const BugHuntIntakeForm: React.FC = () => { BugHuntFormConfig.buttons.primaryGroup[0].hidden = !isLoggedIn BugHuntFormConfig.buttons.primaryGroup[1].onClick = () => { setAction('submit') } if (BugHuntFormConfig.buttons.secondaryGroup) { - BugHuntFormConfig.buttons.secondaryGroup[0].onClick = () => { navigate(-1) } + BugHuntFormConfig.buttons.secondaryGroup[0].onClick = () => { navigate('/self-service/wizard') } } const [challenge, setChallenge]: [Challenge | undefined, Dispatch>] = useState() From 398fde6e91030d9c98c2b98a366d04fcdefc34bd Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Fri, 21 Oct 2022 00:03:41 +0530 Subject: [PATCH 3/8] PROD-2620 #comment Fix when opening bug hunt drafts after opening another work type's draft, the bug hunt drafts cannot be opened --- src/IntakeForm.jsx | 7 +++++-- src/constants/products/BugHunt/index.js | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src/constants/products/BugHunt/index.js diff --git a/src/IntakeForm.jsx b/src/IntakeForm.jsx index 7a043f806..9978825ad 100644 --- a/src/IntakeForm.jsx +++ b/src/IntakeForm.jsx @@ -1,4 +1,4 @@ -import { useNavigate, Route, Routes } from "react-router-dom"; +import { useNavigate, Route, Routes, useLocation } from "react-router-dom"; import _ from "lodash"; import React, { useContext, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; @@ -20,6 +20,7 @@ import { INTAKE_FORM_ROUTES as FIND_ME_DATA_INTAKE_FORM_ROUTES } from "./constan import { INTAKE_FORM_ROUTES as DATA_ADVISORY_INTAKE_FORM_ROUTES } from "./constants/products/DataAdvisory"; import { INTAKE_FORM_ROUTES as WEBSITE_DESIGN_INTAKE_FORM_ROUTES } from "./constants/products/WebsiteDesign"; import { INTAKE_FORM_ROUTES as WEBSITE_DESIGN_LEGACY_INTAKE_FORM_ROUTES } from "./constants/products/WebsiteDesignLegacy"; +import { BUG_HUNT_ROUTE } from "./constants/products/BugHunt"; import { getIntakeFormChallenges } from "./services/challenge"; import SelectWorkType from "./routes/SelectWorkType"; import DataExploration from "./routes/Products/DataExploration"; @@ -33,6 +34,7 @@ import { profileContext, WorkType } from "../src-ts"; export default function IntakeForm() { const dispatch = useDispatch(); + const location = useLocation(); const [isLoading, setIsLoading] = useState(false); const navigate = useNavigate() @@ -141,7 +143,8 @@ export default function IntakeForm() { }; const syncSavedData = (savedData) => { - if (!savedData) return; + const isBugHuntRoute = location.pathname.indexOf(BUG_HUNT_ROUTE) > -1 + if (!savedData || isBugHuntRoute) return; const { form, progress } = savedData; if (form) dispatch(saveForm(form)); if (progress?.currentStep) { diff --git a/src/constants/products/BugHunt/index.js b/src/constants/products/BugHunt/index.js new file mode 100644 index 000000000..09b172440 --- /dev/null +++ b/src/constants/products/BugHunt/index.js @@ -0,0 +1 @@ +export const BUG_HUNT_ROUTE = "/bug-hunt/"; \ No newline at end of file From 3467c18483c8d17352bc7195761087f52c649154 Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Fri, 21 Oct 2022 00:09:16 +0530 Subject: [PATCH 4/8] PROD-2760 #comment Fix issues with Timeline status in Bug hunt work --- .../work-functions/work-factory/work.factory.ts | 6 +++++- .../work-functions/work-store/challenge-phase-name.enum.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts b/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts index 688fb0fd0..5922367c1 100644 --- a/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts +++ b/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts @@ -548,7 +548,11 @@ function getProgress(challenge: Challenge, workStatus: WorkStatus): WorkProgress name: 'Submitted', }, { - date: getProgressStepDateStart(challenge, [ChallengePhaseName.registration]), + date: getProgressStepDateStart(challenge, [ + ChallengePhaseName.specificationReview, + ChallengePhaseName.specificationSubmission, + ChallengePhaseName.registration + ]), name: 'Started', }, { diff --git a/src-ts/tools/work/work-lib/work-provider/work-functions/work-store/challenge-phase-name.enum.ts b/src-ts/tools/work/work-lib/work-provider/work-functions/work-store/challenge-phase-name.enum.ts index dd3bffc1d..4b4267942 100644 --- a/src-ts/tools/work/work-lib/work-provider/work-functions/work-store/challenge-phase-name.enum.ts +++ b/src-ts/tools/work/work-lib/work-provider/work-functions/work-store/challenge-phase-name.enum.ts @@ -1,4 +1,6 @@ export enum ChallengePhaseName { + specificationReview = 'Specification Review', + specificationSubmission = 'Specification Submission', appeals = 'Appeals', appealsResponse = 'Appeals Response', approval = 'Approval', From 866683d6c89b287784a9a87e674b3dc7027c0289 Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Fri, 21 Oct 2022 00:15:41 +0530 Subject: [PATCH 5/8] Fix lint errors --- src-ts/lib/icon-wrapper/index.tsx | 2 +- .../work-provider/work-functions/work-factory/work.factory.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src-ts/lib/icon-wrapper/index.tsx b/src-ts/lib/icon-wrapper/index.tsx index b1036868e..6c97dd1d2 100644 --- a/src-ts/lib/icon-wrapper/index.tsx +++ b/src-ts/lib/icon-wrapper/index.tsx @@ -1,5 +1,5 @@ -import { FC } from 'react' import classNames from 'classnames' +import { FC } from 'react' import styles from './IconWrapper.module.scss' diff --git a/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts b/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts index 5922367c1..5eb4d4556 100644 --- a/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts +++ b/src-ts/tools/work/work-lib/work-provider/work-functions/work-factory/work.factory.ts @@ -551,7 +551,7 @@ function getProgress(challenge: Challenge, workStatus: WorkStatus): WorkProgress date: getProgressStepDateStart(challenge, [ ChallengePhaseName.specificationReview, ChallengePhaseName.specificationSubmission, - ChallengePhaseName.registration + ChallengePhaseName.registration, ]), name: 'Started', }, From d50324df089498551f840ec58f4b849f9ea1127d Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Fri, 21 Oct 2022 12:09:10 +0530 Subject: [PATCH 6/8] PROD-2644 #comment Fix unable to proceed to pay if user submits the contact support form --- src-ts/lib/form/form-functions/form.functions.ts | 5 +++-- src-ts/lib/form/form-input.model.ts | 1 + .../intake-forms/bug-hunt/bug-hunt.form.config.tsx | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src-ts/lib/form/form-functions/form.functions.ts b/src-ts/lib/form/form-functions/form.functions.ts index 1c4eaf1a3..5a9eceb2f 100644 --- a/src-ts/lib/form/form-functions/form.functions.ts +++ b/src-ts/lib/form/form-functions/form.functions.ts @@ -72,13 +72,14 @@ export async function onSubmitAsync( ): Promise { event.preventDefault() + event.stopPropagation(); const { groups, shortName, successMessage }: FormDefinition = formDef const inputs: Array = getFormInputFields(groups || []) // get the dirty fields before we validate b/c validation marks them dirty on submit const dirty: FormInputModel | undefined = inputs?.find(fieldDef => !!fieldDef.dirty) - + const pristine: FormInputModel | undefined = inputs?.find(fieldDef => !!fieldDef.pristine) // if there are any validation errors, display a message and stop submitting // NOTE: need to check this before we check if the form is dirty bc you // could have a form that's not dirty but has errors and you wouldn't @@ -98,7 +99,7 @@ export async function onSubmitAsync( }) // if there are no dirty fields, don't actually perform the save - const savePromise: Promise = !dirty ? Promise.resolve() : save(formValue) + const savePromise: Promise = !dirty && !pristine ? Promise.resolve() : save(formValue) return savePromise .then(() => { diff --git a/src-ts/lib/form/form-input.model.ts b/src-ts/lib/form/form-input.model.ts index 419d63cb7..2921b7cfc 100644 --- a/src-ts/lib/form/form-input.model.ts +++ b/src-ts/lib/form/form-input.model.ts @@ -28,6 +28,7 @@ export interface FormInputModel { dirty?: boolean disabled?: boolean error?: string + pristine?: boolean readonly events?: ReadonlyArray readonly fileConfig?: { readonly acceptFileType?: string diff --git a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx index dc97ccf6b..949230d02 100644 --- a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx +++ b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx @@ -41,6 +41,7 @@ export const BugHuntFormConfig: FormDefinition = { { hideInlineErrors: true, label: 'Project title', + pristine: true, name: ChallengeMetadataName.projectTitle, placeholder: 'Enter a descriptive title', type: 'text', From 64e63635bad3449384438808c41802099aa222ac Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Fri, 21 Oct 2022 19:22:17 +0530 Subject: [PATCH 7/8] Fix PR comments and fix lint errors --- src-ts/lib/form/form-functions/form.functions.ts | 2 +- src-ts/lib/form/form-input.model.ts | 2 +- .../icon-wrapper/IconWrapper.module.scss | 9 ++++----- .../icon-wrapper/IconWrapper.tsx} | 0 src-ts/lib/svgs/icon-wrapper/index.ts | 1 + src-ts/lib/svgs/index.ts | 1 + src-ts/tools/index.ts | 1 + .../intake-forms/bug-hunt/BugHuntIntakeForm.tsx | 4 ++-- .../bug-hunt/bug-hunt.form.config.tsx | 2 +- .../work/work-service-price/WorkServicePrice.tsx | 3 +-- .../WorkTableTitleRenderer.tsx | 15 +++++++-------- src-ts/tools/work/work.routes.tsx | 11 ++++++----- src/IntakeForm.jsx | 5 ++--- src/constants/products/BugHunt/index.js | 1 - 14 files changed, 28 insertions(+), 29 deletions(-) rename src-ts/lib/{ => svgs}/icon-wrapper/IconWrapper.module.scss (71%) rename src-ts/lib/{icon-wrapper/index.tsx => svgs/icon-wrapper/IconWrapper.tsx} (100%) create mode 100644 src-ts/lib/svgs/icon-wrapper/index.ts delete mode 100644 src/constants/products/BugHunt/index.js diff --git a/src-ts/lib/form/form-functions/form.functions.ts b/src-ts/lib/form/form-functions/form.functions.ts index 5a9eceb2f..4f52fad10 100644 --- a/src-ts/lib/form/form-functions/form.functions.ts +++ b/src-ts/lib/form/form-functions/form.functions.ts @@ -72,7 +72,7 @@ export async function onSubmitAsync( ): Promise { event.preventDefault() - event.stopPropagation(); + event.stopPropagation() const { groups, shortName, successMessage }: FormDefinition = formDef const inputs: Array = getFormInputFields(groups || []) diff --git a/src-ts/lib/form/form-input.model.ts b/src-ts/lib/form/form-input.model.ts index 2921b7cfc..ac8ee469d 100644 --- a/src-ts/lib/form/form-input.model.ts +++ b/src-ts/lib/form/form-input.model.ts @@ -28,7 +28,6 @@ export interface FormInputModel { dirty?: boolean disabled?: boolean error?: string - pristine?: boolean readonly events?: ReadonlyArray readonly fileConfig?: { readonly acceptFileType?: string @@ -44,6 +43,7 @@ export interface FormInputModel { readonly notTabbable?: boolean options?: ReadonlyArray readonly placeholder?: string + pristine?: boolean readonly spellCheck?: boolean readonly title?: string touched?: boolean diff --git a/src-ts/lib/icon-wrapper/IconWrapper.module.scss b/src-ts/lib/svgs/icon-wrapper/IconWrapper.module.scss similarity index 71% rename from src-ts/lib/icon-wrapper/IconWrapper.module.scss rename to src-ts/lib/svgs/icon-wrapper/IconWrapper.module.scss index e182ce53f..432d0158e 100644 --- a/src-ts/lib/icon-wrapper/IconWrapper.module.scss +++ b/src-ts/lib/svgs/icon-wrapper/IconWrapper.module.scss @@ -1,11 +1,11 @@ -@import '../styles/includes'; +@import '../../styles/includes'; .iconWrapper { - height: 48px; - width: 48px; + @include icon-mxx; + margin: 0 $space-lg $space-lg $space-lg; background: $tc-grad12; - border-radius: 24px; + border-radius: $space-xxl; display: flex; align-items: center; justify-content: center; @@ -15,4 +15,3 @@ color: $tc-white; } } - diff --git a/src-ts/lib/icon-wrapper/index.tsx b/src-ts/lib/svgs/icon-wrapper/IconWrapper.tsx similarity index 100% rename from src-ts/lib/icon-wrapper/index.tsx rename to src-ts/lib/svgs/icon-wrapper/IconWrapper.tsx diff --git a/src-ts/lib/svgs/icon-wrapper/index.ts b/src-ts/lib/svgs/icon-wrapper/index.ts new file mode 100644 index 000000000..768299dbd --- /dev/null +++ b/src-ts/lib/svgs/icon-wrapper/index.ts @@ -0,0 +1 @@ +export { default as IconWrapper } from './IconWrapper' diff --git a/src-ts/lib/svgs/index.ts b/src-ts/lib/svgs/index.ts index 55c230790..389ea834b 100644 --- a/src-ts/lib/svgs/index.ts +++ b/src-ts/lib/svgs/index.ts @@ -37,3 +37,4 @@ export { GitlabIcon, GithubIcon } +export * from './icon-wrapper' diff --git a/src-ts/tools/index.ts b/src-ts/tools/index.ts index c4c7be5c9..bf19d7574 100644 --- a/src-ts/tools/index.ts +++ b/src-ts/tools/index.ts @@ -28,4 +28,5 @@ export { WorkTypeCategoryUnknownIcon, WorkTypeConfigs, BugHuntIntakeForm, + bugHuntRoute } from './work' diff --git a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx index b10c5d6d6..500204dfa 100644 --- a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx +++ b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx @@ -29,7 +29,7 @@ import { } from '../../../work-lib' import { WorkServicePrice } from '../../../work-service-price' import { WorkTypeBanner } from '../../../work-type-banner' -import { dashboardRoute } from '../../../work.routes' +import { dashboardRoute, selfServiceStartRoute } from '../../../work.routes' import IntakeFormsBreadcrumb from '../intake-forms-breadcrumb/IntakeFormsBreadcrumb' import { BugHuntFormConfig } from './bug-hunt.form.config' @@ -52,7 +52,7 @@ const BugHuntIntakeForm: React.FC = () => { BugHuntFormConfig.buttons.primaryGroup[0].hidden = !isLoggedIn BugHuntFormConfig.buttons.primaryGroup[1].onClick = () => { setAction('submit') } if (BugHuntFormConfig.buttons.secondaryGroup) { - BugHuntFormConfig.buttons.secondaryGroup[0].onClick = () => { navigate('/self-service/wizard') } + BugHuntFormConfig.buttons.secondaryGroup[0].onClick = () => { navigate(selfServiceStartRoute) } } const [challenge, setChallenge]: [Challenge | undefined, Dispatch>] = useState() diff --git a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx index 949230d02..6ec081ee8 100644 --- a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx +++ b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx @@ -41,9 +41,9 @@ export const BugHuntFormConfig: FormDefinition = { { hideInlineErrors: true, label: 'Project title', - pristine: true, name: ChallengeMetadataName.projectTitle, placeholder: 'Enter a descriptive title', + pristine: true, type: 'text', validators: [ { diff --git a/src-ts/tools/work/work-service-price/WorkServicePrice.tsx b/src-ts/tools/work/work-service-price/WorkServicePrice.tsx index 0b6bfa3c1..51ff7fa5e 100644 --- a/src-ts/tools/work/work-service-price/WorkServicePrice.tsx +++ b/src-ts/tools/work/work-service-price/WorkServicePrice.tsx @@ -1,7 +1,6 @@ import { FC } from 'react' -import { IconOutline, textFormatMoneyLocaleString, Tooltip } from '../../../lib' -import IconWrapper from '../../../lib/icon-wrapper' +import { IconOutline, IconWrapper, textFormatMoneyLocaleString, Tooltip } from '../../../lib' import styles from './WorkServicePrice.module.scss' diff --git a/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx b/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx index 20c64a5e3..c04f027b9 100644 --- a/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx +++ b/src-ts/tools/work/work-table/work-table-title-renderer/WorkTableTitleRenderer.tsx @@ -1,11 +1,10 @@ -import { IconOutline } from '../../../../lib' -import IconWrapper from '../../../../lib/icon-wrapper' +import { IconOutline, IconWrapper } from '../../../../lib' import { - Work, - WorkTypeCategory, - WorkTypeCategoryDataIcon, - WorkTypeCategoryDesignIcon, - WorkTypeCategoryUnknownIcon, + Work, + WorkTypeCategory, + WorkTypeCategoryDataIcon, + WorkTypeCategoryDesignIcon, + WorkTypeCategoryUnknownIcon, } from '../../work-lib' import styles from './WorkTableTitleRenderer.module.scss' @@ -27,7 +26,7 @@ function WorkTableTitleRenderer(data: Work): JSX.Element { Icon = ( } + icon={} /> ) break diff --git a/src-ts/tools/work/work.routes.tsx b/src-ts/tools/work/work.routes.tsx index 8f2676974..83cd53e31 100644 --- a/src-ts/tools/work/work.routes.tsx +++ b/src-ts/tools/work/work.routes.tsx @@ -20,6 +20,7 @@ export const rootRoute: string = '/work' export const selfServiceRootRoute: string = '/self-service' export const selfServiceStartRoute: string = `${selfServiceRootRoute}/wizard` export const dashboardRoute: string = `${rootRoute}/dashboard` +export const bugHuntRoute: string = 'bug-hunt/' export function workDashboardRoute(active: string): string { return `${dashboardRoute}/${active}` @@ -82,23 +83,23 @@ export const workRoutes: Array = [ // Bug Hunt { element: , - route: `bug-hunt/basic-info`, + route: `${bugHuntRoute}basic-info`, }, { element: , - route: `bug-hunt/basic-info/:workId`, + route: `${bugHuntRoute}basic-info/:workId`, }, { element: , - route: `bug-hunt/review`, + route: `${bugHuntRoute}review`, }, { element: , - route: `bug-hunt/review/:workId`, + route: `${bugHuntRoute}review/:workId`, }, { element: , - route: `bug-hunt/login-prompt/:retUrl`, + route: `${bugHuntRoute}login-prompt/:retUrl`, }, // General { diff --git a/src/IntakeForm.jsx b/src/IntakeForm.jsx index 9978825ad..b0889c6dd 100644 --- a/src/IntakeForm.jsx +++ b/src/IntakeForm.jsx @@ -20,7 +20,6 @@ import { INTAKE_FORM_ROUTES as FIND_ME_DATA_INTAKE_FORM_ROUTES } from "./constan import { INTAKE_FORM_ROUTES as DATA_ADVISORY_INTAKE_FORM_ROUTES } from "./constants/products/DataAdvisory"; import { INTAKE_FORM_ROUTES as WEBSITE_DESIGN_INTAKE_FORM_ROUTES } from "./constants/products/WebsiteDesign"; import { INTAKE_FORM_ROUTES as WEBSITE_DESIGN_LEGACY_INTAKE_FORM_ROUTES } from "./constants/products/WebsiteDesignLegacy"; -import { BUG_HUNT_ROUTE } from "./constants/products/BugHunt"; import { getIntakeFormChallenges } from "./services/challenge"; import SelectWorkType from "./routes/SelectWorkType"; import DataExploration from "./routes/Products/DataExploration"; @@ -29,7 +28,7 @@ import WebsiteDesign from "./routes/Products/WebsiteDesign"; import DataAdvisory from "./routes/Products/DataAdvisory"; import WebsiteDesignLegacy from "./routes/Products/WebsiteDesignLegacy"; -import { profileContext, WorkType } from "../src-ts"; +import { profileContext, WorkType, bugHuntRoute } from "../src-ts"; export default function IntakeForm() { @@ -143,7 +142,7 @@ export default function IntakeForm() { }; const syncSavedData = (savedData) => { - const isBugHuntRoute = location.pathname.indexOf(BUG_HUNT_ROUTE) > -1 + const isBugHuntRoute = location.pathname.indexOf(`/${bugHuntRoute}`) > -1 if (!savedData || isBugHuntRoute) return; const { form, progress } = savedData; if (form) dispatch(saveForm(form)); diff --git a/src/constants/products/BugHunt/index.js b/src/constants/products/BugHunt/index.js deleted file mode 100644 index 09b172440..000000000 --- a/src/constants/products/BugHunt/index.js +++ /dev/null @@ -1 +0,0 @@ -export const BUG_HUNT_ROUTE = "/bug-hunt/"; \ No newline at end of file From c476a226fce8b8bd7a2d365d145aba80ebc8f659 Mon Sep 17 00:00:00 2001 From: Anwar Sadath Date: Fri, 21 Oct 2022 22:36:42 +0530 Subject: [PATCH 8/8] Remove the pristine field --- src-ts/lib/form/form-functions/form.functions.ts | 3 +-- src-ts/lib/form/form-input.model.ts | 1 - .../intake-forms/bug-hunt/bug-hunt.form.config.tsx | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src-ts/lib/form/form-functions/form.functions.ts b/src-ts/lib/form/form-functions/form.functions.ts index 4f52fad10..0d32fd6de 100644 --- a/src-ts/lib/form/form-functions/form.functions.ts +++ b/src-ts/lib/form/form-functions/form.functions.ts @@ -79,7 +79,6 @@ export async function onSubmitAsync( // get the dirty fields before we validate b/c validation marks them dirty on submit const dirty: FormInputModel | undefined = inputs?.find(fieldDef => !!fieldDef.dirty) - const pristine: FormInputModel | undefined = inputs?.find(fieldDef => !!fieldDef.pristine) // if there are any validation errors, display a message and stop submitting // NOTE: need to check this before we check if the form is dirty bc you // could have a form that's not dirty but has errors and you wouldn't @@ -99,7 +98,7 @@ export async function onSubmitAsync( }) // if there are no dirty fields, don't actually perform the save - const savePromise: Promise = !dirty && !pristine ? Promise.resolve() : save(formValue) + const savePromise: Promise = !dirty ? Promise.resolve() : save(formValue) return savePromise .then(() => { diff --git a/src-ts/lib/form/form-input.model.ts b/src-ts/lib/form/form-input.model.ts index ac8ee469d..419d63cb7 100644 --- a/src-ts/lib/form/form-input.model.ts +++ b/src-ts/lib/form/form-input.model.ts @@ -43,7 +43,6 @@ export interface FormInputModel { readonly notTabbable?: boolean options?: ReadonlyArray readonly placeholder?: string - pristine?: boolean readonly spellCheck?: boolean readonly title?: string touched?: boolean diff --git a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx index 6ec081ee8..dc97ccf6b 100644 --- a/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx +++ b/src-ts/tools/work/work-self-service/intake-forms/bug-hunt/bug-hunt.form.config.tsx @@ -43,7 +43,6 @@ export const BugHuntFormConfig: FormDefinition = { label: 'Project title', name: ChallengeMetadataName.projectTitle, placeholder: 'Enter a descriptive title', - pristine: true, type: 'text', validators: [ {