Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added splash_title var to launch page #36

Merged
merged 43 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
810e32d
ui changes
prtkjakhar Jun 26, 2023
7aab254
fix: user id in socket
Shruti3004 Jun 27, 2023
c26e5a2
fix:socket
Shruti3004 Jun 27, 2023
3d6b652
removed flagsmith
prtkjakhar Jun 28, 2023
e140355
recorder button on chat screen
prtkjakhar Jun 28, 2023
801746e
clear chat button added
prtkjakhar Jun 28, 2023
f38ef10
added identifier in socket
prtkjakhar Jun 28, 2023
6318e24
Merge branch 'production' into main
prtkjakhar Jun 28, 2023
e64e67d
minor bug fix
prtkjakhar Jun 29, 2023
75524c6
Merge branch 'main' of https://github.com/AgrI-Mitra/app
prtkjakhar Jun 29, 2023
d6beed9
fix: updated API flows
Jul 3, 2023
fb30820
minor fix
prtkjakhar Jul 3, 2023
0e50f46
Update RenderVoiceRecorder.jsx
prtkjakhar Jul 6, 2023
45ae938
Update ContextProvider.tsx
prtkjakhar Jul 6, 2023
4acc503
minor fix
prtkjakhar Jul 3, 2023
3e9700f
added examples
prtkjakhar Jul 5, 2023
b0af3f3
Merge branch 'production' into main
prtkjakhar Jul 6, 2023
f067590
Updated the hindi STT model Id.
Amruth-Vamshi Jul 7, 2023
a86d889
Updated verify otp req
prtkjakhar Jul 11, 2023
2dcea3d
Updated identifier
prtkjakhar Jul 11, 2023
541b27a
changed send to submit for otp
prtkjakhar Jul 11, 2023
60badec
Updated langauge data and ContextProvider.tsx
Jul 13, 2023
c4c5704
hindi models updated
prtkjakhar Jul 13, 2023
5e3552e
bug fixes
prtkjakhar Jul 13, 2023
99c6dc8
Update index.tsx
prtkjakhar Jul 13, 2023
233d802
Merge branch 'production' into main
prtkjakhar Jul 13, 2023
31d6d61
Update build-and-push.yml
singhalkarun Jul 13, 2023
73c197d
Update Dockerfile
singhalkarun Jul 13, 2023
d552c26
removed isSubmitting
prtkjakhar Jul 13, 2023
1369bd1
added otpsubmitting
prtkjakhar Jul 13, 2023
6a8a2e0
fix: minor ui changes
prtkjakhar Jul 13, 2023
ec4d7a0
Merge branch 'production' into main
prtkjakhar Jul 13, 2023
a59ba87
changed models
prtkjakhar Jul 13, 2023
6d8e572
Merge branch 'production' into main
prtkjakhar Jul 13, 2023
1081723
updated hindi asr model
prtkjakhar Jul 13, 2023
f2f1560
fix: updated translation hindi model id
prtkjakhar Jul 14, 2023
f6bb560
Merge branch 'production' into main
prtkjakhar Jul 14, 2023
b89c870
updated title in launch page
prtkjakhar Jul 14, 2023
cbc01ca
added splash title var in json
prtkjakhar Jul 14, 2023
6c750d5
removed splash title
prtkjakhar Jul 14, 2023
456a509
Merge branch 'production' into main
prtkjakhar Jul 14, 2023
b16b292
added splash title
prtkjakhar Jul 14, 2023
454157d
Merge branch 'production' into main
prtkjakhar Jul 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/agri-mitra/src/components/LaunchPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import styles from './index.module.css';
import Logo from "../../assets/images/MOA_logo.png";
import Image from "next/image";
import { useLocalization } from '../../hooks/useLocalization';

function LaunchPage() {
const t = useLocalization();
return (
<div className={`${styles.container}`}>
<Image
Expand All @@ -12,7 +14,7 @@ function LaunchPage() {
width={235}
height={235}
/>
<span>Kisan e-Mitra</span>
<span>{t('label.splash_title')}</span>
</div>
)
}
Expand Down
95 changes: 53 additions & 42 deletions apps/agri-mitra/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import ContextProvider from '../context/ContextProvider';
import { ReactElement, useCallback, useEffect, useState } from 'react';
import 'chatui/dist/index.css';
import { Toaster } from 'react-hot-toast';
import { useCookies } from 'react-cookie';
import { useRouter } from 'next/router';
import dynamic from 'next/dynamic';
import { useLogin } from '../hooks';
import FingerprintJS from '@fingerprintjs/fingerprintjs';
import { IntlProvider } from 'react-intl';

const LaunchPage = dynamic(() => import('../components/LaunchPage'), {
ssr: false,
Expand All @@ -26,10 +24,44 @@ function SafeHydrate({ children }: { children: ReactElement }) {
}

const App = ({ Component, pageProps }: AppProps) => {
const router = useRouter();
const { isAuthenticated, login } = useLogin();
const [launch, setLaunch] = useState(true);
const [cookie, setCookie, removeCookie] = useCookies();
const [locale, setLocale] = useState('en');
const [localeMsgs, setLocaleMsgs] = useState<Record<string, string> | null>(
null
);

function loadMessages(locale: string) {
switch (locale) {
case 'en':
return import('../../lang/en.json');
case 'hi':
return import('../../lang/hi.json');
case 'bn':
return import('../../lang/bn.json');
case 'ta':
return import('../../lang/ta.json');
case 'te':
return import('../../lang/te.json');
default:
return import('../../lang/en.json');
}
}

useEffect(() => {
if (typeof window !== 'undefined') {
const savedLocale = localStorage.getItem('locale');
if (savedLocale) {
setLocale(savedLocale);
}
}
}, []);

useEffect(() => {
if (locale) {
//@ts-ignore
loadMessages(locale).then((res) => setLocaleMsgs(res));
}
}, [locale]);

useEffect(() => {
setTimeout(() => {
Expand Down Expand Up @@ -57,50 +89,29 @@ const App = ({ Component, pageProps }: AppProps) => {
}, []);


// const handleLoginRedirect = useCallback(() => {
// if (router.pathname === '/login' || router.pathname.startsWith('/otp')) {
// // already logged in then send to home
// if (cookie['access_token'] && localStorage.getItem('userID')) {
// router.push('/');
// }
// } else {
// // not logged in then send to login page
// if (!cookie['access_token'] || !localStorage.getItem('userID')) {
// localStorage.clear();
// sessionStorage.clear();
// router.push('/login');
// }
// }
// }, [cookie, router]);

// useEffect(() => {
// handleLoginRedirect();
// }, [handleLoginRedirect]);

// useEffect(() => {
// if (!isAuthenticated) {
// login();
// }
// }, [isAuthenticated, login]);

if (process.env.NODE_ENV === 'production') {
globalThis.console.log = () => {};
}

if (launch) {
return <LaunchPage />;
return (
//@ts-ignore
<IntlProvider locale="en" messages={localeMsgs}>
<LaunchPage />
</IntlProvider>
);
} else {
return (
<ChakraProvider>
<ContextProvider>
<div style={{ height: '100%' }}>
<Toaster position="top-center" reverseOrder={false} />
<NavBar />
<SafeHydrate>
<Component {...pageProps} />
</SafeHydrate>
</div>
</ContextProvider>
<ContextProvider>
<div style={{ height: '100%' }}>
<Toaster position="top-center" reverseOrder={false} />
<NavBar />
<SafeHydrate>
<Component {...pageProps} />
</SafeHydrate>
</div>
</ContextProvider>
</ChakraProvider>
);
}
Expand Down