Skip to content

Commit d1b4b79

Browse files
authored
Merge pull request #124 from kube-js/develop
feat: added stripe checkout form validation
2 parents cdde8e2 + 31d0657 commit d1b4b79

File tree

20 files changed

+310
-295
lines changed

20 files changed

+310
-295
lines changed

.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ REACT_APP_LOGGER_TYPE=dummy
99
# sentry options:
1010
REACT_APP_SENTRY_DSN=https://[email protected]/yourSentryNumber
1111
# available values: production, development
12-
REACT_APP_NODE_ENV=development
12+
REACT_APP_NODE_ENV=development
13+
14+
STRIPE_PUBLISHABLE_KEY=pk_test_TYooMQauvdEDq54NiTphI7jx

k8s/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
description: A Helm chart for kube-ts-react-client
33
name: kube-ts-react-client
44
version: 1.0.0
5-
appVersion: 1.6.25
5+
appVersion: 1.7.0
66
home: https://cloud.docker.com/u/kubejs/repository/docker/kubejs/kube-ts-react-client
77
icon: https://avatars2.githubusercontent.com/u/47761918?s=200&v=4
88
sources:

k8s/values-circleci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ configMap:
77
REACT_APP_SENTRY_DSN: $REACT_APP_SENTRY_DSN
88
REACT_APP_LOGGER_TYPE: $REACT_APP_LOGGER_TYPE
99
REACT_APP_NODE_ENV: $REACT_APP_NODE_ENV
10+
STRIPE_PUBLISHABLE_KEY: $STRIPE_PUBLISHABLE_KEY
1011

k8s/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replicaCount: 2
66

77
image:
88
repository: kubejs/kube-ts-react-client
9-
tag: 1.6.25
9+
tag: 1.7.0
1010
pullPolicy: Always
1111
containerPort: 80
1212

package-lock.json

Lines changed: 24 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
"pre-commit": "1.2.2",
3131
"ramda": "0.26.1",
3232
"react": "16.12.0",
33-
"react-credit-cards": "0.8.0",
3433
"react-dom": "16.12.0",
3534
"react-i18next": "11.2.5",
3635
"react-redux": "7.1.3",
3736
"react-router": "5.1.2",
3837
"react-router-dom": "5.1.2",
3938
"react-scripts": "2.1.8",
4039
"react-slick": "0.25.2",
40+
"react-stripe-elements": "^6.0.1",
4141
"redux": "4.0.4",
4242
"redux-persist": "6.0.0",
4343
"redux-saga": "1.1.3",
@@ -59,12 +59,12 @@
5959
"@types/node": "11.15.3",
6060
"@types/ramda": "0.26.36",
6161
"@types/react": "16.9.13",
62-
"@types/react-credit-cards": "0.8.0",
6362
"@types/react-dom": "16.9.4",
6463
"@types/react-redux": "7.1.5",
6564
"@types/react-router": "5.1.3",
6665
"@types/react-router-dom": "5.1.3",
6766
"@types/react-slick": "0.23.4",
67+
"@types/react-stripe-elements": "^1.3.5",
6868
"@types/redux-logger": "3.0.7",
6969
"@types/redux-persist": "4.3.1",
7070
"@types/store": "2.0.2",

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<script id="stripe-js" src="https://js.stripe.com/v3/" async></script>
67
<!-- added env variables window._env_ -->
78
<script src="%PUBLIC_URL%/env-config.js"></script>
89
<meta

src/api/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ const createApi = ({ httpClient, token }: Options): Api => {
148148
}),
149149
getDiscoveryItems: <T>({
150150
searchParams,
151-
type,
152151
}: BaseGetOptions): Promise<T> =>
153152
normalisePromise(
154153
httpClient.get('discovery-items', {

src/app.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import Login from './pages/Login';
2828
import NotFound from './pages/NotFound';
2929
import Notifier from './pages/Notifier';
3030
import Register from './pages/Register';
31-
// tslint:disable-next-line:no-import-side-effect
32-
import './styles/index.css';
3331

3432
const RemindPassword = lazy(() => import('./pages/RemindPassword'));
3533
const ResetPassword = lazy(() => import('./pages/ResetPassword'));
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { TextField } from '@material-ui/core';
2+
import React, { useState } from 'react';
3+
import StripeInput from '../StripeInput';
4+
5+
interface Props {
6+
readonly component: any;
7+
readonly label: string;
8+
readonly id: string;
9+
readonly name: string;
10+
readonly fullWidth?: boolean;
11+
}
12+
13+
const StripeElementWrapper = ({
14+
component,
15+
fullWidth = true,
16+
label,
17+
...otherProps
18+
}: Props) => {
19+
const [error, setError] = useState(null);
20+
const [empty, setEmpty] = useState(true);
21+
const [focused, setFocused] = useState(false);
22+
23+
const handleChange = (changeObj: any) => {
24+
setError(changeObj.error);
25+
setEmpty(changeObj.empty);
26+
};
27+
28+
const handleFocus = (e: any) => {
29+
setFocused(true);
30+
};
31+
32+
const handleBlur = () => {
33+
setFocused(false);
34+
};
35+
36+
const hasError = Boolean(error);
37+
38+
return (
39+
<TextField
40+
fullWidth={fullWidth}
41+
variant="outlined"
42+
error={hasError}
43+
label={label}
44+
InputLabelProps={{
45+
error: hasError,
46+
focused,
47+
shrink: focused || !empty,
48+
}}
49+
InputProps={{
50+
inputComponent: StripeInput,
51+
inputProps: {
52+
component,
53+
onBlur: handleBlur,
54+
onFocus: handleFocus,
55+
placeholder: '',
56+
},
57+
onChange: handleChange,
58+
}}
59+
helperText={hasError ? (error as any).message : null}
60+
{...otherProps}
61+
/>
62+
);
63+
};
64+
65+
export default StripeElementWrapper;

0 commit comments

Comments
 (0)