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

Commit 4b77b44

Browse files
committed
Implemented Modal component and payment cancelling.
1 parent 02c6a82 commit 4b77b44

File tree

21 files changed

+603
-98
lines changed

21 files changed

+603
-98
lines changed
Lines changed: 30 additions & 0 deletions
Loading

src/components/Button/index.jsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import styles from "./styles.module.scss";
99
* @param {Object} props component properties
1010
* @param {Object} props.children button text
1111
* @param {string} [props.className] class name added to root element
12-
* @param {'primary'|'primary-dark'|'primary-light'} [props.color] button color
12+
* @param {'primary'|'primary-dark'|'primary-light'|'error'|'warning'} [props.color]
13+
* button color
1314
* @param {boolean} [props.isDisabled] if button is disabled
1415
* @param {boolean} [props.isSelected] if button is selected
1516
* @param {string} [props.name] button name
16-
* @param {(e: any) => void} props.onClick function called when button is clicked
17+
* @param {(e: any) => void} [props.onClick] function called when button is clicked
1718
* @param {'medium'|'small'} [props.size] button size
1819
* @param {'circle'|'rounded'} [props.style] button style
1920
* @param {'button'|'submit'|'reset'} [props.type] button type
@@ -42,13 +43,11 @@ const Button = ({
4243
type={type}
4344
className={cn(
4445
styles.button,
45-
{
46-
[styles.selected]: isSelected,
47-
[styles[color]]: true,
48-
[styles[size]]: true,
49-
[styles[style]]: true,
50-
[styles[variant]]: true,
51-
},
46+
styles[color],
47+
styles[size],
48+
styles[style],
49+
styles[variant],
50+
{ [styles.selected]: isSelected },
5251
className
5352
)}
5453
onClick={onClick}
@@ -60,7 +59,13 @@ const Button = ({
6059
Button.propTypes = {
6160
children: PT.node,
6261
className: PT.string,
63-
color: PT.oneOf(["primary"]),
62+
color: PT.oneOf([
63+
"primary",
64+
"primary-dark",
65+
"primary-light",
66+
"error",
67+
"warning",
68+
]),
6469
isDisabled: PT.bool,
6570
isSelected: PT.bool,
6671
name: PT.string,

src/components/Button/styles.module.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
align-items: center;
88
@include roboto-bold;
99
letter-spacing: 0.8px;
10+
white-space: nowrap;
1011
text-transform: uppercase;
1112
outline: none;
1213
cursor: pointer;
@@ -61,6 +62,16 @@
6162
color: $primary-dark-text-color;
6263
}
6364

65+
&.error {
66+
border-color: $error-color;
67+
color: $error-text-color;
68+
}
69+
70+
&.warning {
71+
border-color: $warning-color;
72+
color: $warning-text-color;
73+
}
74+
6475
&:disabled {
6576
border-color: $control-disabled-border-color;
6677
background-color: $control-disabled-bg-color;
@@ -88,6 +99,16 @@
8899
background-color: $primary-dark-color;
89100
}
90101

102+
&.error {
103+
border-color: $error-color;
104+
background-color: $error-color;
105+
}
106+
107+
&.warning {
108+
border-color: $warning-color;
109+
background-color: $warning-color;
110+
}
111+
91112
&:disabled {
92113
border-color: $control-disabled-border-color;
93114
background-color: $control-disabled-bg-color;

src/components/Modal/index.jsx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React from "react";
2+
import PT from "prop-types";
3+
import { Modal as ReactModal } from "react-responsive-modal";
4+
import Button from "components/Button";
5+
import IconCross from "../../assets/images/icon-cross-light.svg";
6+
import { stopImmediatePropagation } from "utils/misc";
7+
import styles from "./styles.module.scss";
8+
import "react-responsive-modal/styles.css";
9+
10+
const classNames = {
11+
modal: styles.modal,
12+
modalContainer: styles.modalContainer,
13+
};
14+
const closeIcon = <IconCross />;
15+
16+
const Modal = ({
17+
approveText = "Apply",
18+
children,
19+
controls,
20+
dismissText = "Cancel",
21+
isOpen,
22+
onApprove,
23+
onDismiss,
24+
title,
25+
}) => (
26+
<ReactModal
27+
center
28+
classNames={classNames}
29+
onClose={onDismiss}
30+
open={isOpen}
31+
onOverlayClick={stopImmediatePropagation}
32+
showCloseIcon={false}
33+
>
34+
<div
35+
className={styles.wrapper}
36+
onClick={stopImmediatePropagation}
37+
role="button"
38+
tabIndex={0}
39+
>
40+
{title && <div className={styles.title}>{title}</div>}
41+
<div className={styles.content}>{children}</div>
42+
{controls || controls === null ? (
43+
controls
44+
) : (
45+
<div className={styles.controls}>
46+
<Button
47+
className={styles.button}
48+
color="warning"
49+
variant="contained"
50+
onClick={onApprove}
51+
>
52+
{approveText}
53+
</Button>
54+
<Button className={styles.button} onClick={onDismiss}>
55+
{dismissText}
56+
</Button>
57+
</div>
58+
)}
59+
<button className={styles.closeButton} type="button" onClick={onDismiss}>
60+
{closeIcon}
61+
</button>
62+
</div>
63+
</ReactModal>
64+
);
65+
66+
Modal.propTypes = {
67+
approveText: PT.string,
68+
children: PT.node,
69+
container: PT.element,
70+
controls: PT.node,
71+
dismissText: PT.string,
72+
isOpen: PT.bool.isRequired,
73+
onApprove: PT.func,
74+
onDismiss: PT.func.isRequired,
75+
title: PT.string,
76+
};
77+
78+
export default Modal;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@import "styles/mixins";
2+
3+
div.modalContainer {
4+
padding: 20px;
5+
}
6+
7+
div.modal {
8+
margin: 0;
9+
border-radius: 8px;
10+
border: none;
11+
padding: 0;
12+
width: 640px;
13+
max-width: 100%;
14+
}
15+
16+
.wrapper {
17+
padding: 32px 32px 22px;
18+
}
19+
20+
button.closeButton {
21+
display: inline-block;
22+
position: absolute;
23+
top: 14px;
24+
right: 14px;
25+
border: none;
26+
padding: 0;
27+
width: 15px;
28+
background: transparent;
29+
outline: none !important;
30+
box-shadow: none !important;
31+
32+
svg {
33+
display: block;
34+
width: 100%;
35+
height: auto;
36+
}
37+
}
38+
39+
.title {
40+
margin: 0 0 24px;
41+
font-size: 34px;
42+
line-height: 38px;
43+
text-transform: uppercase;
44+
@include barlow-condensed;
45+
}
46+
47+
.content {
48+
margin: 0 0 10px;
49+
font-size: 16px;
50+
line-height: 22px;
51+
@include roboto-regular;
52+
53+
+ .controls {
54+
margin-top: 24px;
55+
}
56+
}
57+
58+
.controls {
59+
display: flex;
60+
flex-wrap: wrap;
61+
}
62+
63+
.button {
64+
margin: 0 10px 10px 0;
65+
66+
&:last-child {
67+
margin-right: 0;
68+
}
69+
}

src/components/Spinner/index.jsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
import React from "react";
22
import PT from "prop-types";
33
import cn from "classnames";
4+
import Loader from "react-loader-spinner";
45
import styles from "./styles.module.scss";
56

67
/**
78
* Displays spinning incomplete circle.
89
*
910
* @param {Object} props component props
1011
* @param {string} [props.className] class name added to root element
11-
* @param {string} [props.spinnerClassName] class name added to spinner element
12+
* @param {string} [props.color] spinner color in HEX format
13+
* @param {any} [props.type] spinner type as defined in
14+
* react-loader-spinner documentation
15+
* @param {number} [props.width] spinner width
16+
* @param {number} [props.height] spinner height
1217
* @returns {JSX.Element}
1318
*/
14-
const Spinner = ({ className, spinnerClassName }) => (
19+
const Spinner = ({
20+
className,
21+
color = "#00BFFF",
22+
type = "TailSpin",
23+
width = 80,
24+
height = 0,
25+
}) => (
1526
<div className={cn(styles.container, className)}>
16-
<span className={cn(styles.spinner, spinnerClassName)}>Loading...</span>
27+
<Loader color={color} type={type} width={width} height={height || width} />
1728
</div>
1829
);
1930

2031
Spinner.propTypes = {
2132
className: PT.string,
22-
spinnerClassName: PT.string,
33+
color: PT.string,
34+
type: PT.string,
35+
width: PT.number,
36+
height: PT.number,
2337
};
2438

2539
export default Spinner;
Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,7 @@
1-
@import 'styles/variables';
1+
@import "styles/variables";
22

33
.container {
4-
position: relative;
5-
padding-bottom: 100%;
6-
width: 100%;
7-
height: 0;
8-
overflow: hidden;
9-
}
10-
11-
.spinner {
12-
position: absolute;
13-
left: 0;
14-
top: 0;
15-
right: 0;
16-
bottom: 0;
17-
margin: auto;
18-
padding-bottom: 50%;
19-
width: 50%;
20-
height: 0;
21-
color: transparent;
22-
user-select: none;
23-
24-
&::after {
25-
content: '';
26-
display: block;
27-
position: absolute;
28-
left: 0;
29-
top: 0;
30-
right: 0;
31-
bottom: 0;
32-
border: 10px solid $control-border-color;
33-
border-right-color: transparent;
34-
border-radius: 9999px;
35-
animation: loading-indicator 0.75s linear infinite;
36-
}
37-
}
38-
39-
@keyframes loading-indicator {
40-
to {
41-
transform: rotate(360deg);
42-
}
4+
display: flex;
5+
flex-direction: column;
6+
align-items: center;
437
}

src/constants/workPeriods.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const API_REQUIRED_FIELDS = [
5656
"workPeriods.payments.memberRate",
5757
"workPeriods.payments.status",
5858
"workPeriods.payments.statusDetails",
59+
"workPeriods.payments.workPeriodId",
5960
];
6061

6162
// Valid parameter names for requests.

0 commit comments

Comments
 (0)