diff --git a/browser-extension/plugin/.env.development b/browser-extension/plugin/.env.development index a41444a5..845728b3 100644 --- a/browser-extension/plugin/.env.development +++ b/browser-extension/plugin/.env.development @@ -1,4 +1,4 @@ ENVIRONMENT=development LOCAL_STORAGE_NAME=ogbvData -API_URL=http://localhost:3000 +API_URL=http://localhost:4000 MEDIA_URL=https://uli-media.tattle.co.in \ No newline at end of file diff --git a/browser-extension/plugin/src/api.js b/browser-extension/plugin/src/api.js new file mode 100644 index 00000000..b4c43452 --- /dev/null +++ b/browser-extension/plugin/src/api.js @@ -0,0 +1,21 @@ +import axios from "axios"; +import config from "./config"; + +const { API_URL } = config; + +export async function userLogin({email, password}){ + + console.log("INSIDE USERLOGIN: ") + try { + const response = await axios.post(`${API_URL}/api/auth/login`, { + email, + password + }); + console.log("RESPONSE IS: ",response) + console.log('Login successful:', response.data); + return response.data; + } catch (error) { + + throw error; + } +} diff --git a/browser-extension/plugin/src/ui-components/pages/App.jsx b/browser-extension/plugin/src/ui-components/pages/App.jsx index 410c3521..1ee00b7d 100644 --- a/browser-extension/plugin/src/ui-components/pages/App.jsx +++ b/browser-extension/plugin/src/ui-components/pages/App.jsx @@ -46,6 +46,7 @@ export function App() { async function navigatePreferences() { try { const userData = await getUserData(); + console.log("USER DATA: ", userData) const preferenceData = await getPreferenceData(); if (!ignore) { diff --git a/browser-extension/plugin/src/ui-components/pages/Debug.jsx b/browser-extension/plugin/src/ui-components/pages/Debug.jsx index 77ade592..d00902f2 100644 --- a/browser-extension/plugin/src/ui-components/pages/Debug.jsx +++ b/browser-extension/plugin/src/ui-components/pages/Debug.jsx @@ -9,7 +9,7 @@ import { TextInput, Heading } from 'grommet'; -import { UserContext } from '../atoms/AppContext'; +import { UserContext, NotificationContext } from '../atoms/AppContext'; import repository from '../../repository'; import config from '../../config'; import { useTranslation } from 'react-i18next'; @@ -18,41 +18,126 @@ const { getUserData, getPreferenceData, setUserData, setPreferenceData } = repository; const { resetAccount } = Api; import { Hide, View } from 'grommet-icons'; +import { userLogin } from '../../api'; export function Debug() { const { user, setUser } = useContext(UserContext); + const { showNotification } = useContext(NotificationContext); const [localStorageData, setLocalStorageData] = useState(undefined); const { t, i18n } = useTranslation(); + const [isResetChecked, setIsResetChecked] = useState(false); - useEffect(() => { - async function localStorage() { - const userData = await getUserData(); - const preferenceData = await getPreferenceData(); - if (!ignore) { - setLocalStorageData({ - user: userData, - preference: preferenceData - }); - } - } - let ignore = false; - localStorage(); - return () => { - ignore = true; - }; - }, []); - - return {user ? Logged in. Settings : }; + // useEffect(() => { + // async function localStorage() { + // const userData = await getUserData(); + // const preferenceData = await getPreferenceData(); + // if (!ignore) { + // setLocalStorageData({ + // user: userData, + // preference: preferenceData + // }); + // } + // } + // let ignore = false; + // localStorage(); + // return () => { + // ignore = true; + // }; + // }, []); + + return ( + + {user ? ( + + + Hello, {user?.email} ! + + + + Logout + + + + + setIsResetChecked(e.target.checked) + } + /> +