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