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

Commit 94e697f

Browse files
authored
Merge pull request #346 from topcoder-platform/roles-finalfix
Roles finalfix challenge
2 parents 21a5dd5 + cef072d commit 94e697f

File tree

29 files changed

+428
-209
lines changed

29 files changed

+428
-209
lines changed

src/components/MonthPicker/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function getCurrMonthYear() {
1515
return new Date(`${year}-${month + 1}`);
1616
}
1717

18-
function MonthPicker({ name, value, onChange, onBlur }) {
18+
function MonthPicker({ name, value, onChange, onBlur, onFocus }) {
1919
return (
2020
<div styleName="month-picker">
2121
<DatePicker
@@ -26,6 +26,7 @@ function MonthPicker({ name, value, onChange, onBlur }) {
2626
showMonthYearPicker
2727
showPopperArrow={false}
2828
onBlur={onBlur}
29+
onFocus={onFocus}
2930
popperPlacement="top-end"
3031
showFourColumnMonthYearPicker
3132
minDate={getCurrMonthYear()}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Number Input
3+
* A custom number input to be used in forms
4+
* Removed default buttons and adds custom buttons
5+
*/
6+
import React from "react";
7+
import PT from "prop-types";
8+
import cn from "classnames";
9+
import "./styles.module.scss";
10+
11+
function NumberInput({ name, value, onChange, onBlur, onFocus, min, error }) {
12+
const incrementVal = (step) => {
13+
const newVal = +value + step;
14+
if (typeof newVal === "number" && !isNaN(newVal)) {
15+
onChange(newVal);
16+
}
17+
};
18+
const decrementVal = (step) => {
19+
const newVal = value - step;
20+
if (newVal >= min) {
21+
onChange(value - step);
22+
}
23+
};
24+
25+
return (
26+
<div styleName="container">
27+
<button styleName="left-button" onClick={() => decrementVal(1)}>
28+
29+
</button>
30+
<input
31+
styleName={cn("input", { error: error })}
32+
type="number"
33+
name={name}
34+
value={value}
35+
onChange={onChange}
36+
onBlur={onBlur}
37+
onFocus={onFocus}
38+
/>
39+
<button styleName="right-button" onClick={() => incrementVal(1)}>
40+
+
41+
</button>
42+
</div>
43+
);
44+
}
45+
46+
NumberInput.propTypes = {
47+
name: PT.string,
48+
value: PT.string,
49+
onChange: PT.func,
50+
onFocus: PT.func,
51+
onBlur: PT.func,
52+
min: PT.string,
53+
error: PT.bool,
54+
};
55+
56+
export default NumberInput;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@import "styles/include";
2+
3+
// remove default buttons and style input as text input
4+
.input {
5+
appearance: textfield;
6+
text-align: center;
7+
8+
&.error {
9+
border-color: #fe665d;
10+
}
11+
}
12+
.input::-webkit-inner-spin-button,
13+
.input::-webkit-outer-spin-button {
14+
appearance: none;
15+
margin: 0;
16+
}
17+
18+
.container {
19+
position: relative;
20+
width: fit-content;
21+
}
22+
23+
.left-button,
24+
.right-button {
25+
@include font-roboto;
26+
font-size: 22px;
27+
color: #137D60;
28+
outline: none;
29+
border: none;
30+
background: none;
31+
position: absolute;
32+
top: 0;
33+
height: 100%;
34+
padding: 0 11px;
35+
}
36+
37+
.left-button {
38+
left: 0;
39+
}
40+
41+
.right-button {
42+
right: 0;
43+
}

src/constants/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export const ACTION_TYPE = {
257257
CLEAR_SEARCHED_ROLES: "CLEAR_SEARCHED_ROLES",
258258
ADD_SEARCHED_ROLE: "ADD_SEARCHED_ROLE",
259259
ADD_ROLE_SEARCH_ID: "ADD_ROLE_SEARCH_ID",
260-
REPLACE_SEARCHED_ROLES: "REPLACE_SEARCHED_ROLES",
260+
DELETE_SEARCHED_ROLE: "DELETE_SEARCHED_ROLE",
261261
};
262262

263263
/**

src/root.component.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function Root() {
2525
<Router>
2626
<Redirect from="/taas" to="/taas/myteams" exact />
2727
<MyTeamsList path="/taas/myteams" />
28-
<CreateNewTeam path="/taas/myteams/createnewteam" />
28+
<CreateNewTeam path="/taas/createnewteam" />
2929
<MyTeamsDetails path="/taas/myteams/:teamId" />
3030
<JobDetails path="/taas/myteams/:teamId/positions/:jobId" />
3131
<JobForm path="/taas/myteams/:teamId/positions/:jobId/edit" />
@@ -34,9 +34,9 @@ export default function Root() {
3434
<ResourceBookingForm path="/taas/myteams/:teamId/rb/:resourceBookingId/edit" />
3535
<PositionDetails path="/taas/myteams/:teamId/positions/:positionId/candidates" />
3636
<TeamAccess path="/taas/myteams/:teamId/access" />
37-
<InputJobDescription path="/taas/myteams/createnewteam/jd/*" />
38-
<InputSkills path="/taas/myteams/createnewteam/skills/*" />
39-
<SelectRole path="/taas/myteams/createnewteam/role/*" />
37+
<InputJobDescription path="/taas/createnewteam/jd/*" />
38+
<InputSkills path="/taas/createnewteam/skills/*" />
39+
<SelectRole path="/taas/createnewteam/role/*" />
4040
</Router>
4141

4242
{/* Global config for Toastr popups */}

src/routes/CreateNewTeam/actions/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const addPreviousSearchId = (id) => ({
2222
payload: id,
2323
});
2424

25-
export const replaceSearchedRoles = (roles) => ({
26-
type: ACTION_TYPE.REPLACE_SEARCHED_ROLES,
27-
payload: { roles, lastRoleId: roles[roles.length - 1].searchId },
25+
const deleteRole = (id) => ({
26+
type: ACTION_TYPE.DELETE_SEARCHED_ROLE,
27+
payload: id,
2828
});
2929

3030
export const clearSearchedRoles = () => (dispatch, getState) => {
@@ -41,3 +41,8 @@ export const addRoleSearchId = (id) => (dispatch, getState) => {
4141
dispatch(addPreviousSearchId(id));
4242
updateLocalStorage(getState().searchedRoles);
4343
};
44+
45+
export const deleteSearchedRole = (id) => (dispatch, getState) => {
46+
dispatch(deleteRole(id));
47+
updateLocalStorage(getState().searchedRoles);
48+
};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function AddedRolesAccordion({ addedRoles }) {
1919
<div styleName="heading">
2020
<h4 styleName="title">
2121
{addedRoles.length}{" "}
22-
{addedRoles.length > 1 ? "roles have" : "role has"} been added.
22+
{addedRoles.length > 1 ? "positions have" : "position has"} been
23+
added.
2324
</h4>
2425
</div>
2526
<div styleName={cn("arrow", { [isOpen ? "up" : "down"]: true })}></div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function ItemList({
3737
<div styleName="item-list">
3838
<PageHeader
3939
title={title}
40-
backTo="/taas/myteams/createnewteam"
40+
backTo="/taas/createnewteam"
4141
aside={
4242
<>
4343
<Input

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
margin-right: 20px;
88
position: relative;
99
height: 80vh;
10-
overflow-y: scroll;
10+
overflow-y: auto;
1111

1212
> header {
1313
padding: 16px 24px;
@@ -33,9 +33,9 @@ input:not([type="checkbox"]).filter-input {
3333
color: #2a2a2a;
3434
font-size: 14px;
3535
height: 40px;
36-
line-height: 38px;
36+
line-height: normal;
3737
outline: none;
38-
padding: 0 15px;
38+
padding: 8px 15px;
3939

4040
&:not(:focus) {
4141
background-image: url("../../../../assets/images/icon-search.svg");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function NoMatchingProfilesResultCard({ role }) {
3838
<p>/Week</p>
3939
</div>
4040
)}
41-
<Link to="/taas/myteams/createnewteam">
41+
<Link to="/taas/createnewteam">
4242
<Button type="secondary" styleName="button">
4343
Modify Search Criteria
4444
</Button>

0 commit comments

Comments
 (0)