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

Commit e5403a6

Browse files
committed
Documentation and cleanup
1 parent 9dbc0ed commit e5403a6

File tree

23 files changed

+258
-186
lines changed

23 files changed

+258
-186
lines changed

config/dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ module.exports = {
1616

1717
API: {
1818
V5: "https://api.topcoder-dev.com/v5",
19-
V3: "https://api.topcoder-dev.com/v3"
19+
V3: "https://api.topcoder-dev.com/v3",
2020
},
2121
};

config/prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ module.exports = {
1616

1717
API: {
1818
V5: "https://api.topcoder.com/v5",
19-
V3: "https://api.topcoder.com/v3"
19+
V3: "https://api.topcoder.com/v3",
2020
},
2121
};

src/components/Babge/styles.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
line-height: 20px;
77
border-radius: 5px;
88
height: 20px;
9-
color: #FFFFFF;
9+
color: #ffffff;
1010
font-size: 12px;
1111
letter-spacing: 0.5px;
1212
text-align: left;
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
import React from 'react'
2-
import PT from 'prop-types'
3-
import Loader from 'react-loader-spinner';
1+
/**
2+
* A centered spinner used to indicate loading in modals
3+
*/
4+
5+
import React from "react";
6+
import PT from "prop-types";
7+
import Loader from "react-loader-spinner";
48
import "./styles.module.scss";
59

610
function CenteredSpinner(props) {
7-
const {type = "TailSpin", color = "#00BFFF", height = 80, width = 80} = props;
11+
const {
12+
type = "TailSpin",
13+
color = "#00BFFF",
14+
height = 80,
15+
width = 80,
16+
} = props;
817

918
return (
1019
<div styleName="loader-container">
1120
<Loader type={type} color={color} height={height} width={width} />
1221
</div>
13-
)
22+
);
1423
}
1524

1625
CenteredSpinner.propTypes = {
1726
type: PT.string,
1827
color: PT.string,
1928
height: PT.number,
20-
width: PT.number
21-
}
29+
width: PT.number,
30+
};
2231

23-
export default CenteredSpinner
32+
export default CenteredSpinner;

src/components/CenteredSpinner/styles.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
display: flex;
33
align-items: center;
44
flex-direction: column;
5-
}
5+
}

src/components/ReactSelect/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const ReactSelect = (props) => {
6363
borderRadius: "5px",
6464
}),
6565
dropdownIndicator: () => ({
66-
display: "none"
66+
display: "none",
6767
}),
6868
};
6969

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1+
/**
2+
* Report popup actions
3+
*/
4+
15
export const ACTION_TYPE = {
26
OPEN_REPORT: "OPEN_REPORT",
37
CLOSE_REPORT: "CLOSE_REPORT",
4-
}
8+
};
59

10+
/**
11+
* Action to populate the report info and open a report popup
12+
* @param {string} teamName Team name
13+
* @param {string|number} teamId Tead ID
14+
* @param {string} memberHandle Member handle
15+
*/
616
export const openReport = (teamName, teamId, memberHandle) => ({
717
type: ACTION_TYPE.OPEN_REPORT,
8-
payload: { teamName, teamId, memberHandle }
9-
})
18+
payload: { teamName, teamId, memberHandle },
19+
});
1020

21+
/**
22+
* Action to close a report popup
23+
*/
1124
export const closeReport = () => ({
12-
type: ACTION_TYPE.CLOSE_REPORT
13-
})
25+
type: ACTION_TYPE.CLOSE_REPORT,
26+
});
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
/**
2+
* Use report popup hook
3+
*/
4+
15
import { useDispatch } from "react-redux";
26
import { openReport } from "../actions";
37

8+
/**
9+
* Hook to allow report popup to be opened by any other component
10+
* (as long as it is mounted somewhere in the tree)
11+
*
12+
* @returns func A wrapper around the open report dispatch
13+
*/
414
export const useReportPopup = () => {
515
const dispatch = useDispatch();
616

717
return (teamName, teamId, memberHandle) => {
818
dispatch(openReport(teamName, teamId, memberHandle));
9-
}
10-
}
19+
};
20+
};

src/components/ReportPopup/index.jsx

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
import React, { useCallback, useState } from 'react'
2-
import { useSelector, useDispatch } from 'react-redux';
1+
/**
2+
* A report popup used to report issues with teams or team members
3+
*/
4+
5+
import React, { useCallback, useState } from "react";
6+
import { useSelector, useDispatch } from "react-redux";
37
import { toastr } from "react-redux-toastr";
4-
import { closeReport, submitReport } from "./actions";
5-
import BaseModal from "components/BaseModal"
6-
import TextArea from "components/TextArea"
8+
import { closeReport } from "./actions";
9+
import BaseModal from "components/BaseModal";
10+
import TextArea from "components/TextArea";
711
import Button from "../Button";
812
import { postReport } from "services/teams";
913
import CenteredSpinner from "components/CenteredSpinner";
1014

11-
12-
1315
function ReportPopup() {
14-
15-
const {isOpen, teamName, teamId, memberHandle } = useSelector(state => state.reportPopup);
16+
const { isOpen, teamName, teamId, memberHandle } = useSelector(
17+
(state) => state.reportPopup
18+
);
1619

1720
const dispatch = useDispatch();
1821
const [textVal, setTextVal] = useState("");
@@ -26,37 +29,50 @@ function ReportPopup() {
2629
console.log(res);
2730
setIsLoading(false);
2831
closeModal();
29-
toastr.success("Report submitted successfully")
32+
toastr.success("Report submitted successfully");
3033
})
31-
.catch(err => {
34+
.catch((err) => {
3235
setIsLoading(false);
3336
toastr.error("Report failed", err.message);
34-
})
35-
}
37+
});
38+
};
3639

3740
const button = (
38-
<Button
39-
onClick={() => submitReport()}
40-
size="medium"
41-
isSubmit
42-
disabled={textVal.trim().length < 1 || isLoading}
43-
>
41+
<Button
42+
onClick={() => submitReport()}
43+
size="medium"
44+
isSubmit
45+
disabled={textVal.trim().length < 1 || isLoading}
46+
>
4447
Submit
45-
</Button>
46-
)
48+
</Button>
49+
);
4750

4851
const closeModal = useCallback(() => {
4952
dispatch(closeReport());
50-
}, [dispatch])
53+
}, [dispatch]);
5154

5255
return (
53-
<BaseModal
54-
open={isOpen}
55-
onClose={closeModal}
56-
title={`Issue Report - ${teamName}${memberHandle ? " - " + memberHandle : ""}`} button={button} disabled={isLoading}>
57-
{isLoading ? <CenteredSpinner /> : <TextArea value={textVal} onChange={setTextVal}placeholder="Describe your issue" /> }
58-
</BaseModal>
59-
)
56+
<BaseModal
57+
open={isOpen}
58+
onClose={closeModal}
59+
title={`Issue Report - ${teamName}${
60+
memberHandle ? " - " + memberHandle : ""
61+
}`}
62+
button={button}
63+
disabled={isLoading}
64+
>
65+
{isLoading ? (
66+
<CenteredSpinner />
67+
) : (
68+
<TextArea
69+
value={textVal}
70+
onChange={setTextVal}
71+
placeholder="Describe your issue"
72+
/>
73+
)}
74+
</BaseModal>
75+
);
6076
}
6177

62-
export default ReportPopup;
78+
export default ReportPopup;
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
import { ACTION_TYPE } from '../actions';
1+
/**
2+
* Reducer for Report popup
3+
*/
4+
5+
import { ACTION_TYPE } from "../actions";
26

37
const initialState = {
48
teamName: undefined,
59
teamId: undefined,
610
memberHandle: undefined,
711
isOpen: false,
8-
}
12+
};
913

1014
const reducer = (state = initialState, action) => {
1115
switch (action.type) {
12-
1316
case ACTION_TYPE.OPEN_REPORT:
1417
return {
1518
...state,
1619
...action.payload,
1720
isOpen: true,
18-
}
21+
};
1922

2023
case ACTION_TYPE.CLOSE_REPORT:
2124
return {
2225
...state,
2326
isOpen: false,
24-
}
27+
};
2528

2629
default:
2730
return state;
2831
}
29-
}
32+
};
3033

3134
export default reducer;

src/reducers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const rootReducer = combineReducers({
1111
toastr: toastrReducer,
1212
positionDetails: positionDetailsReducer,
1313
teamMembers: teamMembersReducer,
14-
reportPopup: reportPopupReducer
14+
reportPopup: reportPopupReducer,
1515
});
1616

1717
export default rootReducer;

src/routes/MyTeamsDetails/components/TeamMembers/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ const TeamMembers = ({ team }) => {
162162
},
163163
{
164164
label: "Report an Issue",
165-
action: () => {showReportPopup(team.name, team.id, member.handle)},
165+
action: () => {
166+
showReportPopup(team.name, team.id, member.handle);
167+
},
166168
},
167169
{
168170
label: "Request an Extension",

src/routes/MyTeamsDetails/components/TeamSummary/index.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { useReportPopup } from "components/ReportPopup/hooks/useReportPopup";
2020
import "./styles.module.scss";
2121

2222
const TeamSummary = ({ team }) => {
23-
2423
const showReportPopup = useReportPopup();
2524

2625
return (

src/routes/MyTeamsList/components/TeamCard/index.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import ThreeDotsMenu from "components/ThreeDotsMenu";
2222
import { useReportPopup } from "components/ReportPopup/hooks/useReportPopup";
2323

2424
const TeamCard = ({ team }) => {
25-
2625
const showReportPopup = useReportPopup();
2726

2827
return (
@@ -33,7 +32,7 @@ const TeamCard = ({ team }) => {
3332
{
3433
label: "Open in Connect",
3534
action: () => {
36-
console.log("Issue reported!")
35+
console.log("Issue reported!");
3736
},
3837
},
3938
{

src/routes/PositionDetails/components/PositionCandidates/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const PositionCandidates = ({ position, candidateStatus, updateCandidate }) => {
6161

6262
useEffect(() => {
6363
setPage(1);
64-
}, [candidateStatus])
64+
}, [candidateStatus]);
6565

6666
const filteredCandidates = useMemo(
6767
() =>

0 commit comments

Comments
 (0)