Commit 749a6447 authored by chaiwat's avatar chaiwat

Add dashboard

parent 3294b268
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@line/liff": "^2.17.0",
"@testing-library/jest-dom": "^5.11.4", "@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0", "@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10", "@testing-library/user-event": "^12.1.10",
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
<meta <meta name="description" content="Web site created using create-react-app" />
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!-- <!--
manifest.json provides metadata used when your web app is installed on a manifest.json provides metadata used when your web app is installed on a
...@@ -24,9 +22,13 @@ ...@@ -24,9 +22,13 @@
work correctly both with client-side routing and a non-root public URL. work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`. Learn how to configure a non-root public URL by running `npm run build`.
--> -->
<!-- line sdk -->
<script src="https://static.line-scdn.net/liff/edge/2.1/liff.js"></script>
<!-- line sdk -->
<title>React App</title> <title>React App</title>
</head> </head>
<body>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div> <div id="root"></div>
<!-- <!--
...@@ -39,5 +41,6 @@ ...@@ -39,5 +41,6 @@
To begin the development, run `npm start` or `yarn start`. To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`. To create a production bundle, use `npm run build` or `yarn build`.
--> -->
</body> </body>
</html> </html>
\ No newline at end of file
import { lazy } from 'react'
const PagesRoutes = [
// Dashboard
{
path: '/Dashboard',
component: lazy(() => import('../../view/Dashboards/ecommerce')),
layout: 'VerticalLayout',
}
]
export default PagesRoutes
\ No newline at end of file
// Routes Imports
import Pages from "./Pages";
// Merge Routes
const Routes = [...Pages];
export { Routes };
\ No newline at end of file
import React from 'react'
export default function Ecommerce() {
return (
<div>
<h3>สวัสดี, Fariw 👋</h3>
</div>
)
}
\ No newline at end of file
import liff from "@line/liff";
import { Fragment, useEffect, useState } from "react";
function App() { function App() {
// const [pictureUrl, setPictureUrl] = useState(logo)
// eslint-disable-next-line no-unused-vars
const [idToken, setIdToken] = useState("");
// const [displayName, setDisplayName] = useState('')
// const [statusMessage, setStatusMessage] = useState('')
// const [userId, setUserId] = useState('')
// const logout = () => {
// liff.logout()
// window.location.reload()
// }
const initLine = () => {
liff.init(
{ liffId: "1656654849-0gQezROW" },
() => {
if (liff.isLoggedIn()) {
runApp();
} else {
liff.login();
}
},
(err) => console.error(err)
);
};
const runApp = () => {
const idToken = liff.getIDToken();
setIdToken(idToken);
liff
.getProfile()
.then((profile) => {
console.log(profile)
setTimeout(() => {
window.location.href = '/Dashboard'
}, 3000);
})
.catch((err) => console.error(err));
};
useEffect(() => {
initLine();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return ( return (
<div> <Fragment></Fragment>
<p>Login</p> );
</div>
)
} }
export default App export default App;
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment