diff --git a/ui/src/App.tsx b/ui/src/App.tsx index c6674bd7..3a9e10dd 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -1,36 +1,49 @@ -import React, { useEffect } from 'react'; -import './App.css'; +import React, { useEffect } from "react"; +import "./App.css"; import Home from "./pages/Home"; import Offline from "./pages/Offline"; -import {RouterProvider, createBrowserRouter} from "react-router-dom"; +import { Scan } from "./pages/Scan"; +import { RouterProvider, createBrowserRouter } from "react-router-dom"; import AlertMessage from "./components/commons/AlertMessage"; - import PreloadImages from "./components/commons/PreloadImages"; import OvpRedirect from "./pages/OvpRedirect"; import PageNotFound404 from "./pages/PageNotFound404"; -import {Pages} from "./utils/config"; -import { useAppSelector } from './redux/hooks'; -import { RootState } from './redux/store'; -import { isRTL } from './utils/i18n'; +import { Pages } from "./utils/config"; +import { useAppSelector } from "./redux/hooks"; +import store, { RootState } from "./redux/store"; +import { isRTL } from "./utils/i18n"; +import { VerificationMethod } from "./types/data-types"; +import { goToHomeScreen } from "./redux/features/verification/verification.slice"; + +function switchToVerificationMethod(method: VerificationMethod) { + store.dispatch(goToHomeScreen({ method })); + return null; +} const router = createBrowserRouter([ - { - path: Pages.Home, - element: - }, - { - path: Pages.Redirect, - element: - }, - { - path: Pages.Offline, - element: - }, - { - path: Pages.PageNotFound, - element: - } -]) + { + path: Pages.Home, + element: , + loader: () => switchToVerificationMethod("UPLOAD"), + }, + { + path: Pages.Scan, + element: , + loader: () => switchToVerificationMethod("SCAN"), + }, + { + path: Pages.Redirect, + element: , + }, + { + path: Pages.Offline, + element: , + }, + { + path: Pages.PageNotFound, + element: , + }, +]); const preloadImages = ['/assets/images/under_construction.svg', '/assets/images/inji-logo.svg']; diff --git a/ui/src/components/Home/Header/VerificationMethodTabs/index.tsx b/ui/src/components/Home/Header/VerificationMethodTabs/index.tsx index fded04e1..1a37e247 100644 --- a/ui/src/components/Home/Header/VerificationMethodTabs/index.tsx +++ b/ui/src/components/Home/Header/VerificationMethodTabs/index.tsx @@ -4,10 +4,11 @@ import { useVerificationFlowSelector } from "../../../../redux/features/verifica import { goToHomeScreen } from "../../../../redux/features/verification/verification.slice"; import { VerificationMethod } from "../../../../types/data-types"; import { raiseAlert } from "../../../../redux/features/alerts/alerts.slice"; -import { AlertMessages } from "../../../../utils/config"; +import { AlertMessages, Pages } from "../../../../utils/config"; import { MdArrowForwardIos } from "react-icons/md"; import { MdArrowBackIos } from "react-icons/md"; import { useTranslation } from 'react-i18next'; +import { useNavigate } from "react-router-dom"; const Tab = ({ id, @@ -45,6 +46,7 @@ const Tab = ({ function VerificationMethodTabs(props: any) { const dispatch = useAppDispatch(); + const navigate = useNavigate(); const method = useVerificationFlowSelector((state) => state.method); const {t} = useTranslation('Tab') @@ -93,13 +95,20 @@ function VerificationMethodTabs(props: any) { id="upload-qr-code-tab" active={method === "UPLOAD"} label={t('upload')} - onClick={() => switchToVerificationMethod("UPLOAD")} + onClick={() => { + switchToVerificationMethod("UPLOAD"); + navigate(Pages.Home); + } + } /> switchToVerificationMethod("SCAN")} + onClick={() => { + switchToVerificationMethod("SCAN"); + navigate(Pages.Scan); + }} /> { const {activeScreen, method} = useVerificationFlowSelector(state => ({activeScreen: state.activeScreen, qrData: state.qrReadResult?.qrData, method: state.method})); - + switch (activeScreen) { case VerificationSteps[method].QrCodePrompt: - return (); + return method ==='SCAN' ? : case VerificationSteps[method].ActivateCamera: case VerificationSteps[method].Verifying: return (); diff --git a/ui/src/components/PageTemplate/index.tsx b/ui/src/components/PageTemplate/index.tsx index a42a2b2c..a727ccac 100644 --- a/ui/src/components/PageTemplate/index.tsx +++ b/ui/src/components/PageTemplate/index.tsx @@ -2,11 +2,15 @@ import React from 'react'; import Navbar from "./Navbar"; import Copyrights from "./Copyrights"; import CheckingForInternetConnectivity from "../misc/CheckingForInternetConnectivity"; +import Header from '../Home/Header'; const PageTemplate = (props: any) => { return (
+
+
+
{props.children} diff --git a/ui/src/index.css b/ui/src/index.css index afa6d668..4bbc57ba 100644 --- a/ui/src/index.css +++ b/ui/src/index.css @@ -54,7 +54,6 @@ #7c1389 90%, #5b03ad 100% ); - --iw-color-languageArrowIcon: #951f6f; } [class="purple_theme"] { --iv-font-base: "Gentium Plus", serif; @@ -105,7 +104,6 @@ #7c1389 90%, #5b03ad 100% ); - --iw-color-languageArrowIcon: #0fac8b; } } diff --git a/ui/src/pages/Home.tsx b/ui/src/pages/Home.tsx index 2089e5c7..8c6d941e 100644 --- a/ui/src/pages/Home.tsx +++ b/ui/src/pages/Home.tsx @@ -1,28 +1,23 @@ -import React from 'react'; -import VerificationProgressTracker from "../components/Home/VerificationProgressTracker"; -import VerificationSection from "../components/Home/VerificationSection"; +import React from "react"; import PageTemplate from "../components/PageTemplate"; -import Header from "../components/Home/Header"; +import VerificationSection from "../components/Home/VerificationSection"; +import VerificationProgressTracker from "../components/Home/VerificationProgressTracker"; + + +function Home() { -function Home(props: any) { - return ( - -
-
-
-
-
-
- -
-
- -
-
-
-
- ); + return ( + +
+
+ +
+
+ +
+
+
+ ); } export default Home; diff --git a/ui/src/pages/Scan.tsx b/ui/src/pages/Scan.tsx new file mode 100644 index 00000000..5fec0d13 --- /dev/null +++ b/ui/src/pages/Scan.tsx @@ -0,0 +1,19 @@ +import React from "react"; +import PageTemplate from "../components/PageTemplate"; +import VerificationSection from "../components/Home/VerificationSection"; +import VerificationProgressTracker from "../components/Home/VerificationProgressTracker"; + +export const Scan = () => { + return ( + +
+
+ +
+
+ +
+
+
+ ); +}; diff --git a/ui/src/pages/Upload.tsx b/ui/src/pages/Upload.tsx new file mode 100644 index 00000000..6a6474fc --- /dev/null +++ b/ui/src/pages/Upload.tsx @@ -0,0 +1,37 @@ +import React from "react"; +import { QrIcon } from "../utils/theme-utils"; +import { UploadQrCode } from "../components/Home/VerificationSection/UploadQrCode"; +import { ScanOutline } from "../utils/theme-utils"; +import { useTranslation } from "react-i18next"; + +export const Upload = () => { + const {t} = useTranslation('Upload') + + return ( +
+
+
+
+
+ +
+ +
+
+

+ {t('format')} +

+
+
+
+ ); +}; diff --git a/ui/src/utils/config.ts b/ui/src/utils/config.ts index 51a47bdb..60ba6c40 100644 --- a/ui/src/utils/config.ts +++ b/ui/src/utils/config.ts @@ -3,6 +3,7 @@ import i18next from 'i18next'; export const Pages = { Home: "/", + Scan:"/scan", VerifyCredentials: "/",/*"/verify"*/ Offline: "/offline", Redirect: "/redirect",