@oasisomniverse/react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/package.json +72 -0
- package/src/components/App.js +504 -0
- package/src/components/ForgetPassword.js +126 -0
- package/src/components/Login.js +222 -0
- package/src/components/ResetPassword.js +176 -0
- package/src/components/Signup.js +285 -0
- package/src/components/VerifyEmail.js +68 -0
- package/src/components/common/AvatarConnect.jsx +89 -0
- package/src/components/common/Contact.jsx +60 -0
- package/src/components/common/Eggs.jsx +50 -0
- package/src/components/common/Game.jsx +36 -0
- package/src/components/common/HyperDrive.jsx +50 -0
- package/src/components/common/KarmaToast.jsx +38 -0
- package/src/components/common/Map.jsx +42 -0
- package/src/components/common/MenuMessage.jsx +70 -0
- package/src/components/common/Messaging.jsx +74 -0
- package/src/components/common/Mission.jsx +40 -0
- package/src/components/common/NFT.jsx +42 -0
- package/src/components/common/NavBar.jsx +52 -0
- package/src/components/common/Navbar.js +137 -0
- package/src/components/common/OApp.jsx +41 -0
- package/src/components/common/ONET.jsx +50 -0
- package/src/components/common/ONODE.jsx +49 -0
- package/src/components/common/OasisModal.css +9 -0
- package/src/components/common/OasisModal.jsx +29 -0
- package/src/components/common/ProviderDropdown.js +25 -0
- package/src/components/common/ProviderDropdown.jsx +61 -0
- package/src/components/common/Providers.jsx +38 -0
- package/src/components/common/Quest.jsx +40 -0
- package/src/components/common/SearchAvatars.jsx +49 -0
- package/src/components/common/Seeds.jsx +39 -0
- package/src/components/common/Settings.jsx +70 -0
- package/src/components/common/StarField.jsx +56 -0
- package/src/components/common/Wallet.jsx +45 -0
- package/src/components/common/message/MessageContacts.jsx +66 -0
- package/src/components/common/message/Messages.jsx +75 -0
- package/src/components/common/sidebar/Sidebar.jsx +27 -0
- package/src/components/common/sidebar/SidebarData.js +615 -0
- package/src/components/common/sidebar/SidebarMenuItem.jsx +79 -0
- package/src/components/index.js +26 -0
- package/src/components/pages/forgotPassword.js +47 -0
- package/src/components/popups/avatar/components/AvatarWallet.jsx +169 -0
- package/src/components/popups/avatar/components/EditAvatar.jsx +34 -0
- package/src/components/popups/avatar/components/SearchAvatar.jsx +34 -0
- package/src/components/popups/avatar/components/ViewAvatar.jsx +148 -0
- package/src/components/popups/avatar/index.jsx +39 -0
- package/src/components/popups/comingsoon/ComingSoon.jsx +28 -0
- package/src/components/popups/confirmation/Confirmation.js +30 -0
- package/src/components/popups/contact/index.js +100 -0
- package/src/components/popups/data-screen/components/AddData.jsx +89 -0
- package/src/components/popups/data-screen/components/CrossChainManagement.jsx +87 -0
- package/src/components/popups/data-screen/components/LoadData.jsx +157 -0
- package/src/components/popups/data-screen/components/ManageData.jsx +34 -0
- package/src/components/popups/data-screen/components/OffChainManagement.jsx +177 -0
- package/src/components/popups/data-screen/components/SearchData.jsx +34 -0
- package/src/components/popups/data-screen/index.jsx +52 -0
- package/src/components/popups/eggs/components/ManageEggs.jsx +34 -0
- package/src/components/popups/eggs/components/SearchEggs.jsx +34 -0
- package/src/components/popups/eggs/components/ViewEggs.jsx +34 -0
- package/src/components/popups/eggs/index.jsx +31 -0
- package/src/components/popups/game/components/SearchProfiles.jsx +34 -0
- package/src/components/popups/game/components/ViewAchievements.jsx +34 -0
- package/src/components/popups/game/components/ViewLeagues.jsx +34 -0
- package/src/components/popups/game/components/ViewTournaments.jsx +34 -0
- package/src/components/popups/game/index.jsx +38 -0
- package/src/components/popups/karma/components/SearchKarma.jsx +34 -0
- package/src/components/popups/karma/components/ViewAvatarKarma.jsx +139 -0
- package/src/components/popups/karma/components/ViewKarma.jsx +103 -0
- package/src/components/popups/karma/components/VoteKarma.jsx +34 -0
- package/src/components/popups/karma/index.jsx +34 -0
- package/src/components/popups/map/components/Add2dObjectMap.jsx +34 -0
- package/src/components/popups/map/components/Add3dObjectMap.jsx +34 -0
- package/src/components/popups/map/components/AddQuestToMap.jsx +34 -0
- package/src/components/popups/map/components/DownloadOurWorld.jsx +34 -0
- package/src/components/popups/map/components/ManageMap.jsx +34 -0
- package/src/components/popups/map/components/PlotRouteOnMap.jsx +34 -0
- package/src/components/popups/map/components/SearchMap.jsx +34 -0
- package/src/components/popups/map/components/ViewGlobal3dMap.jsx +34 -0
- package/src/components/popups/map/components/ViewHalonsOnMap.jsx +34 -0
- package/src/components/popups/map/components/ViewOappOnMap.jsx +34 -0
- package/src/components/popups/map/components/ViewQuestOnMap.jsx +34 -0
- package/src/components/popups/map/index.jsx +79 -0
- package/src/components/popups/messages/Message.jsx +86 -0
- package/src/components/popups/mission/components/ManageMission.jsx +34 -0
- package/src/components/popups/mission/components/SearchMission.jsx +34 -0
- package/src/components/popups/mission/components/ViewMission.jsx +34 -0
- package/src/components/popups/mission/index.jsx +32 -0
- package/src/components/popups/nft/ContactPopup.jsx +146 -0
- package/src/components/popups/nft/Solana.jsx +70 -0
- package/src/components/popups/nft/components/ManageOasisNft.jsx +34 -0
- package/src/components/popups/nft/components/PurchaseOasisNft.jsx +34 -0
- package/src/components/popups/nft/components/PurchaseOasisVirtualLandNft.jsx +34 -0
- package/src/components/popups/nft/components/SearchOasisNft.jsx +34 -0
- package/src/components/popups/nft/components/ViewOasisNft.jsx +34 -0
- package/src/components/popups/nft/index.jsx +45 -0
- package/src/components/popups/oapp/components/CreateOAPP.jsx +34 -0
- package/src/components/popups/oapp/components/DeployOAPP.jsx +34 -0
- package/src/components/popups/oapp/components/DownloadOurWorld.jsx +34 -0
- package/src/components/popups/oapp/components/EditOAPP.jsx +34 -0
- package/src/components/popups/oapp/components/InstallOAPP.jsx +34 -0
- package/src/components/popups/oapp/components/LaunchOAPP.jsx +34 -0
- package/src/components/popups/oapp/components/ManageOAPP.jsx +68 -0
- package/src/components/popups/oapp/components/SearchOAPP.jsx +34 -0
- package/src/components/popups/oapp/index.jsx +62 -0
- package/src/components/popups/provider/components/ActivityPub.jsx +34 -0
- package/src/components/popups/provider/components/CompareProviderSpeeds.jsx +123 -0
- package/src/components/popups/provider/components/Eosio.jsx +34 -0
- package/src/components/popups/provider/components/Ethereum.jsx +34 -0
- package/src/components/popups/provider/components/Holochain.jsx +34 -0
- package/src/components/popups/provider/components/Ipfs.jsx +35 -0
- package/src/components/popups/provider/components/ManageAutoFailOver.jsx +34 -0
- package/src/components/popups/provider/components/ManageAutoReplicaton.jsx +34 -0
- package/src/components/popups/provider/components/ManageLoadBalancing.jsx +34 -0
- package/src/components/popups/provider/components/ManageProviders.jsx +34 -0
- package/src/components/popups/provider/components/MongoDb.jsx +34 -0
- package/src/components/popups/provider/components/Neo4j.jsx +34 -0
- package/src/components/popups/provider/components/SearchProviders.jsx +122 -0
- package/src/components/popups/provider/components/Seeds.jsx +34 -0
- package/src/components/popups/provider/components/Solid.jsx +34 -0
- package/src/components/popups/provider/components/SqlLite.jsx +34 -0
- package/src/components/popups/provider/components/ThreeFold.jsx +34 -0
- package/src/components/popups/provider/components/ViewProviderStats.jsx +123 -0
- package/src/components/popups/provider/components/ViewProviders.jsx +121 -0
- package/src/components/popups/provider/index.jsx +113 -0
- package/src/components/popups/quest/components/ManageQuest.jsx +34 -0
- package/src/components/popups/quest/components/SearchQuest.jsx +34 -0
- package/src/components/popups/quest/components/ViewQuest.jsx +34 -0
- package/src/components/popups/quest/index.jsx +32 -0
- package/src/components/popups/seeds/components/AcceptInvite.jsx +61 -0
- package/src/components/popups/seeds/components/DonateSeeds.jsx +178 -0
- package/src/components/popups/seeds/components/ManageSeeds.jsx +34 -0
- package/src/components/popups/seeds/components/PayWithSeeds.jsx +233 -0
- package/src/components/popups/seeds/components/RewardSeeds.jsx +178 -0
- package/src/components/popups/seeds/components/SearchSeeds.jsx +91 -0
- package/src/components/popups/seeds/components/SendInvite.jsx +178 -0
- package/src/components/popups/seeds/components/ViewOrganizations.jsx +178 -0
- package/src/components/popups/seeds/components/ViewSeeds.jsx +221 -0
- package/src/components/popups/seeds/index.jsx +70 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { toast } from "react-toastify";
|
|
4
|
+
|
|
5
|
+
import { Modal } from 'react-bootstrap';
|
|
6
|
+
import Loader from 'react-loader-spinner';
|
|
7
|
+
import { Formik } from "formik";
|
|
8
|
+
import * as Yup from "yup";
|
|
9
|
+
import oasisApi from "oasis-api";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export default class ForgetPassword extends React.Component {
|
|
13
|
+
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
|
|
17
|
+
this.state = {
|
|
18
|
+
email: '',
|
|
19
|
+
loading: false,
|
|
20
|
+
user: null
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
initialValues = {
|
|
25
|
+
email: ''
|
|
26
|
+
}
|
|
27
|
+
validationSchema = Yup.object().shape({
|
|
28
|
+
email: Yup.string()
|
|
29
|
+
.email('Email is invalid')
|
|
30
|
+
.required("Email is required")
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
handleForgetPassword = () => {
|
|
34
|
+
let data = {
|
|
35
|
+
email: this.state.email
|
|
36
|
+
}
|
|
37
|
+
this.setState({ loading: true })
|
|
38
|
+
|
|
39
|
+
const auth = new oasisApi.Auth();
|
|
40
|
+
auth.forgotPassword(data)
|
|
41
|
+
.then(response => {
|
|
42
|
+
this.setState({ loading: false })
|
|
43
|
+
|
|
44
|
+
if (response?.data?.result.isError) {
|
|
45
|
+
toast.error(response.data.result.message);
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
toast.success(response?.data?.result.message);
|
|
50
|
+
this.props.hide();
|
|
51
|
+
})
|
|
52
|
+
.catch(error => {
|
|
53
|
+
toast.error(error.data.result.message);
|
|
54
|
+
this.setState({ loading: false })
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
const { loading } = this.state;
|
|
60
|
+
const { show, hide } = this.props;
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
<Formik
|
|
65
|
+
initialValues={this.initialValues}
|
|
66
|
+
validationSchema={this.validationSchema}
|
|
67
|
+
onSubmit={(values, { setSubmitting, resetForm }) => {
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
this.setState({
|
|
70
|
+
email: values.email
|
|
71
|
+
});
|
|
72
|
+
this.handleForgetPassword();
|
|
73
|
+
|
|
74
|
+
setSubmitting(true);
|
|
75
|
+
// resetForm();
|
|
76
|
+
setSubmitting(false);
|
|
77
|
+
}, 400);
|
|
78
|
+
} }
|
|
79
|
+
>
|
|
80
|
+
{({ values, errors, touched, isSubmitting, handleChange, handleBlur, handleSubmit }) => (
|
|
81
|
+
|
|
82
|
+
<Modal centered className="custom-modal" show={show} onHide={hide}>
|
|
83
|
+
<Modal.Body>
|
|
84
|
+
<span className="form-cross-icon" onClick={hide}>
|
|
85
|
+
<i className="fa fa-times"></i>
|
|
86
|
+
</span>
|
|
87
|
+
|
|
88
|
+
<form className="custom-form" onSubmit={handleSubmit}>
|
|
89
|
+
<div className="form-header">
|
|
90
|
+
<h2>Forget Password?</h2>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div className="form-inputs">
|
|
94
|
+
<div className={this.handleFormFieldClass(errors.email, touched.email)}>
|
|
95
|
+
<label>EMAIL</label>
|
|
96
|
+
<input
|
|
97
|
+
type="email"
|
|
98
|
+
name="email"
|
|
99
|
+
value={values.email}
|
|
100
|
+
onChange={handleChange}
|
|
101
|
+
onBlur={handleBlur}
|
|
102
|
+
disabled={loading}
|
|
103
|
+
placeholder="name@example.com" />
|
|
104
|
+
<span className="text-danger">{errors.email && touched.email && errors.email}</span>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<button type="submit" className="submit-button" disabled={isSubmitting}>
|
|
108
|
+
{loading ? 'Sending Link' : 'Submit '} {loading ? <Loader type="Oval" height={15} width={15} color="#fff" /> : null}
|
|
109
|
+
</button>
|
|
110
|
+
</div>
|
|
111
|
+
</form>
|
|
112
|
+
</Modal.Body>
|
|
113
|
+
</Modal>
|
|
114
|
+
)}
|
|
115
|
+
</Formik>
|
|
116
|
+
</>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
handleFormFieldClass(error, touched) {
|
|
121
|
+
let classes = "single-form-field ";
|
|
122
|
+
classes += (error && touched) ? "has-error" : "";
|
|
123
|
+
|
|
124
|
+
return classes;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import ShowIcon from "../assets/images/visible-icon.svg";
|
|
4
|
+
import HideIcon from "../assets/images/hidden-icon.svg";
|
|
5
|
+
|
|
6
|
+
import ForgetPassword from "./ForgetPassword";
|
|
7
|
+
|
|
8
|
+
import { Modal } from "react-bootstrap";
|
|
9
|
+
import Loader from "react-loader-spinner";
|
|
10
|
+
import { Formik } from "formik";
|
|
11
|
+
import * as Yup from "yup";
|
|
12
|
+
import axios from "axios";
|
|
13
|
+
import { toast } from 'react-toastify';
|
|
14
|
+
import API_BASE_URL from "../config/api";
|
|
15
|
+
|
|
16
|
+
export default class Login extends React.Component {
|
|
17
|
+
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
|
|
21
|
+
this.state = {
|
|
22
|
+
form: {
|
|
23
|
+
username: '',
|
|
24
|
+
password: '',
|
|
25
|
+
},
|
|
26
|
+
showPassword: false,
|
|
27
|
+
showForgetPasswordPopup: false,
|
|
28
|
+
loading: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
componentDidMount = () => {
|
|
33
|
+
console.log("component is mounted")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
initialValues = {
|
|
37
|
+
username: '',
|
|
38
|
+
password: ''
|
|
39
|
+
}
|
|
40
|
+
validationSchema = Yup.object().shape({
|
|
41
|
+
username: Yup.string()
|
|
42
|
+
.required("Username is required"),
|
|
43
|
+
password: Yup.string()
|
|
44
|
+
.required("No password provided.")
|
|
45
|
+
.min(8, "Password is too short - should be 8 characters minimum.")
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
handleLogin = () => {
|
|
49
|
+
this.setState({ loading: true })
|
|
50
|
+
|
|
51
|
+
let data = {
|
|
52
|
+
"providerType": "provider",
|
|
53
|
+
"setGlobally": true,
|
|
54
|
+
"autoFailOverMode": "default",
|
|
55
|
+
"autoReplicationMode": "default",
|
|
56
|
+
"autoLoadBalanceMode": "default",
|
|
57
|
+
"autoFailOverProviders": "default",
|
|
58
|
+
"autoReplicationProviders": "default",
|
|
59
|
+
"autoLoadBalanceProviders": "default",
|
|
60
|
+
"waitForAutoReplicationResult": true,
|
|
61
|
+
"showDetailedSettings": true,
|
|
62
|
+
...this.state.form
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
axios({
|
|
66
|
+
method: 'post',
|
|
67
|
+
url: `${API_BASE_URL}/avatar/authenticate/`,
|
|
68
|
+
data: data, // you are sending body instead
|
|
69
|
+
headers: {
|
|
70
|
+
'Content-Type': 'application/json'
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
.then((response) => {
|
|
74
|
+
this.setState({loading: false})
|
|
75
|
+
|
|
76
|
+
if (response.data.result?.isError) {
|
|
77
|
+
toast.error(response.data.result.message);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const data = response.data.result.result;
|
|
82
|
+
localStorage.clear();
|
|
83
|
+
|
|
84
|
+
toast.success(response.data.result.message);
|
|
85
|
+
this.setState({user: response.data.result})
|
|
86
|
+
|
|
87
|
+
this.props.setUserStateData(data);
|
|
88
|
+
this.props.hide();
|
|
89
|
+
})
|
|
90
|
+
.catch((err) => {
|
|
91
|
+
toast.error('err');
|
|
92
|
+
this.setState({loading: false})
|
|
93
|
+
return { error: true, data: err };
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
showForgetPasswordPopup = (hideLogin) => {
|
|
98
|
+
this.setState({
|
|
99
|
+
showForgetPasswordPopup: true
|
|
100
|
+
});
|
|
101
|
+
hideLogin();
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
hideForgetPasswordPopup = () => {
|
|
105
|
+
this.setState({
|
|
106
|
+
showForgetPasswordPopup: false
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
render() {
|
|
111
|
+
const { showPassword, loading } = this.state;
|
|
112
|
+
const { show, hide, change } = this.props;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<>
|
|
116
|
+
|
|
117
|
+
<Formik
|
|
118
|
+
initialValues={this.initialValues}
|
|
119
|
+
validationSchema={this.validationSchema}
|
|
120
|
+
onSubmit={(values, { setSubmitting, resetForm }) => {
|
|
121
|
+
setTimeout(() => {
|
|
122
|
+
console.log(values);
|
|
123
|
+
let form = values;
|
|
124
|
+
this.setState({form});
|
|
125
|
+
this.handleLogin();
|
|
126
|
+
|
|
127
|
+
setSubmitting(true);
|
|
128
|
+
// resetForm();
|
|
129
|
+
setSubmitting(false);
|
|
130
|
+
}, 400);
|
|
131
|
+
} }
|
|
132
|
+
>
|
|
133
|
+
{({ values, errors, touched, isSubmitting, handleChange, handleBlur, handleSubmit }) => (
|
|
134
|
+
|
|
135
|
+
<Modal centered className="custom-modal" show={show} onHide={hide}>
|
|
136
|
+
<Modal.Body>
|
|
137
|
+
<span className="form-cross-icon" onClick={hide}>
|
|
138
|
+
<i className="fa fa-times"></i>
|
|
139
|
+
</span>
|
|
140
|
+
|
|
141
|
+
<form className="custom-form" onSubmit={handleSubmit}>
|
|
142
|
+
<div className="form-header">
|
|
143
|
+
<h2>Beam In</h2>
|
|
144
|
+
|
|
145
|
+
<p>
|
|
146
|
+
Don't have an account?
|
|
147
|
+
<span className="text-link" onClick={change}> Sign Up!</span>
|
|
148
|
+
</p>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div className="form-inputs">
|
|
152
|
+
<div className={this.handleFormFieldClass(errors.username, touched.username)}>
|
|
153
|
+
<label>USERNAME</label>
|
|
154
|
+
<input
|
|
155
|
+
type="email"
|
|
156
|
+
name="username"
|
|
157
|
+
value={values.username}
|
|
158
|
+
onChange={handleChange}
|
|
159
|
+
onBlur={handleBlur}
|
|
160
|
+
disabled={loading}
|
|
161
|
+
placeholder="name@example.com" />
|
|
162
|
+
<span className="text-danger">{errors.username && touched.username && errors.username}</span>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<div className={this.handleFormFieldClass(errors.password, touched.password)}>
|
|
166
|
+
<label>PASSWORD</label>
|
|
167
|
+
<div className="have-icon">
|
|
168
|
+
<input
|
|
169
|
+
type={`${showPassword ? "text" : "password"}`}
|
|
170
|
+
name="password"
|
|
171
|
+
value={values.password}
|
|
172
|
+
onChange={handleChange}
|
|
173
|
+
onBlur={handleBlur}
|
|
174
|
+
disabled={loading}
|
|
175
|
+
placeholder="password" />
|
|
176
|
+
<img
|
|
177
|
+
className="field-icon"
|
|
178
|
+
onClick={() => this.setState({ showPassword: !showPassword })}
|
|
179
|
+
src={showPassword ? ShowIcon : HideIcon}
|
|
180
|
+
alt="icon" />
|
|
181
|
+
</div>
|
|
182
|
+
<span className="text-danger">{errors.password && touched.password && errors.password}</span>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div className="forgot-password">
|
|
186
|
+
<label className="text-link" onClick={() => this.showForgetPasswordPopup(hide)}>Forgot Password?</label>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div className="remember-me">
|
|
190
|
+
<label>
|
|
191
|
+
<input type="checkbox" name="remember-login" id="remember-login" />
|
|
192
|
+
Remember me
|
|
193
|
+
</label>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<button type="submit" className="submit-button" disabled={isSubmitting}>
|
|
197
|
+
{loading ? 'Beaming in ' : 'Submit '} {loading ? <Loader type="Oval" height={15} width={15} color="#fff" /> : null}
|
|
198
|
+
</button>
|
|
199
|
+
</div>
|
|
200
|
+
</form>
|
|
201
|
+
</Modal.Body>
|
|
202
|
+
</Modal>
|
|
203
|
+
)}
|
|
204
|
+
</Formik>
|
|
205
|
+
|
|
206
|
+
<ForgetPassword
|
|
207
|
+
className="custom-form"
|
|
208
|
+
show={this.state.showForgetPasswordPopup}
|
|
209
|
+
hide={this.hideForgetPasswordPopup}
|
|
210
|
+
change={this.showForgetPasswordPopup}
|
|
211
|
+
/>
|
|
212
|
+
</>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
handleFormFieldClass(error, touched) {
|
|
217
|
+
let classes = "single-form-field ";
|
|
218
|
+
classes += (error && touched) ? "has-error" : "";
|
|
219
|
+
|
|
220
|
+
return classes;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { toast } from "react-toastify";
|
|
4
|
+
|
|
5
|
+
import { Modal } from 'react-bootstrap';
|
|
6
|
+
import Loader from 'react-loader-spinner';
|
|
7
|
+
import { Formik } from "formik";
|
|
8
|
+
import * as Yup from "yup";
|
|
9
|
+
import axios from 'axios';
|
|
10
|
+
import API_BASE_URL from "../config/api";
|
|
11
|
+
|
|
12
|
+
// import { Link, withRouter } from "react-router-dom";
|
|
13
|
+
import { withRouter } from "react-router-dom";
|
|
14
|
+
|
|
15
|
+
class ResetPassword extends React.Component {
|
|
16
|
+
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props);
|
|
19
|
+
|
|
20
|
+
this.state = {
|
|
21
|
+
show: false,
|
|
22
|
+
form: {
|
|
23
|
+
token: '',
|
|
24
|
+
password: '',
|
|
25
|
+
confirmPassword: ''
|
|
26
|
+
},
|
|
27
|
+
showPassword: false,
|
|
28
|
+
loading: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
validationSchema = Yup.object().shape({
|
|
33
|
+
token: Yup.string()
|
|
34
|
+
.required("Token is required"),
|
|
35
|
+
password: Yup.string()
|
|
36
|
+
.required("Password is required.")
|
|
37
|
+
.min(8, "Password is too short - should be 8 characters minimum."),
|
|
38
|
+
confirmPassword: Yup.string()
|
|
39
|
+
.required("Confirm Password is required.")
|
|
40
|
+
.min(8, "Password is too short - should be 8 characters minimum.")
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
componentDidMount() {
|
|
44
|
+
this.setState({
|
|
45
|
+
show: true
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
hidePopup = () => {
|
|
50
|
+
this.setState({
|
|
51
|
+
show: false
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
handleResetPassword = () => {
|
|
56
|
+
if (this.state.form.password === this.state.form.confirmPassword) {
|
|
57
|
+
let data = {
|
|
58
|
+
token: this.state.form.token, // use token from form state
|
|
59
|
+
NewPassword: this.state.form.password,
|
|
60
|
+
ConfirmNewPassword: this.state.form.confirmPassword
|
|
61
|
+
}
|
|
62
|
+
this.setState({ loading: true })
|
|
63
|
+
|
|
64
|
+
axios.post(`${API_BASE_URL}/Avatar/reset-password`, data)
|
|
65
|
+
.then(response => {
|
|
66
|
+
this.setState({loading: false});
|
|
67
|
+
|
|
68
|
+
if(response.data.result?.isError) {
|
|
69
|
+
toast.error(response.data.result.message);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this.props.history.push('/');
|
|
74
|
+
|
|
75
|
+
toast.success(response?.data?.result.message);
|
|
76
|
+
})
|
|
77
|
+
.catch(error => {
|
|
78
|
+
this.setState({
|
|
79
|
+
loading: false,
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
toast.error("Password and Confirm password should be same.")
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
render() {
|
|
89
|
+
const searchParams = new URLSearchParams(this.props.location.search);
|
|
90
|
+
const token = searchParams.get('token');
|
|
91
|
+
|
|
92
|
+
const initialValues = {
|
|
93
|
+
token: token || '',
|
|
94
|
+
password: '',
|
|
95
|
+
confirmPassword: ''
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<>
|
|
100
|
+
<Formik
|
|
101
|
+
initialValues={initialValues}
|
|
102
|
+
validationSchema={this.validationSchema}
|
|
103
|
+
onSubmit={(values, { setSubmitting, resetForm }) => {
|
|
104
|
+
setTimeout(() => {
|
|
105
|
+
let form = values;
|
|
106
|
+
this.setState({form});
|
|
107
|
+
this.handleResetPassword();
|
|
108
|
+
|
|
109
|
+
setSubmitting(true);
|
|
110
|
+
// resetForm();
|
|
111
|
+
setSubmitting(false);
|
|
112
|
+
}, 400);
|
|
113
|
+
} }
|
|
114
|
+
>
|
|
115
|
+
{({ values, errors, touched, isSubmitting, handleChange, handleBlur, handleSubmit }) => (
|
|
116
|
+
|
|
117
|
+
<Modal centered className="custom-modal" show={this.state.show} onHide={() => this.hidePopup()}>
|
|
118
|
+
<Modal.Body>
|
|
119
|
+
<span className="form-cross-icon" onClick={() => this.hidePopup()}>
|
|
120
|
+
<i className="fa fa-times"></i>
|
|
121
|
+
</span>
|
|
122
|
+
|
|
123
|
+
<form className="custom-form" onSubmit={handleSubmit}>
|
|
124
|
+
<div className="form-header">
|
|
125
|
+
<h2>Reset Password</h2>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<div className="form-inputs">
|
|
129
|
+
<div className={this.handleFormFieldClass(errors.password, touched.password)}>
|
|
130
|
+
<label>Password</label>
|
|
131
|
+
<input
|
|
132
|
+
type="password"
|
|
133
|
+
name="password"
|
|
134
|
+
value={values.password}
|
|
135
|
+
onChange={handleChange}
|
|
136
|
+
onBlur={handleBlur}
|
|
137
|
+
disabled={this.state.loading}
|
|
138
|
+
placeholder="Password" />
|
|
139
|
+
<span className="text-danger">{errors.password && touched.password && errors.password}</span>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<div className={this.handleFormFieldClass(errors.confirmPassword, touched.confirmPassword)}>
|
|
143
|
+
<label>Confirm Password</label>
|
|
144
|
+
<input
|
|
145
|
+
type="password"
|
|
146
|
+
name="confirmPassword"
|
|
147
|
+
value={values.confirmPassword}
|
|
148
|
+
onChange={handleChange}
|
|
149
|
+
onBlur={handleBlur}
|
|
150
|
+
disabled={this.state.loading}
|
|
151
|
+
placeholder="Confirm Password" />
|
|
152
|
+
<span className="text-danger">{errors.confirmPassword && touched.confirmPassword && errors.confirmPassword}</span>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<button type="submit" className="submit-button" disabled={isSubmitting}>
|
|
156
|
+
Reset {this.state.loading ? <Loader type="Oval" height={15} width={15} color="#fff" /> : null}
|
|
157
|
+
</button>
|
|
158
|
+
</div>
|
|
159
|
+
</form>
|
|
160
|
+
</Modal.Body>
|
|
161
|
+
</Modal>
|
|
162
|
+
)}
|
|
163
|
+
</Formik>
|
|
164
|
+
</>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
handleFormFieldClass(error, touched) {
|
|
169
|
+
let classes = "single-form-field ";
|
|
170
|
+
classes += (error && touched) ? "has-error" : "";
|
|
171
|
+
|
|
172
|
+
return classes;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export default withRouter(ResetPassword);
|