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>
<meta charset="utf-8" /> <head>
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="theme-color" content="#000000" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta <meta name="theme-color" content="#000000" />
name="description" <meta name="description" content="Web site created using create-react-app" />
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
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
--> -->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!-- <!--
Notice the use of %PUBLIC_URL% in the tags above. Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build. It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML. Only files inside the `public` folder can be referenced from the HTML.
...@@ -24,12 +22,16 @@ ...@@ -24,12 +22,16 @@
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`.
--> -->
<title>React App</title> <!-- line sdk -->
</head> <script src="https://static.line-scdn.net/liff/edge/2.1/liff.js"></script>
<body> <!-- line sdk -->
<noscript>You need to enable JavaScript to run this app.</noscript> <title>React App</title>
<div id="root"></div> </head>
<!--
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template. This HTML file is a template.
If you open it directly in the browser, you will see an empty page. If you open it directly in the browser, you will see an empty page.
...@@ -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() {
return ( // const [pictureUrl, setPictureUrl] = useState(logo)
<div> // eslint-disable-next-line no-unused-vars
<p>Login</p> const [idToken, setIdToken] = useState("");
</div> // 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 (
<Fragment></Fragment>
);
} }
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