Skip to content

BH Config & Carousel -> PROD-2321 #123

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

Merged
merged 11 commits into from
Jul 8, 2022
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-ts/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export {
WorkTypeCategoryDataIcon,
WorkTypeCategoryDesignIcon,
WorkTypeCategoryUnknownIcon,
WorkTypeConfigs,
} from './work'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Challenge, Work, WorkStatus } from './work-functions'
import { Challenge, Work, WorkPricesType, WorkStatus } from './work-functions'

export interface WorkContextData {
createFromChallenge: (challenge: Challenge) => Work
createFromChallenge: (challenge: Challenge, workPrices: WorkPricesType) => Work
deleteWorkAsync: (id: string) => Promise<void>
error?: string
getStatusFromChallenge: (challenge: Challenge) => WorkStatus
Expand Down
14 changes: 9 additions & 5 deletions src-ts/tools/work/work-lib/work-provider/work-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ export {
workFactoryCreate,
workFactoryGetStatus,
workFactoryMapFormData,
workPriceData,
workPriceDesign,
workPriceDesignLegacy,
workPriceFindData,
workPriceProblem,
type WorkProgress,
type WorkProgressStep,
type WorkSolution,
Expand All @@ -18,8 +13,17 @@ export {
export {
type Challenge,
ChallengeMetadataName,
workBugHuntConfig,
workPriceData,
workPriceDesign,
workPriceDesignLegacy,
workPriceFindData,
workPriceProblem,
WorkPrices,
WorkStatusFilter,
WorkTypeConfigs,
} from './work-store'
export type { WorkPricesType } from './work-store'
export * from './work-by-status.model'
export {
deleteAsync as workDeleteAsync,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
export {
data as workPriceData,
design as workPriceDesign,
designLegacy as workPriceDesignLegacy,
findData as workPriceFindData,
problem as workPriceProblem,
} from './work-prices.config'
export * from './work-progress.model'
export * from './work-progress-step.model'
export * from './work-status.enum'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum WorkType {
bugHunt = 'Website Bug Hunt',
data = 'Data Exploration',
design = 'Website Design',
designLegacy = 'Website Design Legacy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
ChallengeMetadataName,
ChallengePhase,
ChallengePhaseName,
WorkPrice,
WorkPricesType,
} from '../work-store'

import { ChallengeStatus } from './challenge-status.enum'
import { WorkPrice } from './work-price.model'
import { WorkPrices } from './work-prices.config'
import { WorkProgressStep } from './work-progress-step.model'
import { WorkProgress } from './work-progress.model'
import { WorkStatus } from './work-status.enum'
Expand Down Expand Up @@ -38,14 +38,15 @@ interface IntakeForm {
}
}

export function create(challenge: Challenge): Work {
export function create(challenge: Challenge, workPrices: WorkPricesType): Work {

const status: WorkStatus = getStatus(challenge)
const submittedDate: Date | undefined = getSubmittedDate(challenge)
const type: WorkType = getType(challenge)
const priceConfig: WorkPrice = workPrices[type]

return {
cost: getCost(challenge, type),
cost: getCost(challenge, priceConfig, type),
created: submittedDate,
description: getDescription(challenge, type),
id: challenge.id,
Expand Down Expand Up @@ -254,15 +255,8 @@ function findPhase(challenge: Challenge, phases: Array<string>): ChallengePhase
return phase
}

// the switch statement shouldn't count against cyclomatic complexity
// tslint:disable-next-line: cyclomatic-complexity
function getCost(challenge: Challenge, type: WorkType): number | undefined {
function getCost(challenge: Challenge, priceConfig: WorkPrice, type: WorkType): number | undefined {

function getCountFromString(raw: string | undefined): number {
return Number(raw?.split(' ')?.[0] || '0')
}

const priceConfig: WorkPrice = WorkPrices[type]
switch (type) {

case WorkType.designLegacy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,25 @@ export * from './challenge-metadata.model'
export * from './challenge-phase'
export * from './challenge-phase-name.enum'
export * from './challenge.model'
export * from './work-price.model'
export {
bugHunt as workPriceBugHunt,
data as workPriceData,
design as workPriceDesign,
designLegacy as workPriceDesignLegacy,
findData as workPriceFindData,
problem as workPriceProblem,
WorkPrices
} from './work-prices.config'
export type { WorkPricesType } from './work-prices.config'
export * from './work-status-filter.enum'
export {
deleteAsync as workStoreDeleteAsync,
getAsync as workStoreGetAsync,
getFilteredByStatus as workStoreGetFilteredByStatus,
} from './work-store.functions'
export {
bugHuntConfig as workBugHuntConfig,
WorkTypeConfigs
} from './work-type.config'
export * from './work-type.model'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { WorkType } from '../work-factory'

export const WorkIntakeFormRoutes: { [workType: string]: ReadonlyArray<string> } = {
// TODO: determine URL for Bug Hunt and if the following "/self-service" routes
// can be deleted. Not sure if they correspond to the currentStep
[WorkType.bugHunt]: [
'/self-service/wizard',
'/self-service/work/new/bug-hunt/basic-info',
'/self-service',
'/self-service',
'/self-service/work/new/bug-hunt/login-prompt',
'/self-service',
'/self-service/work/new/bug-hunt/review',
'/self-service/work/new/bug-hunt/thank-you',
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export interface WorkPrice {
base: number,
getPrice: (price: WorkPrice, pageCount?: number, deviceCount?: number) => number,
payments?: {
base?: {
prizes: ReadonlyArray<number>,
reviewers: ReadonlyArray<number>,
},
promo?: {
prizes: ReadonlyArray<number>,
reviewers: ReadonlyArray<number>,
},
},
perPage?: number,
promo?: number,
usePromo?: boolean,
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import { WorkType } from '../work-factory'

import { WorkPrice } from './work-price.model'
import { WorkType } from './work-type.enum'

export const WorkPrices: { [workType: string]: WorkPrice } = {
// TODO: modify payments specific to bug hunt
[WorkType.bugHunt]: {
base: 2,
getPrice: getPriceDefault,
payments: {
base: {
prizes: [0.2609, 0.2174, 0.1304],
reviewers: [0.0435, 0.0435],
},
promo: {
prizes: [0.348, 0.29, 0.174],
reviewers: [0.058, 0.058],
},
},
promo: 1,
usePromo: true,
},
[WorkType.data]: {
base: 799,
getPrice: getPriceDefault,
Expand Down Expand Up @@ -41,6 +59,9 @@ export const WorkPrices: { [workType: string]: WorkPrice } = {
},
}

export type WorkPricesType = typeof WorkPrices

export const bugHunt: WorkPrice = WorkPrices[WorkType.bugHunt]
export const data: WorkPrice = WorkPrices[WorkType.data]
export const design: WorkPrice = WorkPrices[WorkType.design]
export const designLegacy: WorkPrice = WorkPrices[WorkType.designLegacy]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface WorkTimeline {
duration: number,
phaseId: string,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { WorkType } from '../work-factory'

import { WorkTimeline } from './work-timeline.model'

export const WorkTimelines: { [workType: string]: ReadonlyArray<WorkTimeline> } = {
// TODO: Determine actual timeline for Bug Hunt
[WorkType.bugHunt]: [
{
// Registration
duration: 259200, // 3 days
phaseId: 'a93544bc-c165-4af4-b55e-18f3593b457a',
},
{
// Submission
duration: 259200, // 3 days
phaseId: '6950164f-3c5e-4bdc-abc8-22aaf5a1bd49',
},
{
// Review
duration: 86400, // 1 day
phaseId: 'aa5a3f78-79e0-4bf7-93ff-b11e8f5b398b',
},
{
// Appeals
duration: 86400, // 1 day
phaseId: '1c24cfb3-5b0a-4dbd-b6bd-4b0dff5349c6',
},
{
// Appeals response
duration: 259200, // 3 days
phaseId: '797a6af7-cd3f-4436-9fca-9679f773bee9',
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import imgBugHunt from '../../../work-images/bug-hunt-main.jpeg'
import { WorkType } from '../work-factory'

import { WorkIntakeFormRoutes } from './work-intake-form-routes.config'
import { bugHunt as workPriceBugHunt } from './work-prices.config'
import { WorkTimelines } from './work-timelines.config'
import { WorkTypeConfig } from './work-type.model'

export const WorkTypeConfigs: { [workType: string]: WorkTypeConfig } = {
// TODO: Verify timelineTemplateId, trackId, typeId
[WorkType.bugHunt]: {
about: `Our Website Bug Hunt services remove the burden of testing from you and your teams and provide detailed results quickly.
Topcoder has conducted hundreds bug hunts for customers like you. For each bug hunt, we average between 25 and 150 bug hunters,
and we typically find a significant number bugs which helps improve quality of your site. The Bug Hunt will start with a
registration period, where experienced quality assurance engineers signup to register for the bug hunt. After the registration
period completes, we will run the bug hunt for the time which meets the option you choose below.`,
bgImage: imgBugHunt,
description: 'This is Bug Hunt description',
// TODO: The duration will be based on the package the user selects
duration: 2,
featured: true,
intakeFormRoutes: WorkIntakeFormRoutes[WorkType.bugHunt],
results: `You will receive thorough testing of your website, and at the conclusion will be provided
a detailed report of bugs which have steps to reproduce, screenshots / videos if applicable,
details of the bug, and severity of the issue.`,
shortDescription: 'Find bugs quickly and vigorously',
startRoute: WorkIntakeFormRoutes[WorkType.bugHunt][1],
subtitle: `Conduct a time based testing bug hunt where Topcoder experts scramble to find bugs or issues in the system`,
timeline: WorkTimelines[WorkType.bugHunt],
timelineTemplateId: '7ebf1c69-f62f-4d3a-bdfb-fe9ddb56861c', // Default Challenge
title: WorkType.bugHunt,
trackId: '36e6a8d0-7e1e-4608-a673-64279d99c115', // QA
type: WorkType.bugHunt,
typeId: '927abff4-7af9-4145-8ba1-577c16e64e2e', // Challenge
...workPriceBugHunt,
// TODO: do we need to include breadcrumbs here?
},
}

export const bugHuntConfig: WorkTypeConfig = WorkTypeConfigs[WorkType.bugHunt]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { WorkType } from '../work-factory'

import { WorkPrice } from './work-price.model'
import { WorkTimeline } from './work-timeline.model'

export interface WorkTypeConfig extends WorkPrice {
about: string,
bgImage: string,
description: string,
duration: number,
featured: boolean,
intakeFormRoutes: ReadonlyArray<string>
results: string,
shortDescription: string,
startRoute: string,
subtitle: string,
timeline: ReadonlyArray<WorkTimeline>
timelineTemplateId: string,
title: string,
trackId: string,
type: WorkType,
typeId: string,
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Page } from '../../../../../lib'

import { WorkByStatus } from './work-by-status.model'
import { Work, workFactoryCreate, WorkStatus, WorkType } from './work-factory'
import { Challenge, WorkStatusFilter, workStoreDeleteAsync, workStoreGetAsync, workStoreGetFilteredByStatus } from './work-store'
import { Challenge, WorkPrices, WorkStatusFilter, workStoreDeleteAsync, workStoreGetAsync, workStoreGetFilteredByStatus } from './work-store'

export async function deleteAsync(workId: string): Promise<void> {
return workStoreDeleteAsync(workId)
Expand All @@ -16,7 +16,7 @@ export async function getAsync(handle: string, page: Page): Promise<Array<Work>>

// run it through the factory and filter out deleted and non-self-service
const workItems: Array<Work> = challenges
.map(challenge => workFactoryCreate(challenge))
.map(challenge => workFactoryCreate(challenge, WorkPrices))
.filter(work => work.status !== WorkStatus.deleted && work.type !== WorkType.unknown)

return workItems
Expand Down
4 changes: 2 additions & 2 deletions src/routes/SelectWorkType/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import PageContent from "../../components/PageContent";
import PageDivider from "../../components/PageDivider";
import PageH2 from "../../components/PageElements/PageH2";
import Slider from "../../components/Slider";
import { Breadcrumb, ContactSupportModal } from "../../../src-ts";
import { Breadcrumb, ContactSupportModal, WorkTypeConfigs } from "../../../src-ts";
import {
BUTTON_SIZE,
projectAndProfessionalWork,
Expand Down Expand Up @@ -127,7 +127,7 @@ const SelectWorkType = ({
const challenge = useSelector((state) => state.challenge);
const navigate = useNavigate()

const allWorkTypes = [...workTypes, ...webWorkTypes];
const allWorkTypes = [...workTypes, ...webWorkTypes, ...Object.values(WorkTypeConfigs)];
const featuredWorkTypes = allWorkTypes.filter((wt) => wt.featured);

useEffect(() => {
Expand Down
Loading