Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
chore: check get user info
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Jan 19, 2022
1 parent 2340004 commit c6077e0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@mdx-js/react": "^1.6.21",
"@metamask/detect-provider": "^1.2.0",
"antd": "^4.16.13",
"axios": "^0.25.0",
"clsx": "^1.1.1",
"docusaurus-plugin-sass": "^0.2.1",
"raw-loader": "^4.0.2",
Expand Down
43 changes: 36 additions & 7 deletions src/component/ClaimAirdrop/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import clsx from 'clsx';
import styles from './styles.module.scss';
import {
Expand All @@ -17,6 +17,16 @@ import {
ComfirmModalTitleForCcongratulation,
} from './SubComponent';
import { Space } from 'antd';
import axios from 'axios';

const BASE_URL = 'https://crab-docs-fewensa-itering.vercel.app';

const getUserInfo = () => {
return axios.get('/api/user/info', {
timeout: 3000,
baseURL: BASE_URL,
});
};

type Props = {
className?: string;
Expand All @@ -26,17 +36,36 @@ const ClaimAirdrop: React.FC<Props> = ({ className }) => {
const [visibleLoadingModal, setVisibleLoadingModal] = useState(false);
const [visibleComfirmModal, setVisibleComfirmModal] = useState(false);

// const handleClickLoginWithGithub = (e: Event) => {
// e.preventDefault();
// setVisibleComfirmModal(true);
// }
const handleClickLoginWithGithub = (e: Event) => {
e.preventDefault();
// setVisibleComfirmModal(true);
getUserInfo()
.then((res) => {
console.log('user info:', res);
})
.catch((err) => {
console.error('get user info', err);
})
.finally(() => {});
};

useEffect(() => {
getUserInfo()
.then((res) => {
console.log('init user info:', res);
})
.catch((err) => {
console.error('init get user info', err);
})
.finally(() => {});
}, []);

return (
<>
<div className={clsx(className)}>
<a className={clsx(styles.btnLoginWithGihub)} href="/api/connect/github">
<button className={clsx(styles.btnLoginWithGihub)} onClick={handleClickLoginWithGithub}>
<span>Log in with Github</span>
</a>
</button>
</div>
<ComfirmModal
visible={visibleComfirmModal}
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,13 @@ axios@^0.21.1:
dependencies:
follow-redirects "^1.14.0"

axios@^0.25.0:
version "0.25.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.25.0.tgz#349cfbb31331a9b4453190791760a8d35b093e0a"
integrity sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==
dependencies:
follow-redirects "^1.14.7"

babel-loader@^8.2.2:
version "8.2.2"
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.2.2.tgz#9363ce84c10c9a40e6c753748e1441b60c8a0b81"
Expand Down Expand Up @@ -4129,6 +4136,11 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.0:
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==

follow-redirects@^1.14.7:
version "1.14.7"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==

for-in@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
Expand Down

0 comments on commit c6077e0

Please sign in to comment.