Skip to content

Commit 1f81366

Browse files
Merge branch 'dev' into TCA-455_npm-modules-update
2 parents ab91913 + 0b2584f commit 1f81366

File tree

9 files changed

+67
-35
lines changed

9 files changed

+67
-35
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"start": "sh start-ssl.sh",
88
"start:brooke": "sudo sh start-ssl-brooke.sh",
99
"build": "yarn react-app-rewired build",
10-
"postbuild": "gzip build/static/js/*.js && gzip build/static/css/*.css",
1110
"lint": "tslint 'src-ts/**/*.{ts,tsx}' && eslint 'src*/**/*.{js,jsx,ts,tsx}'",
1211
"lint:fix": "tslint 'src-ts/**/*.{ts,tsx}' --fix && eslint 'src*/**/*.{js,jsx,ts,tsx}' --fix",
1312
"tslint": "tslint 'src-ts/**/*.{ts,tsx}'",

src-ts/lib/loading-spinner/LoadingSpinner.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121
&.show {
2222
opacity: 1;
2323
}
24+
&.overlay {
25+
position: fixed;
26+
background: $white-100-opacity-10;
27+
}
2428
}

src-ts/lib/loading-spinner/LoadingSpinner.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,25 @@ import { PuffLoader } from 'react-spinners'
99

1010
import styles from './LoadingSpinner.module.scss'
1111

12+
// This will determine whether we want to show the loading indicator on top of existing content or if its shown
13+
// without any content
14+
type LoadingSpinnerType = 'Overlay' | 'Normal'
15+
1216
export interface LoadingSpinnerProps {
1317
className?: string
1418
hide?: boolean
19+
type?: LoadingSpinnerType
1520
}
1621

17-
const LoadingSpinner: FC<LoadingSpinnerProps> = ({ hide, className }: LoadingSpinnerProps) => {
22+
const LoadingSpinner: FC<LoadingSpinnerProps> = ({ hide, className, type = 'Normal' }: LoadingSpinnerProps) => {
1823

1924
if (!!hide) {
2025
return <></>
2126
}
2227

28+
const isOverlay: boolean = type === 'Overlay'
2329
return (
24-
<div className={classNames(styles['loading-spinner'], styles.show, className)}>
30+
<div className={classNames(styles['loading-spinner'], styles.show, {[styles.overlay]: isOverlay}, className)}>
2531
<PuffLoader color={'#2196f3'} loading={true} size={100} />
2632
</div>
2733
)

src-ts/lib/payment-form/PaymentForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ const PaymentForm: React.FC<PaymentFormProps> = (props: PaymentFormProps) => {
202202
name='order-contract'
203203
tabIndex={1}
204204
type='checkbox'
205+
checked={props.formData.orderContract}
205206
onChange={(event) => props.onUpdateField('orderContract', event.target.checked)}
206207
/>
207208

src-ts/lib/styles/variables/_palette.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,5 @@ $tc-grad18: linear-gradient(84.92deg, #363D8C 2.08%, #723390 97.43%);
199199

200200

201201
/* OPACITY */
202-
$black-100-opacity-80: rgba(255, 255, 255, 0.8)
202+
$black-100-opacity-80: rgba(255, 255, 255, 0.8);
203+
$white-100-opacity-10: rgba(0, 0, 0, 0.1);

src-ts/tools/work/work-login-prompt/WorkLoginPrompt.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
import { FC, useContext } from 'react'
2-
import { Location, useLocation, useParams } from 'react-router-dom'
2+
import { Location, NavigateFunction, useLocation, useNavigate, useParams } from 'react-router-dom'
33

44
import {
55
authUrlLogin,
66
Button,
7+
PageDivider,
78
routeContext,
89
RouteContextData,
910
} from '../../../lib'
11+
import { BackArrowIcon } from '../../../lib/svgs'
1012

1113
import styles from './WorkLoginPrompt.module.scss'
1214

13-
const WorkLoginPrompt: FC = () => {
15+
interface WorkLoginPromptProps {
16+
previousPageUrl: string
17+
}
18+
19+
const WorkLoginPrompt: FC<WorkLoginPromptProps> = ({ previousPageUrl }: WorkLoginPromptProps) => {
1420

1521
const routeData: RouteContextData = useContext(routeContext)
1622
const location: Location = useLocation()
23+
const navigate: NavigateFunction = useNavigate()
1724
const customReturnUrl: string | undefined = useParams().retUrl
1825

1926
function signUp(): void {
2027
const signUpUrl: string = routeData.getSignupUrl(location.pathname, routeData.toolsRoutes, customReturnUrl)
2128
window.location.href = signUpUrl
2229
}
2330

31+
const onBack: () => void = () => {
32+
navigate(
33+
previousPageUrl
34+
)
35+
}
36+
2437
return (
2538
<>
2639
<div className={styles.container}>
@@ -46,6 +59,17 @@ const WorkLoginPrompt: FC = () => {
4659
</div>
4760
</div>
4861
</div>
62+
<PageDivider />
63+
<div className={styles['footerContent']}>
64+
<div>
65+
<Button
66+
size='md'
67+
icon={BackArrowIcon}
68+
buttonStyle='secondary'
69+
onClick={onBack}
70+
/>
71+
</div>
72+
</div>
4973
</>
5074
)
5175
}

src-ts/tools/work/work-self-service/intake-forms/bug-hunt/BugHuntIntakeForm.tsx

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import {
55
Form,
66
FormAction,
77
FormDefinition,
8-
formGetInputFields,
98
formGetInputModel,
10-
FormGroup,
119
FormInputModel,
12-
formOnReset,
1310
IconOutline,
1411
InfoCard,
1512
LoadingSpinner,
@@ -48,6 +45,8 @@ const BugHuntIntakeForm: React.FC = () => {
4845
const { isLoggedIn }: ProfileContextData = useContext<ProfileContextData>(profileContext)
4946

5047
const [action, setAction]: [FormAction, Dispatch<SetStateAction<FormAction>>] = useState()
48+
const [loading, setLoading]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
49+
const [saveSuccess, setSaveSuccess]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
5150

5251
BugHuntFormConfig.buttons.primaryGroup[0].onClick = () => { setAction('save') }
5352
BugHuntFormConfig.buttons.primaryGroup[0].hidden = !isLoggedIn
@@ -68,17 +67,6 @@ const BugHuntIntakeForm: React.FC = () => {
6867
const [selectedPackage, setSelectedPackage]: [PricePackageName, Dispatch<SetStateAction<PricePackageName>>]
6968
= useState<PricePackageName>(formValues?.packageType)
7069

71-
const formInputs: Array<FormInputModel> = formGetInputFields(formDef.groups as Array<FormGroup>)
72-
73-
useEffect(() => {
74-
if (!workId && !challenge) {
75-
formOnReset(formInputs, formValues)
76-
}
77-
// Disabling lint rule as we only want this to run one time when component mounts, otherwise it resets
78-
// the form for a user that is not logged in and has no challenge created yet
79-
// eslint-disable-next-line react-hooks/exhaustive-deps
80-
}, [])
81-
8270
useEffect(() => {
8371

8472
async function getAndSetWork(): Promise<void> {
@@ -113,13 +101,20 @@ const BugHuntIntakeForm: React.FC = () => {
113101
}
114102
}
115103

116-
getAndSetWork()
104+
setLoading(true)
105+
getAndSetWork().finally(() => setLoading(false))
117106
}, [
118107
isLoggedIn,
119108
selectedPackage,
120109
workId,
121110
])
122111

112+
useEffect(() => {
113+
if (!loading && saveSuccess) {
114+
handleSaveSuccess()
115+
}
116+
}, [loading, saveSuccess])
117+
123118
const requestGenerator: (inputs: ReadonlyArray<FormInputModel>) => void = (inputs) => {
124119
const projectTitle: string = formGetInputModel(inputs, ChallengeMetadataName.projectTitle).value as string
125120
const featuresToTest: string = formGetInputModel(inputs, ChallengeMetadataName.featuresToTest).value as string
@@ -161,16 +156,21 @@ const BugHuntIntakeForm: React.FC = () => {
161156
val.currentStep = 'review'
162157
}
163158

164-
return workUpdateAsync(WorkType.bugHunt, challenge, val)
159+
setLoading(true)
160+
return workUpdateAsync(WorkType.bugHunt, challenge, val).finally(() => setLoading(false))
161+
}
162+
163+
const handleSaveSuccess: () => void = () => {
164+
if (action === 'save') {
165+
navigate(`${dashboardRoute}/draft`)
166+
} else if (action === 'submit') {
167+
const nextUrl: string = `${WorkIntakeFormRoutes[WorkType.bugHunt]['review']}/${workId || challenge?.id}`
168+
navigate(nextUrl)
169+
}
165170
}
166171

167172
const onSaveSuccess: () => void = () => {
168-
if (action === 'save') {
169-
navigate(`${dashboardRoute}/draft`)
170-
} else if (action === 'submit') {
171-
const nextUrl: string = `${WorkIntakeFormRoutes[WorkType.bugHunt]['review']}/${workId || challenge?.id}`
172-
navigate(nextUrl)
173-
}
173+
setSaveSuccess(true)
174174
}
175175

176176
const goToLoginStep: (formData: any) => void = (formData: any) => {
@@ -183,12 +183,9 @@ const BugHuntIntakeForm: React.FC = () => {
183183
navigate(loginPromptUrl)
184184
}
185185

186-
if (!challenge && workId) {
187-
return <LoadingSpinner />
188-
}
189-
190186
return (
191187
<>
188+
<LoadingSpinner hide={!loading} type='Overlay' />
192189
<IntakeFormsBreadcrumb
193190
basicInfoRoute={WorkIntakeFormRoutes[WorkType.bugHunt]['basicInfo']}
194191
workType={workBugHuntConfig.type}

src-ts/tools/work/work-self-service/intake-forms/review/Review.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const Review: FC = () => {
193193

194194
return (
195195
<div className={styles['review-container']}>
196-
<LoadingSpinner hide={!isLoading} />
196+
<LoadingSpinner hide={!isLoading} type='Overlay' />
197197
{/* TODO: We need to not hard code the configs to that of BugHunt and instead
198198
use the challenge data to determine the WorkType */}
199199
<IntakeFormsBreadcrumb

src-ts/tools/work/work.routes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Navigate } from 'react-router-dom'
33
import { contactSupportPath, PlatformRoute } from '../../lib'
44

55
import { dashboardTitle, default as WorkComponent, toolTitle } from './Work'
6-
import { Work, WorkIntakeFormRoutes, WorkStatus } from './work-lib'
6+
import { Work, WorkIntakeFormRoutes, WorkStatus, WorkType } from './work-lib'
77
import { WorkLoginPrompt } from './work-login-prompt'
88
import { WorkNotLoggedIn } from './work-not-logged-in'
99
import {
@@ -97,7 +97,7 @@ export const workRoutes: Array<PlatformRoute> = [
9797
route: `bug-hunt/review/:workId`,
9898
},
9999
{
100-
element: <WorkLoginPrompt />,
100+
element: <WorkLoginPrompt previousPageUrl={WorkIntakeFormRoutes[WorkType.bugHunt]['basicInfo']} />,
101101
route: `bug-hunt/login-prompt/:retUrl`,
102102
},
103103
// General

0 commit comments

Comments
 (0)