| @@ -3,6 +3,9 @@ import * as React from "react"; | |||
| import * as HttpUtils from "utils/HttpUtils"; | |||
| import * as UrlUtils from "utils/ApiPathConst"; | |||
| import { useNavigate } from "react-router-dom"; | |||
| import { useDispatch } from "react-redux"; | |||
| import { handleLogoutFunction, handleLogin } from 'auth/index'; | |||
| import Loadable from 'components/Loadable'; | |||
| const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | |||
| @@ -11,6 +14,7 @@ const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/Loa | |||
| const Index = () => { | |||
| const dispatch = useDispatch() | |||
| const navigate = useNavigate() | |||
| React.useEffect(() => { | |||
| @@ -18,6 +22,8 @@ const Index = () => { | |||
| }, []); | |||
| function getPrfile(){ | |||
| dispatch(handleLogoutFunction()); | |||
| let params = new URLSearchParams(window.location.search) | |||
| if(params.get("code")){ | |||
| HttpUtils.post({ | |||
| @@ -26,15 +32,38 @@ const Index = () => { | |||
| code: params.get("code") | |||
| }, | |||
| onSuccess: (responseData) => { | |||
| navigate('/iAmSmartRegisterFrom', { state: { responseData: responseData } }); | |||
| //navigate('/iAmSmartRegisterFrom', { state: { responseData: responseData } }); | |||
| console.log(response) | |||
| const userData = { | |||
| id: responseData.id, | |||
| fullenName: responseData.name, | |||
| fullchName: responseData.chName, | |||
| email: responseData.email, | |||
| type: responseData.type, | |||
| role: responseData.role, | |||
| abilities: responseData.abilities, | |||
| creditor: responseData.creditor, | |||
| //avatar: require('src/assets/images/users/avatar-3.png').default, | |||
| } | |||
| const data = { ...userData, accessToken: responseData.accessToken, refreshToken: responseData.refreshToken } | |||
| // setSuccess(true) | |||
| dispatch(handleLogin(data)) | |||
| navigate('/dashboard'); | |||
| location.reload() | |||
| }, | |||
| onFail: ()=>{ | |||
| window.location.assign("/iamsmart/loginFall"); | |||
| }, | |||
| onError:()=>{ | |||
| window.location.assign("/iamsmart/loginFall"); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| return ( | |||
| <LoadingComponent /> | |||
| ); | |||
| @@ -2,28 +2,20 @@ | |||
| import { | |||
| Grid, | |||
| Typography, | |||
| Stack, | |||
| Button | |||
| } from '@mui/material'; | |||
| import * as React from "react"; | |||
| import { useNavigate } from "react-router-dom"; | |||
| import Loadable from 'components/Loadable'; | |||
| const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | |||
| import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | |||
| const BackgroundHead = { | |||
| backgroundImage: `url(${titleBackgroundImg})`, | |||
| width: '100%', | |||
| height: '100%', | |||
| backgroundSize: 'contain', | |||
| backgroundRepeat: 'no-repeat', | |||
| backgroundColor: '#0C489E', | |||
| backgroundPosition: 'right' | |||
| } | |||
| // ==============================|| DASHBOARD - DEFAULT ||============================== // | |||
| const Index = () => { | |||
| const navigate = useNavigate() | |||
| const [onReady, setOnReady] = React.useState(false); | |||
| React.useEffect(() => { | |||
| @@ -34,31 +26,32 @@ const Index = () => { | |||
| !onReady ? | |||
| <LoadingComponent /> | |||
| : | |||
| <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" > | |||
| <Grid item xs={12} width="100%"> | |||
| <div style={BackgroundHead} width="100%"> | |||
| <Stack direction="row" height='70px'> | |||
| <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>iAmSmart 登入失敗</Typography> | |||
| </Stack> | |||
| </div> | |||
| </Grid> | |||
| {/*row 1*/} | |||
| <Grid item xs={12} md={12} > | |||
| <Grid container justifyContent="flex-start" alignItems="center" > | |||
| <center> | |||
| <Grid item xs={12} md={12} > | |||
| <Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}> | |||
| 連接 iAM Smart 時出現錯誤,請重試。 | |||
| </Typography> | |||
| </Grid> | |||
| </center> | |||
| <Grid container sx={{ height: '100%', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" > | |||
| <Grid item xs={12} md={12} > | |||
| <Grid container justifyContent="flex-start" alignItems="center" > | |||
| <center> | |||
| <Grid item xs={12} md={12} > | |||
| <Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}> | |||
| 登入失敗,請重試。 | |||
| </Typography> | |||
| <Button | |||
| component="span" | |||
| variant="contained" | |||
| size="large" | |||
| sx={{ m: 4 }} | |||
| onClick={() => { | |||
| navigate("/login"); | |||
| }} | |||
| >返回登入</Button> | |||
| </Grid> | |||
| </center> | |||
| </Grid> | |||
| </Grid> | |||
| </Grid> | |||
| {/*row 2*/} | |||
| </Grid > | |||
| {/*row 2*/} | |||
| </Grid > | |||
| ); | |||
| }; | |||
| @@ -64,11 +64,11 @@ const LoginRoutes = { | |||
| element: <IAmSmart_RegistryCallback/> | |||
| }, | |||
| { | |||
| path: 'iamsmart/loginfallback', | |||
| path: 'iamsmart/loginFall', | |||
| element: <IAmSmart_FailCallback/> | |||
| }, | |||
| { | |||
| path: 'iamsmart/logincallback', | |||
| path: 'iamsmart/loginSucess', | |||
| element: <IAmSmart_SuccessCallback/> | |||
| }, | |||
| { | |||