Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 0cbe16e

Browse files
committed
feat: Update Team Details Labels & add additional options under "Advanced"
Resolves: #365
1 parent 2270993 commit 0cbe16e

File tree

7 files changed

+81
-31
lines changed

7 files changed

+81
-31
lines changed

package-lock.json

+25-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"redux-logger": "^3.0.6",
8888
"redux-promise-middleware": "^6.1.2",
8989
"redux-thunk": "^2.3.0",
90-
"tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.4"
90+
"tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.4",
91+
"uuid": "^8.3.2"
9192
},
9293
"browserslist": [
9394
"last 1 version",

src/routes/CreateNewTeam/components/SubmitContainer/index.jsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import TeamDetailsModal from "../TeamDetailsModal";
2323
import ConfirmationModal from "../ConfirmationModal";
2424
import withAuthentication from "../../../../hoc/withAuthentication";
2525
import "./styles.module.scss";
26-
import { isCustomRole, setCurrentStage } from "utils/helpers";
26+
import { isCustomRole, isUuid, setCurrentStage } from "utils/helpers";
2727
import { clearSearchedRoles } from "../../actions";
2828
import { postTeamRequest } from "services/teams";
2929
import NoMatchingProfilesResultCard from "../NoMatchingProfilesResultCard";
@@ -65,11 +65,15 @@ function SubmitContainer({
6565
};
6666

6767
const assembleTeam = (formData) => {
68-
const teamObject = _.pick(formData, ["teamName", "teamDescription"]);
68+
const teamObject = _.pick(formData, [
69+
"teamName",
70+
"teamDescription",
71+
"refCode",
72+
]);
6973

7074
const positions = [];
7175
for (let key of Object.keys(formData)) {
72-
if (key === "teamName" || key === "teamDescription") {
76+
if (!isUuid(key)) {
7377
continue;
7478
}
7579
const position = _.mapValues(formData[key], (val, key) =>

src/routes/CreateNewTeam/components/TeamDetailsModal/index.jsx

+34-21
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import FormField from "components/FormField";
1111
import BaseCreateModal from "../BaseCreateModal";
1212
import { FORM_FIELD_TYPE } from "constants/";
1313
import { formatPlural } from "utils/format";
14+
import { isUuid } from "utils/helpers";
1415
import Button from "components/Button";
1516
import MonthPicker from "components/MonthPicker";
1617
import InformationTooltip from "components/InformationTooltip";
@@ -28,7 +29,7 @@ const Error = ({ name }) => {
2829
};
2930

3031
function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
31-
const [showDescription, setShowDescription] = useState(false);
32+
const [showAdvanced, setShowAdvanced] = useState(false);
3233
const [startMonthVisible, setStartMonthVisible] = useState({});
3334

3435
// Ensure role is removed from form state when it is removed from redux store
@@ -37,7 +38,7 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
3738
useEffect(() => {
3839
const values = getFormState().values;
3940
for (let fieldName of Object.keys(values)) {
40-
if (fieldName === "teamName" || fieldName === "teamDescription") {
41+
if (!isUuid(fieldName)) {
4142
continue;
4243
}
4344
if (addedRoles.findIndex((role) => role.searchId === fieldName) === -1) {
@@ -49,8 +50,8 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
4950

5051
const dispatch = useDispatch();
5152

52-
const toggleDescription = () => {
53-
setShowDescription((prevState) => !prevState);
53+
const toggleAdvanced = () => {
54+
setShowAdvanced((prevState) => !prevState);
5455
};
5556

5657
return (
@@ -78,7 +79,7 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
7879
open={open}
7980
onClose={onClose}
8081
title="Team Details"
81-
subtitle="Please provide your team details before submitting a request."
82+
subtitle="Please provide a name for your Team. This could be the name of the project they will work on, the name of the team they are joining, or whatever else will make this talent request meaningful for you."
8283
buttons={
8384
<Button
8485
type="primary"
@@ -102,26 +103,38 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
102103
customValidator: true,
103104
}}
104105
/>
105-
{showDescription && (
106-
<FormField
107-
field={{
108-
type: FORM_FIELD_TYPE.TEXTAREA,
109-
name: "teamDescription",
110-
label: "Short description about the team/ project",
111-
placeholder: "Short description about the team/ project",
112-
maxLength: 600,
113-
}}
114-
/>
106+
{showAdvanced && (
107+
<>
108+
<FormField
109+
field={{
110+
type: FORM_FIELD_TYPE.TEXTAREA,
111+
name: "teamDescription",
112+
label: "Short description about the team/ project",
113+
placeholder: "Short description about the team/ project",
114+
maxLength: 600,
115+
}}
116+
/>
117+
<FormField
118+
field={{
119+
type: FORM_FIELD_TYPE.TEXT,
120+
name: "refCode",
121+
label: "Ref Code",
122+
placeholder: "Ref Code",
123+
maxLength: 255,
124+
}}
125+
/>
126+
</>
115127
)}
116128
<button
117-
styleName="toggle-button toggle-description"
129+
styleName="toggle-button toggle-advanced"
118130
onClick={() => {
119131
clearField("teamDescription");
120-
toggleDescription();
132+
clearField("refCode");
133+
toggleAdvanced();
121134
}}
122135
>
123-
<span>{showDescription ? "–" : "+"}</span>
124-
{showDescription ? " Remove Description" : " Add Description"}
136+
<span>{showAdvanced ? "– " : "+ "}</span>
137+
Advanced Options
125138
</button>
126139
<table styleName="table">
127140
<tr>
@@ -147,7 +160,7 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
147160
<Field
148161
validate={validateExists}
149162
name={`${id}.numberOfResources`}
150-
initialValue={numberOfResources}
163+
initialValue={numberOfResources || 1}
151164
>
152165
{({ input, meta }) => (
153166
<NumberInput
@@ -167,7 +180,7 @@ function TeamDetailsModal({ open, onClose, submitForm, addedRoles }) {
167180
<Field
168181
validate={validateExists}
169182
name={`${id}.durationWeeks`}
170-
initialValue={durationWeeks}
183+
initialValue={durationWeeks || 4}
171184
>
172185
{({ input, meta }) => (
173186
<NumberInput

src/routes/CreateNewTeam/components/TeamDetailsModal/styles.module.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
color: #137D60;
1111
padding: 1px 6px 0 6px;
1212

13-
&.toggle-description {
13+
&.toggle-advanced {
1414
margin-top: 12px;
1515
> span {
1616
font-size: 18px;

src/routes/CreateNewTeam/components/TeamDetailsModal/utils/validator.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { isUuid } from "utils/helpers";
2+
13
const validateName = (name) => {
24
if (!name || name.trim().length === 0) {
35
return "Please enter a team name.";
@@ -58,7 +60,7 @@ const validator = (values) => {
5860
errors.teamName = validateName(values.teamName);
5961

6062
for (const key of Object.keys(values)) {
61-
if (key === "teamDescription" || key === "teamName") continue;
63+
if (!isUuid(key)) continue;
6264
errors[key] = validateRole(values[key]);
6365
}
6466

src/utils/helpers.js

+9
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@
55
* If there are multiple methods which could be grouped into a separate file by their meaning they should be extracted from here to not make this file too big.
66
*/
77
import _ from "lodash";
8+
import { validate } from "uuid";
9+
810
import { CUSTOM_ROLE_NAMES } from "constants/";
911

12+
/**
13+
* @param {String} string a possible uuid
14+
*
15+
* @returns {Boolean} true if uuid, false if not
16+
*/
17+
export const isUuid = validate;
18+
1019
/**
1120
* Delay code for some milliseconds using promise.
1221
*

0 commit comments

Comments
 (0)