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

Commit 671b49b

Browse files
authored
Merge pull request #471 from yoution/issue-461
fix: issue #461 #464
2 parents 7e111c4 + 685aff5 commit 671b49b

File tree

4 files changed

+157
-18
lines changed

4 files changed

+157
-18
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ function SearchAndSubmit(props) {
2929

3030
const matchedSkills = useMemo(() => {
3131
if (skills && matchingRole && matchingRole.matchedSkills) {
32-
return _.map(matchingRole.matchedSkills, (s) =>
32+
return _.compact(_.map(matchingRole.matchedSkills, (s) =>
3333
_.find(skills, (skill) => skill.name === s)
34-
);
34+
));
3535
} else {
3636
return [];
3737
}
3838
}, [skills, matchingRole]);
3939

4040
const unMatchedSkills = useMemo(() => {
4141
if (skills && matchingRole && matchingRole.unMatchedSkills) {
42-
return _.map(matchingRole.unMatchedSkills, (s) =>
42+
return _.compact(_.map(matchingRole.unMatchedSkills, (s) =>
4343
_.find(skills, (skill) => skill.name === s)
44-
);
44+
));
4545
} else {
4646
return [];
4747
}

src/routes/CreateNewTeam/pages/CreateTaasPayment/PaymentForm/index.jsx

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
useElements,
99
} from "@stripe/react-stripe-js";
1010
import { navigate } from "@reach/router";
11+
import _ from "lodash";
1112
import { toastr } from "react-redux-toastr";
1213
import { makeStyles } from "@material-ui/core/styles";
1314
import Typography from "@material-ui/core/Typography";
@@ -19,6 +20,7 @@ import StripeElement from "../StripeElement";
1920
import FormField from "../FormField";
2021
import SelectField from "../SelectField";
2122
import ConfirmationModal from "../../../components/ConfirmationModal";
23+
import PaymentResultPopup from "../PaymentResultPopup";
2224

2325
import "./styles.module.scss";
2426

@@ -50,9 +52,15 @@ const PaymentForm = ({ calculatedAmount }) => {
5052
const [formValues, setFormValues] = useState(initialFormValues);
5153
const [dropdownValue, setDropdownValue] = useState("");
5254
const [processing, setProcessing] = useState(false);
55+
const [showPaymentResultPopup, setShowPaymentResultPopup] = useState(false);
5356
const [requestLoading, setRequestLoading] = useState(false);
54-
const [errors, setErrors] = useState({card: true, cardExpire: true, cardCvc: true});
57+
const [errors, setErrors] = useState({
58+
card: true,
59+
cardExpire: true,
60+
cardCvc: true,
61+
});
5562
const [clicked, setClicked] = useState(true);
63+
const [projectId, setProjectId] = useState(null);
5664
const stripe = useStripe();
5765
const elements = useElements();
5866
const dispatch = useDispatch();
@@ -86,11 +94,11 @@ const PaymentForm = ({ calculatedAmount }) => {
8694
});
8795
};
8896
const handleStripeElementError = (fieldName, error) => {
89-
errors[fieldName] = error ? true: false
97+
errors[fieldName] = error ? true : false;
9098
setErrors({
9199
...errors,
92100
});
93-
}
101+
};
94102
const handleInputValue = (e) => {
95103
const { name, value } = e.target;
96104
setFormValues({
@@ -101,6 +109,11 @@ const PaymentForm = ({ calculatedAmount }) => {
101109
[name]: value,
102110
});
103111
};
112+
const goToTassProject = () => {
113+
dispatch(clearSearchedRoles());
114+
setShowPaymentResultPopup(false);
115+
navigate(`/taas/myteams/${projectId}`);
116+
};
104117
const handleFormSubmit = async (e) => {
105118
e.preventDefault();
106119
if (formIsValid() && clicked) {
@@ -130,12 +143,9 @@ const PaymentForm = ({ calculatedAmount }) => {
130143
toastr.success("Payment is successful");
131144
setRequestLoading(true);
132145
postTeamRequest(teamObject)
133-
.then(() => {
134-
setTimeout(() => {
135-
dispatch(clearSearchedRoles());
136-
// Backend api create project has sync issue, so delay 2 seconds
137-
navigate("/taas/myteams");
138-
}, 2000);
146+
.then((res) => {
147+
setProjectId(_.get(res, "data.projectId"));
148+
setShowPaymentResultPopup(true);
139149
})
140150
.catch((err) => {
141151
setRequestLoading(false);
@@ -154,14 +164,16 @@ const PaymentForm = ({ calculatedAmount }) => {
154164

155165
const formIsValid = (fieldValues = formValues) => {
156166
// check card valid
157-
const cardValid = !errors['card'] && !errors['cardExpire'] && !errors['cvc']
167+
const cardValid =
168+
!errors["card"] && !errors["cardExpire"] && !errors["cvc"];
158169
const dropdown = dropdownValue === "" ? false : true;
159170
const isValid =
160171
fieldValues.email &&
161172
fieldValues.name &&
162173
fieldValues.zipcode &&
163-
dropdown && cardValid
164-
Object.values(errors).every((x) => x === "");
174+
dropdown &&
175+
cardValid;
176+
Object.values(errors).every((x) => x === "");
165177

166178
return isValid;
167179
};
@@ -181,9 +193,20 @@ const PaymentForm = ({ calculatedAmount }) => {
181193
Card Information
182194
</Typography>
183195
</Box>
184-
<StripeElement onErrorChange={handleStripeElementError} element={CardNumberElement} name="card" icon="card" />
196+
<StripeElement
197+
onErrorChange={handleStripeElementError}
198+
element={CardNumberElement}
199+
name="card"
200+
icon="card"
201+
/>
185202
<div styleName="horizontal">
186-
<StripeElement onErrorChange={handleStripeElementError} element={CardExpiryElement} name=""width="150px" name='cardExpire' />
203+
<StripeElement
204+
onErrorChange={handleStripeElementError}
205+
element={CardExpiryElement}
206+
name=""
207+
width="150px"
208+
name="cardExpire"
209+
/>
187210
<StripeElement
188211
className={classes.cvc}
189212
name="cvc"
@@ -217,6 +240,13 @@ const PaymentForm = ({ calculatedAmount }) => {
217240
</button>
218241
</form>
219242
<ConfirmationModal open={requestLoading} isLoading={requestLoading} />
243+
<PaymentResultPopup
244+
open={showPaymentResultPopup}
245+
onContinueClick={goToTassProject}
246+
onClose={() => {
247+
setShowPaymentResultPopup(false);
248+
}}
249+
/>
220250
</>
221251
);
222252
};
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Payment result popup
3+
*/
4+
import React, { useState, useEffect } from "react";
5+
import PT from "prop-types";
6+
import { useInterval } from "react-use";
7+
import Button from "components/Button";
8+
import BaseCreateModal from "../../../components/BaseCreateModal";
9+
import "./styles.module.scss";
10+
11+
function PaymentResultPopup({ open, onClose, onContinueClick }) {
12+
const [second, setSecond] = useState(10);
13+
useInterval(
14+
() => {
15+
setSecond(second - 1);
16+
},
17+
second > 0 ? 1000 : null
18+
);
19+
useEffect(() => {
20+
if (second === 0) {
21+
onContinueClick();
22+
}
23+
}, [second, onContinueClick]);
24+
25+
const Buttons = (
26+
<div styleName="button-contaier">
27+
<Button
28+
type="primary"
29+
size="medium"
30+
styleName="continue-button"
31+
onClick={onContinueClick}
32+
>
33+
TAKE ME TO MY TEAM
34+
</Button>
35+
<div styleName="time-label">
36+
You will be automatically redirected in{" "}
37+
{second === 0 || second === 10 ? second : "0" + second} seconds
38+
</div>
39+
</div>
40+
);
41+
42+
return (
43+
<BaseCreateModal
44+
open={open}
45+
onClose={onClose}
46+
maxWidth="560px"
47+
buttons={Buttons}
48+
>
49+
<h1 styleName="header">WE'VE RECEIVED YOUR DEPOSIT</h1>
50+
<div styleName="sub-header">
51+
Thanks for trusting us with your talent needs! You will be redirected to
52+
your Team page where you can review candidates, schedule interviews, and
53+
lock in your selections.
54+
</div>
55+
</BaseCreateModal>
56+
);
57+
}
58+
59+
PaymentResultPopup.propTypes = {
60+
open: PT.bool,
61+
onClose: PT.func,
62+
onContinueClick: PT.func,
63+
};
64+
65+
export default PaymentResultPopup;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@import "styles/include";
2+
3+
.header {
4+
margin-top: -30px;
5+
background-color: #ffffff;
6+
background-image: linear-gradient(
7+
90deg
8+
, #9D41C9, #EF476F);
9+
background-size: 100%;
10+
background-clip: text;
11+
-webkit-text-fill-color: transparent;
12+
font-family: BarlowCondensed;
13+
font-size: 34px;
14+
line-height: 38px;
15+
text-align: center;
16+
}
17+
18+
.sub-header {
19+
@include font-roboto;
20+
margin-top: 20px;
21+
color: #2A2A2A;
22+
font-size: 16px;
23+
line-height: 26px;
24+
text-align: center;
25+
}
26+
27+
.button-contaier {
28+
display: flex;
29+
flex-direction: column;
30+
align-items: center;
31+
32+
.time-label {
33+
@include font-roboto;
34+
margin-top: 10px;
35+
color: #2A2A2A;
36+
font-size: 14px;
37+
line-height: 22px;
38+
text-align: center;
39+
}
40+
}
41+
42+
.continue-button:disabled {
43+
background-color: #997b7be6;
44+
}

0 commit comments

Comments
 (0)