@springmicro/auth 0.7.0 → 0.7.2
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/.eslintrc.cjs +18 -18
- package/README.md +60 -60
- package/dist/Index-64ac63ff-ChMmeIY7.js +0 -0
- package/dist/Index-6c094240-hn_S7Xeg.js +0 -0
- package/dist/Web3Auth-CGD96zai.js +0 -0
- package/dist/alphawallet-B7eovdf-.js +0 -0
- package/dist/apexwallet-ysP20G9D.js +0 -0
- package/dist/atoken-BBnNTzcz.js +0 -0
- package/dist/bifrostwallet-CNNBO92h.js +0 -0
- package/dist/binance-DvPgAzCw.js +0 -0
- package/dist/bitget-DZOUrwgy.js +0 -0
- package/dist/bitpie-C_uxmEzw.js +0 -0
- package/dist/bitski-DpzkHNkv.js +0 -0
- package/dist/blockwallet-BL69cqkA.js +0 -0
- package/dist/brave-DnRzMQYW.js +0 -0
- package/dist/ccip-c78d2f16-DLcRlwod.js +0 -0
- package/dist/coin98wallet-CkFdOvXt.js +0 -0
- package/dist/coinbase-CaGNx5if.js +0 -0
- package/dist/core-9rK8tWud.js +0 -0
- package/dist/defiwallet-0AsgJBSy.js +0 -0
- package/dist/detected-CX_JZaUk.js +0 -0
- package/dist/echooo-CmaetT_Z.js +0 -0
- package/dist/enkrypt-BibtwvK7.js +0 -0
- package/dist/exodus-BxzkDWWP.js +0 -0
- package/dist/fordefi-CvKyVwhI.js +0 -0
- package/dist/foxwallet-D7c_LDTf.js +0 -0
- package/dist/frame-CDfNmjUy.js +0 -0
- package/dist/frontier-DqKNSj2z.js +0 -0
- package/dist/hashMessage-Bdgmx0rg.js +0 -0
- package/dist/huobiwallet-CxSwqa5L.js +0 -0
- package/dist/hyperpay-nmHE3WqM.js +0 -0
- package/dist/icon-2Zqy7pqQ.js +0 -0
- package/dist/icon-CGWI1Ies.js +0 -0
- package/dist/icon-C_O4nprO.js +0 -0
- package/dist/icon-DbgmZCnU.js +0 -0
- package/dist/icon-Dbjb6jc5.js +0 -0
- package/dist/icon-cAd7RhSC.js +0 -0
- package/dist/imtoken-yENtOTS3.js +0 -0
- package/dist/index-021f6a62-Zz543EDB.js +0 -0
- package/dist/index-40a497ea-Bn2mC0r7.js +0 -0
- package/dist/index-62liFLUM.js +0 -0
- package/dist/index-BBx_mvyX.js +0 -0
- package/dist/index-C6leUA25.js +0 -0
- package/dist/index-CAVvArYp.js +0 -0
- package/dist/index-Ct7cFdFm.js +0 -0
- package/dist/index-DA32_Pfh.js +0 -0
- package/dist/index-Dna0rycp.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/index.umd.cjs +0 -0
- package/dist/infinitywallet-C8J4FUYw.js +0 -0
- package/dist/kayros-AIrUK1za.js +0 -0
- package/dist/keplr-CyLTca9B.js +0 -0
- package/dist/lif3wallet-C5D6r8pg.js +0 -0
- package/dist/liquality-nbCtErVq.js +0 -0
- package/dist/mathwallet-CWkivCXo.js +0 -0
- package/dist/meetone-kKmvI8md.js +0 -0
- package/dist/metamask-BN7yiDV1.js +0 -0
- package/dist/mykey-CQZ6UcLH.js +0 -0
- package/dist/native-FDN9oNjc.js +0 -0
- package/dist/number-C-98SESp.js +0 -0
- package/dist/okxwallet-CJLVogh2.js +0 -0
- package/dist/oneInch-CciyZ4Pz.js +0 -0
- package/dist/onekey-Dal8kYjU.js +0 -0
- package/dist/opera-DnKg-TJU.js +0 -0
- package/dist/ownbit-BshJUVuW.js +0 -0
- package/dist/phantom-CJ8dIcov.js +0 -0
- package/dist/rabby-D4thTcd6.js +0 -0
- package/dist/rainbow-mXld6yWV.js +0 -0
- package/dist/roninwallet-ZyYrd-D1.js +0 -0
- package/dist/safeheron-Eg1Jb29V.js +0 -0
- package/dist/safepal-DVIKy94N.js +0 -0
- package/dist/sequence-BS2IbtDg.js +0 -0
- package/dist/stablewallet-jyB079Wb.js +0 -0
- package/dist/status-FrAvQjfn.js +0 -0
- package/dist/subwallet-DMvFqKyY.js +0 -0
- package/dist/talisman-Bp8zUXqB.js +0 -0
- package/dist/tallywallet-B4OS9nIr.js +0 -0
- package/dist/tokenary-C7jjcbQa.js +0 -0
- package/dist/tokenpocket-9ZRPmAFA.js +0 -0
- package/dist/tp-V2em5bdl.js +0 -0
- package/dist/transactionRequest-be6a8ea9-CUKWo5mx.js +0 -0
- package/dist/trust-SgHubMq7.js +0 -0
- package/dist/xdefi-COVIyGz4.js +0 -0
- package/dist/zeal-DxHbDqm0.js +0 -0
- package/dist/zerion-BfW0UElc.js +0 -0
- package/dist/zodiacpilot-CrId6F4w.js +0 -0
- package/index.html +13 -13
- package/package.json +2 -2
- package/springmicro-auth-0.6.1.tgz +0 -0
- package/src/auth/config.ts +0 -0
- package/src/components/SignUp.tsx +0 -0
- package/src/components/forms/AgreementModal.tsx +88 -88
- package/src/components/forms/CaptchaController.tsx +94 -94
- package/src/components/forms/CaptchaModal.jsx +171 -171
- package/src/components/forms/CaptchaWidget.jsx +146 -146
- package/src/components/forms/PasswordChecker.ts +88 -88
- package/src/components/forms/SendCodeInput.tsx +0 -0
- package/src/components/forms/SignUpFormItem.tsx +0 -0
- package/src/components/forms/util/application-api.ts +0 -0
- package/src/components/forms/util/auth-api.ts +198 -198
- package/src/components/forms/util/auth-util.tsx +346 -346
- package/src/components/forms/util/core.ts +493 -493
- package/src/components/forms/util/invitation-api.ts +132 -132
- package/src/components/forms/util/provider.tsx +603 -603
- package/src/components/forms/util/user-api.ts +0 -0
- package/src/components/provider/AdfsLoginButton.jsx +38 -38
- package/src/components/provider/AlipayLoginButton.jsx +38 -38
- package/src/components/provider/AppleLoginButton.jsx +38 -38
- package/src/components/provider/AzureADB2CLoginButton.jsx +38 -38
- package/src/components/provider/AzureADLoginButton.jsx +38 -38
- package/src/components/provider/BaiduLoginButton.jsx +38 -38
- package/src/components/provider/BilibiliLoginButton.jsx +37 -37
- package/src/components/provider/CasdoorLoginButton.jsx +38 -38
- package/src/components/provider/DingTalkLoginButton.jsx +37 -37
- package/src/components/provider/DouyinLoginButton.jsx +38 -38
- package/src/components/provider/FacebookLoginButton.jsx +37 -37
- package/src/components/provider/GitHubLoginButton.jsx +37 -37
- package/src/components/provider/GitLabLoginButton.jsx +38 -38
- package/src/components/provider/GiteeLoginButton.jsx +34 -34
- package/src/components/provider/GoogleLoginButton.jsx +68 -68
- package/src/components/provider/InfoflowLoginButton.jsx +38 -38
- package/src/components/provider/LarkLoginButton.jsx +38 -38
- package/src/components/provider/LinkedInLoginButton.jsx +37 -37
- package/src/components/provider/LoginButton.jsx +33 -33
- package/src/components/provider/OktaLoginButton.jsx +38 -38
- package/src/components/provider/Provider.jsx +3 -3
- package/src/components/provider/ProviderButton.jsx +327 -327
- package/src/components/provider/QqLoginButton.jsx +31 -31
- package/src/components/provider/SelfLoginButton.jsx +47 -47
- package/src/components/provider/SlackLoginButton.jsx +38 -38
- package/src/components/provider/SteamLoginButton.jsx +38 -38
- package/src/components/provider/WeComLoginButton.jsx +34 -34
- package/src/components/provider/Web3Auth.jsx +365 -365
- package/src/components/provider/WechatLoginButton.jsx +37 -37
- package/src/components/provider/WeiboLoginButton.jsx +34 -34
- package/src/components/util.tsx +0 -0
- package/src/i18n/en/signup.json +48 -48
- package/src/i18n/index.ts +17 -17
- package/src/index.tsx +0 -0
- package/src/vite-env.d.ts +1 -1
- package/tsconfig.json +23 -23
- package/tsconfig.node.json +10 -10
- package/vite.config.ts +33 -33
package/.eslintrc.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: { browser: true, es2020: true },
|
|
4
|
-
extends: [
|
|
5
|
-
'eslint:recommended',
|
|
6
|
-
'plugin:@typescript-eslint/recommended',
|
|
7
|
-
'plugin:react-hooks/recommended',
|
|
8
|
-
],
|
|
9
|
-
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
10
|
-
parser: '@typescript-eslint/parser',
|
|
11
|
-
plugins: ['react-refresh'],
|
|
12
|
-
rules: {
|
|
13
|
-
'react-refresh/only-export-components': [
|
|
14
|
-
'warn',
|
|
15
|
-
{ allowConstantExport: true },
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'plugin:react-hooks/recommended',
|
|
8
|
+
],
|
|
9
|
+
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
plugins: ['react-refresh'],
|
|
12
|
+
rules: {
|
|
13
|
+
'react-refresh/only-export-components': [
|
|
14
|
+
'warn',
|
|
15
|
+
{ allowConstantExport: true },
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
}
|
package/README.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# @springmicro/auth
|
|
2
|
-
|
|
3
|
-
Auth config supplied for connecting with a Casdoor instance. Uses [auth-astro](https://github.com/nowaythatworked/auth-astro).
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm i -g @springmicro/cli
|
|
9
|
-
springmicro add auth
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
```ts
|
|
13
|
-
// auth.config.ts
|
|
14
|
-
|
|
15
|
-
import { getAuthConfig } from "@springmicro/auth";
|
|
16
|
-
|
|
17
|
-
export default getAuthConfig({
|
|
18
|
-
casdoorEndpoint: import.meta.env.PUBLIC_CASDOOR_ENDPOINT,
|
|
19
|
-
clientId: import.meta.env.PUBLIC_CASDOOR_CLIENT_ID,
|
|
20
|
-
clientSecret: import.meta.env.CASDOOR_CLIENT_SECRET,
|
|
21
|
-
});
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
`auth-astro` requires building your site in `server` mode with a platform adapter like `@astrojs/node`.
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
pnpm run astro add node
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
```js
|
|
31
|
-
// astro.config.mjs
|
|
32
|
-
export default defineConfig({
|
|
33
|
-
output: "server",
|
|
34
|
-
adapter: node({
|
|
35
|
-
mode: "standalone",
|
|
36
|
-
}),
|
|
37
|
-
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Casdoor
|
|
41
|
-
|
|
42
|
-
In the `application` settings, add the callback URL of `http://yourhost/callback`. Enable auto signin (optional).
|
|
43
|
-
|
|
44
|
-
## Development
|
|
45
|
-
|
|
46
|
-
### Build
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
pnpm run build
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Install in repo (locally)
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# testing it out in a demo project
|
|
56
|
-
cd astro-demo-project
|
|
57
|
-
pnpm run astro add react
|
|
58
|
-
pnpm run astro add auth-astro
|
|
59
|
-
pnpm add --workspace @springmicro/auth
|
|
60
|
-
```
|
|
1
|
+
# @springmicro/auth
|
|
2
|
+
|
|
3
|
+
Auth config supplied for connecting with a Casdoor instance. Uses [auth-astro](https://github.com/nowaythatworked/auth-astro).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g @springmicro/cli
|
|
9
|
+
springmicro add auth
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
// auth.config.ts
|
|
14
|
+
|
|
15
|
+
import { getAuthConfig } from "@springmicro/auth";
|
|
16
|
+
|
|
17
|
+
export default getAuthConfig({
|
|
18
|
+
casdoorEndpoint: import.meta.env.PUBLIC_CASDOOR_ENDPOINT,
|
|
19
|
+
clientId: import.meta.env.PUBLIC_CASDOOR_CLIENT_ID,
|
|
20
|
+
clientSecret: import.meta.env.CASDOOR_CLIENT_SECRET,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`auth-astro` requires building your site in `server` mode with a platform adapter like `@astrojs/node`.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm run astro add node
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
// astro.config.mjs
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
output: "server",
|
|
34
|
+
adapter: node({
|
|
35
|
+
mode: "standalone",
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Casdoor
|
|
41
|
+
|
|
42
|
+
In the `application` settings, add the callback URL of `http://yourhost/callback`. Enable auto signin (optional).
|
|
43
|
+
|
|
44
|
+
## Development
|
|
45
|
+
|
|
46
|
+
### Build
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm run build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Install in repo (locally)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# testing it out in a demo project
|
|
56
|
+
cd astro-demo-project
|
|
57
|
+
pnpm run astro add react
|
|
58
|
+
pnpm run astro add auth-astro
|
|
59
|
+
pnpm add --workspace @springmicro/auth
|
|
60
|
+
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/atoken-BBnNTzcz.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/binance-DvPgAzCw.js
CHANGED
|
File without changes
|
package/dist/bitget-DZOUrwgy.js
CHANGED
|
File without changes
|
package/dist/bitpie-C_uxmEzw.js
CHANGED
|
File without changes
|
package/dist/bitski-DpzkHNkv.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/brave-DnRzMQYW.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/core-9rK8tWud.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/echooo-CmaetT_Z.js
CHANGED
|
File without changes
|
package/dist/enkrypt-BibtwvK7.js
CHANGED
|
File without changes
|
package/dist/exodus-BxzkDWWP.js
CHANGED
|
File without changes
|
package/dist/fordefi-CvKyVwhI.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/frame-CDfNmjUy.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/icon-2Zqy7pqQ.js
CHANGED
|
File without changes
|
package/dist/icon-CGWI1Ies.js
CHANGED
|
File without changes
|
package/dist/icon-C_O4nprO.js
CHANGED
|
File without changes
|
package/dist/icon-DbgmZCnU.js
CHANGED
|
File without changes
|
package/dist/icon-Dbjb6jc5.js
CHANGED
|
File without changes
|
package/dist/icon-cAd7RhSC.js
CHANGED
|
File without changes
|
package/dist/imtoken-yENtOTS3.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index-62liFLUM.js
CHANGED
|
File without changes
|
package/dist/index-BBx_mvyX.js
CHANGED
|
File without changes
|
package/dist/index-C6leUA25.js
CHANGED
|
File without changes
|
package/dist/index-CAVvArYp.js
CHANGED
|
File without changes
|
package/dist/index-Ct7cFdFm.js
CHANGED
|
File without changes
|
package/dist/index-DA32_Pfh.js
CHANGED
|
File without changes
|
package/dist/index-Dna0rycp.js
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/index.umd.cjs
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/kayros-AIrUK1za.js
CHANGED
|
File without changes
|
package/dist/keplr-CyLTca9B.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/meetone-kKmvI8md.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/mykey-CQZ6UcLH.js
CHANGED
|
File without changes
|
package/dist/native-FDN9oNjc.js
CHANGED
|
File without changes
|
package/dist/number-C-98SESp.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/oneInch-CciyZ4Pz.js
CHANGED
|
File without changes
|
package/dist/onekey-Dal8kYjU.js
CHANGED
|
File without changes
|
package/dist/opera-DnKg-TJU.js
CHANGED
|
File without changes
|
package/dist/ownbit-BshJUVuW.js
CHANGED
|
File without changes
|
package/dist/phantom-CJ8dIcov.js
CHANGED
|
File without changes
|
package/dist/rabby-D4thTcd6.js
CHANGED
|
File without changes
|
package/dist/rainbow-mXld6yWV.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/safepal-DVIKy94N.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/status-FrAvQjfn.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/tp-V2em5bdl.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/trust-SgHubMq7.js
CHANGED
|
File without changes
|
package/dist/xdefi-COVIyGz4.js
CHANGED
|
File without changes
|
package/dist/zeal-DxHbDqm0.js
CHANGED
|
File without changes
|
package/dist/zerion-BfW0UElc.js
CHANGED
|
File without changes
|
|
File without changes
|
package/index.html
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite + React + TS</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"></div>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springmicro/auth",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"react-social-login-buttons": "^4.1.0",
|
|
54
54
|
"uuid": "^9.0.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "baedb0de00a8f238a2356a747e69eb1754606d58"
|
|
57
57
|
}
|
|
Binary file
|
package/src/auth/config.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { SignUpFormState } from "../SignUp";
|
|
3
|
-
import type { Application } from "./util/provider";
|
|
4
|
-
|
|
5
|
-
export type AgreementModalProps = {
|
|
6
|
-
application: Application;
|
|
7
|
-
state: SignUpFormState;
|
|
8
|
-
setState: React.Dispatch<React.SetStateAction<SignUpFormState>>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export function AgreementModal({
|
|
12
|
-
application,
|
|
13
|
-
state,
|
|
14
|
-
setState,
|
|
15
|
-
}: AgreementModalProps) {
|
|
16
|
-
const [visible, setVisible] = React.useState(false);
|
|
17
|
-
const dialogRef = React.useRef<HTMLDialogElement | null>(null);
|
|
18
|
-
|
|
19
|
-
React.useEffect(() => {
|
|
20
|
-
if (!dialogRef.current) {
|
|
21
|
-
dialogRef.current = document.getElementById(
|
|
22
|
-
"agreementDialog"
|
|
23
|
-
) as HTMLDialogElement | null;
|
|
24
|
-
}
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (dialogRef.current) {
|
|
29
|
-
if (visible) {
|
|
30
|
-
dialogRef.current.showModal();
|
|
31
|
-
} else {
|
|
32
|
-
dialogRef.current.close();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, [visible]);
|
|
36
|
-
|
|
37
|
-
const handleCancel = () => {
|
|
38
|
-
setState({ ...state, agreement: false });
|
|
39
|
-
setVisible(false);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const handleOk = () => {
|
|
43
|
-
setState({ ...state, agreement: true });
|
|
44
|
-
setVisible(false);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const handleOpen = () => {
|
|
48
|
-
setVisible(true);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<>
|
|
53
|
-
<dialog id="agreementDialog" className="modal">
|
|
54
|
-
<div className="modal-box">
|
|
55
|
-
<div className="mt-4 mb-8">
|
|
56
|
-
<iframe
|
|
57
|
-
src={application.termsOfUse}
|
|
58
|
-
width="100%"
|
|
59
|
-
height="300px"
|
|
60
|
-
sandbox="allow-scripts"
|
|
61
|
-
/>
|
|
62
|
-
</div>
|
|
63
|
-
<div className="modal-action">
|
|
64
|
-
<form method="dialog" className="modal-backdrop">
|
|
65
|
-
{/* if there is a button in form, it will close the modal */}
|
|
66
|
-
<button>Close</button>
|
|
67
|
-
</form>
|
|
68
|
-
<form method="dialog" className="flex gap-3">
|
|
69
|
-
<button className="btn" onClick={handleCancel} key="closebtn">
|
|
70
|
-
Cancel
|
|
71
|
-
</button>
|
|
72
|
-
<button
|
|
73
|
-
className="btn btn-primary"
|
|
74
|
-
// disabled={isOkDisabled}
|
|
75
|
-
onClick={handleOk}
|
|
76
|
-
key="okbtn"
|
|
77
|
-
>
|
|
78
|
-
OK
|
|
79
|
-
</button>
|
|
80
|
-
</form>
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
</dialog>
|
|
84
|
-
<input checked={!!state.agreement} type="checkbox" readOnly />
|
|
85
|
-
<button onClick={handleOpen}>Open Terms</button>
|
|
86
|
-
</>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { SignUpFormState } from "../SignUp";
|
|
3
|
+
import type { Application } from "./util/provider";
|
|
4
|
+
|
|
5
|
+
export type AgreementModalProps = {
|
|
6
|
+
application: Application;
|
|
7
|
+
state: SignUpFormState;
|
|
8
|
+
setState: React.Dispatch<React.SetStateAction<SignUpFormState>>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function AgreementModal({
|
|
12
|
+
application,
|
|
13
|
+
state,
|
|
14
|
+
setState,
|
|
15
|
+
}: AgreementModalProps) {
|
|
16
|
+
const [visible, setVisible] = React.useState(false);
|
|
17
|
+
const dialogRef = React.useRef<HTMLDialogElement | null>(null);
|
|
18
|
+
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (!dialogRef.current) {
|
|
21
|
+
dialogRef.current = document.getElementById(
|
|
22
|
+
"agreementDialog"
|
|
23
|
+
) as HTMLDialogElement | null;
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (dialogRef.current) {
|
|
29
|
+
if (visible) {
|
|
30
|
+
dialogRef.current.showModal();
|
|
31
|
+
} else {
|
|
32
|
+
dialogRef.current.close();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}, [visible]);
|
|
36
|
+
|
|
37
|
+
const handleCancel = () => {
|
|
38
|
+
setState({ ...state, agreement: false });
|
|
39
|
+
setVisible(false);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleOk = () => {
|
|
43
|
+
setState({ ...state, agreement: true });
|
|
44
|
+
setVisible(false);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const handleOpen = () => {
|
|
48
|
+
setVisible(true);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
<dialog id="agreementDialog" className="modal">
|
|
54
|
+
<div className="modal-box">
|
|
55
|
+
<div className="mt-4 mb-8">
|
|
56
|
+
<iframe
|
|
57
|
+
src={application.termsOfUse}
|
|
58
|
+
width="100%"
|
|
59
|
+
height="300px"
|
|
60
|
+
sandbox="allow-scripts"
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
<div className="modal-action">
|
|
64
|
+
<form method="dialog" className="modal-backdrop">
|
|
65
|
+
{/* if there is a button in form, it will close the modal */}
|
|
66
|
+
<button>Close</button>
|
|
67
|
+
</form>
|
|
68
|
+
<form method="dialog" className="flex gap-3">
|
|
69
|
+
<button className="btn" onClick={handleCancel} key="closebtn">
|
|
70
|
+
Cancel
|
|
71
|
+
</button>
|
|
72
|
+
<button
|
|
73
|
+
className="btn btn-primary"
|
|
74
|
+
// disabled={isOkDisabled}
|
|
75
|
+
onClick={handleOk}
|
|
76
|
+
key="okbtn"
|
|
77
|
+
>
|
|
78
|
+
OK
|
|
79
|
+
</button>
|
|
80
|
+
</form>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</dialog>
|
|
84
|
+
<input checked={!!state.agreement} type="checkbox" readOnly />
|
|
85
|
+
<button onClick={handleOpen}>Open Terms</button>
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
}
|