Skip to content

Commit d39dcf7

Browse files
Merge pull request #386 from topcoder-platform/PROD-1565_work-details
PROD-1565 work details -> qa
2 parents 79e2bcc + 56db810 commit d39dcf7

File tree

8 files changed

+22841
-101
lines changed

8 files changed

+22841
-101
lines changed

package-lock.json

+22,691-81
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@testing-library/jest-dom": "^5.5.0",
2828
"@testing-library/react": "^9.4.0",
2929
"@types/jest": "^25.2.3",
30+
"@types/lodash": "^4.14.182",
3031
"@types/node": "^17.0.24",
3132
"@types/reach__router": "^1.3.10",
3233
"@types/react": "^18.0.5",

src-ts/tools/work/work-detail-details/WorkDetailDetails.module.scss

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@
33
.wrap {
44
display: flex;
55
padding-bottom: 32px;
6-
}
7-
8-
.details-content {
9-
flex-grow: 2;
10-
}
6+
}

src-ts/tools/work/work-detail-details/WorkDetailDetails.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import { FC } from 'react'
22

3+
import { WorkDetailDetailsPane } from './work-detail-details-pane'
34
import { WorkDetailDetailsSidebar } from './work-detail-details-sidebar'
45
import styles from './WorkDetailDetails.module.scss'
56

67
interface WorkDetailDetailsProps {
7-
children: JSX.Element
8+
formData: {}
89
}
910

1011
const WorkDetailDetails: FC<WorkDetailDetailsProps> = (props: WorkDetailDetailsProps) => {
11-
1212
return (
1313
<div className={styles['wrap']}>
14-
<div className={styles['details-content']}>
15-
{props.children}
16-
</div>
14+
<WorkDetailDetailsPane formData={props.formData} />
1715
<WorkDetailDetailsSidebar />
1816
</div>
1917
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@import '../../../../lib/styles';
2+
3+
.paneContent {
4+
flex-grow: 2;
5+
}
6+
7+
.detail {
8+
margin-bottom: $pad-xxl;
9+
white-space: pre-wrap;
10+
@include font-black-100;
11+
12+
.header {
13+
@include font-barlow;
14+
display: flex;
15+
padding-bottom: $pad-sm;
16+
}
17+
18+
.content {
19+
@extend .body-main;
20+
21+
.detail {
22+
padding-left: $pad-xl;
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import _ from 'lodash'
2+
import { FC } from 'react'
3+
4+
import styles from './WorkDetailDetailsPane.module.scss'
5+
6+
interface WorkDetailDetailsPaneProps {
7+
formData: any
8+
}
9+
10+
const WorkDetailDetailsPane: FC<WorkDetailDetailsPaneProps> = ({ formData }: WorkDetailDetailsPaneProps) => {
11+
const sections: Array<string> = ['basicInfo', 'websitePurpose', 'pageDetails', 'branding']
12+
13+
return (
14+
<div className={styles['paneContent']}>
15+
{sections
16+
.filter((section) => {
17+
if (section === 'pageDetails') {
18+
return _.get(formData[section], 'pages[0].pageDetails') !== ''
19+
}
20+
return !!formData[section]
21+
})
22+
.map((section) => {
23+
return (
24+
<>
25+
{section === 'pageDetails'
26+
? renderPageDetails(formData, section)
27+
: renderDetails(formData, section)
28+
}
29+
</>
30+
)
31+
})}
32+
</div>
33+
)
34+
}
35+
36+
function renderPageDetails(formData: any, section: string): Array<JSX.Element> {
37+
const items: { pages: [] } = formData[section] || {}
38+
const pages: [] = items?.pages || []
39+
40+
return pages.map((page: { pageDetails?: string, pageName?: string }, index: number) => {
41+
return (
42+
<div>
43+
{page?.pageName && (
44+
<div className={styles['detail']}>
45+
<h4 className={styles['header']}>Page {index + 1} Name</h4>
46+
<p className={styles['content']}>{page?.pageName}</p>
47+
</div>
48+
)}
49+
{page?.pageDetails && (
50+
<div className={styles['detail']}>
51+
<h4 className={styles['header']}>Page {index + 1} Requirements</h4>
52+
<p className={styles['content']}>{page?.pageDetails}</p>
53+
</div>
54+
)}
55+
</div>
56+
)
57+
})
58+
}
59+
60+
function renderDetails(formData: any, section: string): Array<JSX.Element | Array<JSX.Element>> {
61+
let items: any = formData[section] || {}
62+
if (formData?.workType?.selectedWorkType === 'Find Me Data') {
63+
items = _.omit(items, ['projectTitle', 'assetsUrl', 'goals'])
64+
} else {
65+
items = _.omit(items, [
66+
'findMeProjectTitle',
67+
'analysis',
68+
'primaryDataChallenge',
69+
'primaryDataChallengeOther',
70+
'sampleData',
71+
])
72+
}
73+
return Object.keys(items).map((key) => {
74+
if (_.isArray(items[key])) {
75+
return _.map(items[key], (item, i) => (
76+
<div className={styles['detail']} key={i}>
77+
<h4 className={styles['header']}>
78+
{key} {i + 1}
79+
</h4>
80+
<p className={styles['content']}>
81+
{Object.keys(item).map((subKey) =>
82+
renderOption(item[subKey], subKey)
83+
)}
84+
</p>
85+
</div>
86+
))
87+
}
88+
return renderOption(items[key])
89+
})
90+
}
91+
92+
function renderOption(option: any, title: string = ''): JSX.Element {
93+
return (
94+
<>
95+
{option.option && (
96+
<div className={styles['detail']}>
97+
<h4 className={styles['header']}>{option.title || title}</h4>
98+
<p className={styles['content']}>{formatOption(option.option)}</p>
99+
</div>
100+
)}
101+
</>
102+
)
103+
}
104+
105+
function formatOption(option: Array<string> | {}): string {
106+
if (_.isArray(option)) {
107+
return option.join(', ')
108+
}
109+
if (_.isObject(option)) {
110+
return formatOption(_.get(option, 'option', option))
111+
}
112+
return option
113+
}
114+
115+
export default WorkDetailDetailsPane
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as WorkDetailDetailsPane } from './WorkDetailDetailsPane'

src/routes/WorkItems/index.jsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const WorkItem = ({
8181
return workUtil.isReviewPhaseEnded(work);
8282
}
8383
}, [work]);
84-
84+
8585
useEffect(() => {
8686
if (!work) {
8787
return;
@@ -123,7 +123,7 @@ const WorkItem = ({
123123
if (!work) {
124124
return;
125125
}
126-
126+
127127
if (work || selectedTab === "messaging") {
128128
getForumNotifications(work.id);
129129
}
@@ -133,7 +133,7 @@ const WorkItem = ({
133133
if (!work) {
134134
return;
135135
}
136-
136+
137137
if (isReviewPhaseEnded) {
138138
getSolutionsCount(work.id);
139139
}
@@ -242,13 +242,7 @@ const WorkItem = ({
242242

243243
{selectedTab === 'details' && (
244244
<div>
245-
<WorkDetailDetails>
246-
<ReviewTable
247-
formData={_.get(details, "intake-form.form", {})}
248-
enableEdit={false}
249-
enableStepsToggle={false}
250-
/>
251-
</WorkDetailDetails>
245+
<WorkDetailDetails formData={_.get(details, "intake-form.form", {})} />
252246
</div>
253247
)}
254248

0 commit comments

Comments
 (0)