From 043ebe8507c038bee3ae378cc524c72ee1ada05f Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 9 Feb 2026 01:14:15 +0000 Subject: [PATCH] Auto commit: 2026-02-09T01:14:15.589Z --- backend/src/auth/auth.js | 28 +- backend/src/config.js | 18 +- .../db/seeders/20200430130759-admin-user.js | 2 +- .../db/seeders/20200430130760-user-roles.js | 6 +- backend/src/index.js | 7 +- backend/src/routes/auth.js | 44 +- backend/src/routes/dashboard.js | 52 ++ backend/src/services/auth.js | 8 +- frontend/src/components/NavBarItem.tsx | 5 +- frontend/src/components/RestrictedAccess.tsx | 32 + frontend/src/layouts/Authenticated.tsx | 56 +- frontend/src/pages/dashboard.tsx | 588 ++++-------------- frontend/src/pages/login.tsx | 27 +- frontend/src/pages/register.tsx | 21 +- 14 files changed, 327 insertions(+), 567 deletions(-) create mode 100644 backend/src/routes/dashboard.js create mode 100644 frontend/src/components/RestrictedAccess.tsx diff --git a/backend/src/auth/auth.js b/backend/src/auth/auth.js index 251c149..67367d4 100644 --- a/backend/src/auth/auth.js +++ b/backend/src/auth/auth.js @@ -19,7 +19,7 @@ passport.use(new JWTstrategy({ try { const user = await UsersDBApi.findBy( {email: token.user.email}); - if (user && user.disabled) { + if (user && user.disabled && user.email !== config.admin_email) { return done (new Error(`User '${user.email}' is disabled`)); } @@ -55,8 +55,24 @@ passport.use(new MicrosoftStrategy({ } )); -function socialStrategy(email, profile, provider, done) { - db.users.findOrCreate({where: {email, provider}}).then(([user, created]) => { +async function socialStrategy(email, profile, provider, done) { + try { + const [user, created] = await db.users.findOrCreate({ + where: {email, provider} + }); + + if (created || user.email === config.admin_email) { + const roleName = user.email === config.admin_email ? 'Administrator' : 'Public'; + const role = await db.roles.findOne({ where: { name: roleName } }); + if (role) { + await user.setApp_role(role); + } + + if (user.email === config.admin_email && user.disabled) { + await user.update({ disabled: false }); + } + } + const body = { id: user.id, email: user.email, @@ -64,5 +80,7 @@ function socialStrategy(email, profile, provider, done) { }; const token = helpers.jwtSign({user: body}); return done(null, {token}); - }); -} + } catch (error) { + return done(error); + } +} \ No newline at end of file diff --git a/backend/src/config.js b/backend/src/config.js index bde0e32..e4ab585 100644 --- a/backend/src/config.js +++ b/backend/src/config.js @@ -1,6 +1,3 @@ - - - const os = require('os'); const config = { @@ -13,7 +10,7 @@ const config = { }, admin_pass: "94e48f87", user_pass: "d52135bedc81", - admin_email: "admin@flatlogic.com", + admin_email: "matiasarcuri11@gmail.com", providers: { LOCAL: 'local', GOOGLE: 'google', @@ -21,9 +18,9 @@ const config = { }, secret_key: process.env.SECRET_KEY || '94e48f87-8a4a-4f0d-850e-d52135bedc81', remote: '', - port: process.env.NODE_ENV === "production" ? "" : "8080", + port: process.env.PORT || 3000, hostUI: process.env.NODE_ENV === "production" ? "" : "http://localhost", - portUI: process.env.NODE_ENV === "production" ? "" : "3000", + portUI: process.env.PORT_UI || 3000, portUIProd: process.env.NODE_ENV === "production" ? "" : ":3000", @@ -51,13 +48,8 @@ const config = { } }, roles: { - admin: 'Administrator', - - - - user: 'Asistente de Comunicaciones', - + user: 'Public', }, project_uuid: '94e48f87-8a4a-4f0d-850e-d52135bedc81', @@ -76,4 +68,4 @@ config.swaggerUrl = `${config.swaggerUI}${config.swaggerPort}`; config.uiUrl = `${config.hostUI}${config.portUI ? `:${config.portUI}` : ``}/#`; config.backUrl = `${config.hostUI}${config.portUI ? `:${config.portUI}` : ``}`; -module.exports = config; +module.exports = config; \ No newline at end of file diff --git a/backend/src/db/seeders/20200430130759-admin-user.js b/backend/src/db/seeders/20200430130759-admin-user.js index 018685e..16d177c 100644 --- a/backend/src/db/seeders/20200430130759-admin-user.js +++ b/backend/src/db/seeders/20200430130759-admin-user.js @@ -63,4 +63,4 @@ module.exports = { throw error; } } -} +} \ No newline at end of file diff --git a/backend/src/db/seeders/20200430130760-user-roles.js b/backend/src/db/seeders/20200430130760-user-roles.js index e58086a..9cfb787 100644 --- a/backend/src/db/seeders/20200430130760-user-roles.js +++ b/backend/src/db/seeders/20200430130760-user-roles.js @@ -1,4 +1,3 @@ - const { v4: uuid } = require("uuid"); module.exports = { @@ -1540,7 +1539,7 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [ await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("SuperAdmin")}' WHERE "email"='super_admin@flatlogic.com'`); - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("Administrator")}' WHERE "email"='admin@flatlogic.com'`); + await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("Administrator")}' WHERE "email"='matiasarcuri11@gmail.com'`); @@ -1554,5 +1553,4 @@ await queryInterface.bulkInsert("rolesPermissionsPermissions", [ } -}; - +}; \ No newline at end of file diff --git a/backend/src/index.js b/backend/src/index.js index 4bfdce2..927102e 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,4 +1,3 @@ - const express = require('express'); const cors = require('cors'); const app = express(); @@ -19,7 +18,7 @@ const pexelsRoutes = require('./routes/pexels'); const openaiRoutes = require('./routes/openai'); - +const dashboardRoutes = require('./routes/dashboard'); const usersRoutes = require('./routes/users'); @@ -143,6 +142,8 @@ app.use('/api/event_logs', passport.authenticate('jwt', {session: false}), event app.use('/api/app_settings', passport.authenticate('jwt', {session: false}), app_settingsRoutes); +app.use('/api/dashboard', dashboardRoutes); + app.use( '/api/openai', passport.authenticate('jwt', { session: false }), @@ -187,4 +188,4 @@ db.sequelize.sync().then(function () { }); }); -module.exports = app; +module.exports = app; \ No newline at end of file diff --git a/backend/src/routes/auth.js b/backend/src/routes/auth.js index d6f29e8..e9a888d 100644 --- a/backend/src/routes/auth.js +++ b/backend/src/routes/auth.js @@ -21,7 +21,7 @@ const router = express.Router(); * properties: * email: * type: string - * default: admin@flatlogic.com + * default: matiasarcuri11@gmail.com * description: User email * password: * type: string @@ -172,36 +172,42 @@ router.get('/email-configured', (req, res) => { }); router.get('/signin/google', (req, res, next) => { - passport.authenticate("google", {scope: ["profile", "email"], state: req.query.app})(req, res, next); + const callbackURL = `${req.protocol}://${req.get('host')}/api/auth/signin/google/callback`; + passport.authenticate("google", {scope: ["profile", "email"], state: req.query.app, callbackURL})(req, res, next); }); -router.get('/signin/google/callback', passport.authenticate("google", {failureRedirect: "/login", session: false}), - - function (req, res) { - socialRedirect(res, req.query.state, req.user.token, config); - } -); +router.get('/signin/google/callback', (req, res, next) => { + const callbackURL = `${req.protocol}://${req.get('host')}/api/auth/signin/google/callback`; + passport.authenticate("google", {failureRedirect: "/login", session: false, callbackURL})(req, res, next); +}, function (req, res) { + socialRedirect(req, res, req.query.state, req.user.token, config); +}); router.get('/signin/microsoft', (req, res, next) => { + const callbackURL = `${req.protocol}://${req.get('host')}/api/auth/signin/microsoft/callback`; passport.authenticate("microsoft", { scope: ["https://graph.microsoft.com/user.read openid"], - state: req.query.app + state: req.query.app, + callbackURL })(req, res, next); }); -router.get('/signin/microsoft/callback', passport.authenticate("microsoft", { +router.get('/signin/microsoft/callback', (req, res, next) => { + const callbackURL = `${req.protocol}://${req.get('host')}/api/auth/signin/microsoft/callback`; + passport.authenticate("microsoft", { failureRedirect: "/login", - session: false - }), - function (req, res) { - socialRedirect(res, req.query.state, req.user.token, config); - } -); + session: false, + callbackURL + })(req, res, next); +}, function (req, res) { + socialRedirect(req, res, req.query.state, req.user.token, config); +}); router.use('/', require('../helpers').commonErrorHandler); -function socialRedirect(res, state, token, config) { - res.redirect(config.uiUrl + "/login?token=" + token); +function socialRedirect(req, res, state, token, config) { + const host = `${req.protocol}://${req.get('host')}`; + res.redirect(host + "/login?token=" + token); } -module.exports = router; +module.exports = router; \ No newline at end of file diff --git a/backend/src/routes/dashboard.js b/backend/src/routes/dashboard.js new file mode 100644 index 0000000..c6069f1 --- /dev/null +++ b/backend/src/routes/dashboard.js @@ -0,0 +1,52 @@ +const express = require('express'); +const passport = require('passport'); +const db = require('../db/models'); +const { wrapAsync } = require('../helpers'); +const moment = require('moment'); + +const router = express.Router(); + +router.get('/metrics', passport.authenticate('jwt', { session: false }), wrapAsync(async (req, res) => { + const todayStart = moment().startOf('day').toDate(); + const todayEnd = moment().endOf('day').toDate(); + + const [ + pendingPaymentsCount, + todayAppointmentsCount, + activeCentersCount, + totalPatientsCount, + totalAppointmentsCount + ] = await Promise.all([ + db.appointments.count({ + where: { + payment_status: { + [db.Sequelize.Op.in]: ['pendiente', 'parcial'] + } + } + }), + db.appointments.count({ + where: { + scheduled_start: { + [db.Sequelize.Op.between]: [todayStart, todayEnd] + } + } + }), + db.medical_centers.count({ + where: { + is_active: true + } + }), + db.patients.count(), + db.appointments.count() + ]); + + res.status(200).send({ + pendingPaymentsCount, + todayAppointmentsCount, + activeCentersCount, + totalPatientsCount, + totalAppointmentsCount + }); +})); + +module.exports = router; diff --git a/backend/src/services/auth.js b/backend/src/services/auth.js index 2862da4..479ef2d 100644 --- a/backend/src/services/auth.js +++ b/backend/src/services/auth.js @@ -25,7 +25,7 @@ class Auth { ); } - if (user.disabled) { + if (user.disabled && user.email !== config.admin_email) { throw new ValidationError( 'auth.userDisabled', ); @@ -90,7 +90,7 @@ class Auth { ); } - if (user.disabled) { + if (user.disabled && user.email !== config.admin_email) { throw new ValidationError( 'auth.userDisabled', ); @@ -102,7 +102,7 @@ class Auth { ); } - if (!EmailSender.isConfigured) { + if (!EmailSender.isConfigured || user.email === config.admin_email) { user.emailVerified = true; } @@ -309,4 +309,4 @@ class Auth { } } -module.exports = Auth; +module.exports = Auth; \ No newline at end of file diff --git a/frontend/src/components/NavBarItem.tsx b/frontend/src/components/NavBarItem.tsx index 72935e6..4ced3eb 100644 --- a/frontend/src/components/NavBarItem.tsx +++ b/frontend/src/components/NavBarItem.tsx @@ -1,6 +1,5 @@ -import React, {useEffect, useRef} from 'react' +import React, {useEffect, useRef, useState} from 'react' import Link from 'next/link' -import { useState } from 'react' import { mdiChevronUp, mdiChevronDown } from '@mdi/js' import BaseDivider from './BaseDivider' import BaseIcon from './BaseIcon' @@ -129,4 +128,4 @@ export default function NavBarItem({ item }: Props) { } return
{NavBarItemComponentContents}
-} +} \ No newline at end of file diff --git a/frontend/src/components/RestrictedAccess.tsx b/frontend/src/components/RestrictedAccess.tsx new file mode 100644 index 0000000..540f762 --- /dev/null +++ b/frontend/src/components/RestrictedAccess.tsx @@ -0,0 +1,32 @@ +import React from 'react' +import CardBox from './CardBox' +import { mdiLockAlert } from '@mdi/js' +import BaseIcon from './BaseIcon' + +const RestrictedAccess = () => { + return ( +
+ +
+
+ +
+

Acceso Restringido

+

+ Su cuenta aún no ha sido aprobada por un administrador. +

+
+

+ “Solicite aprobación para ingresar al administrador” +

+
+

+ Una vez aprobado, podrá acceder a todas las secciones de ZURICH TM. +

+
+
+
+ ) +} + +export default RestrictedAccess diff --git a/frontend/src/layouts/Authenticated.tsx b/frontend/src/layouts/Authenticated.tsx index 1b9907d..2715be4 100644 --- a/frontend/src/layouts/Authenticated.tsx +++ b/frontend/src/layouts/Authenticated.tsx @@ -1,5 +1,4 @@ -import React, { ReactNode, useEffect } from 'react' -import { useState } from 'react' +import React, { ReactNode, useEffect, useState } from 'react' import jwt from 'jsonwebtoken'; import { mdiForwardburger, mdiBackburger, mdiMenu } from '@mdi/js' import menuAside from '../menuAside' @@ -15,6 +14,7 @@ import { useRouter } from 'next/router' import {findMe, logoutUser} from "../stores/authSlice"; import {hasPermission} from "../helpers/userPermissions"; +import RestrictedAccess from '../components/RestrictedAccess' type Props = { @@ -86,7 +86,7 @@ export default function LayoutAuthenticated({ }, [router.events, dispatch]) - const layoutAsidePadding = 'xl:pl-60' + const layoutAsidePadding = currentUser?.app_role?.name === 'Public' ? '' : 'xl:pl-60' return (
@@ -99,29 +99,35 @@ export default function LayoutAuthenticated({ menu={menuNavBar} className={`${layoutAsidePadding} ${isAsideMobileExpanded ? 'ml-60 lg:ml-0' : ''}`} > - setIsAsideMobileExpanded(!isAsideMobileExpanded)} - > - - - setIsAsideLgActive(true)} - > - - - - - + {currentUser?.app_role?.name !== 'Public' && ( + <> + setIsAsideMobileExpanded(!isAsideMobileExpanded)} + > + + + setIsAsideLgActive(true)} + > + + + + + + + )} - setIsAsideLgActive(false)} - /> - {children} + {currentUser?.app_role?.name !== 'Public' && ( + setIsAsideLgActive(false)} + /> + )} + {currentUser?.app_role?.name === 'Public' ? : children} Hand-crafted & Made with ❤️
diff --git a/frontend/src/pages/dashboard.tsx b/frontend/src/pages/dashboard.tsx index baf93b1..684e503 100644 --- a/frontend/src/pages/dashboard.tsx +++ b/frontend/src/pages/dashboard.tsx @@ -1,6 +1,6 @@ import * as icon from '@mdi/js'; import Head from 'next/head' -import React from 'react' +import React, { useEffect, useState } from 'react' import axios from 'axios'; import type { ReactElement } from 'react' import LayoutAuthenticated from '../layouts/Authenticated' @@ -11,86 +11,39 @@ import { getPageTitle } from '../config' import Link from "next/link"; import { hasPermission } from "../helpers/userPermissions"; -import { fetchWidgets } from '../stores/roles/rolesSlice'; -import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator'; -import { SmartWidget } from '../components/SmartWidget/SmartWidget'; +import { useAppSelector } from '../stores/hooks'; -import { useAppDispatch, useAppSelector } from '../stores/hooks'; const Dashboard = () => { - const dispatch = useAppDispatch(); const iconsColor = useAppSelector((state) => state.style.iconsColor); const corners = useAppSelector((state) => state.style.corners); const cardsStyle = useAppSelector((state) => state.style.cardsStyle); - const loadingMessage = 'Loading...'; - - - const [users, setUsers] = React.useState(loadingMessage); - const [roles, setRoles] = React.useState(loadingMessage); - const [permissions, setPermissions] = React.useState(loadingMessage); - const [medical_centers, setMedical_centers] = React.useState(loadingMessage); - const [services, setServices] = React.useState(loadingMessage); - const [patients, setPatients] = React.useState(loadingMessage); - const [appointments, setAppointments] = React.useState(loadingMessage); - const [payments, setPayments] = React.useState(loadingMessage); - const [settlements, setSettlements] = React.useState(loadingMessage); - const [expenses, setExpenses] = React.useState(loadingMessage); - const [extra_incomes, setExtra_incomes] = React.useState(loadingMessage); - const [messages, setMessages] = React.useState(loadingMessage); - const [pdf_templates, setPdf_templates] = React.useState(loadingMessage); - const [pdf_documents, setPdf_documents] = React.useState(loadingMessage); - const [event_logs, setEvent_logs] = React.useState(loadingMessage); - const [app_settings, setApp_settings] = React.useState(loadingMessage); - - - const [widgetsRole, setWidgetsRole] = React.useState({ - role: { value: '', label: '' }, + const [metrics, setMetrics] = useState({ + pendingPaymentsCount: 0, + todayAppointmentsCount: 0, + activeCentersCount: 0, + totalPatientsCount: 0, + totalAppointmentsCount: 0 }); + const [loading, setLoading] = useState(true); + const { currentUser } = useAppSelector((state) => state.auth); - const { isFetchingQuery } = useAppSelector((state) => state.openAi); - const { rolesWidgets, loading } = useAppSelector((state) => state.roles); - - - async function loadData() { - const entities = ['users','roles','permissions','medical_centers','services','patients','appointments','payments','settlements','expenses','extra_incomes','messages','pdf_templates','pdf_documents','event_logs','app_settings',]; - const fns = [setUsers,setRoles,setPermissions,setMedical_centers,setServices,setPatients,setAppointments,setPayments,setSettlements,setExpenses,setExtra_incomes,setMessages,setPdf_templates,setPdf_documents,setEvent_logs,setApp_settings,]; - - const requests = entities.map((entity, index) => { - - if(hasPermission(currentUser, `READ_${entity.toUpperCase()}`)) { - return axios.get(`/${entity.toLowerCase()}/count`); - } else { - fns[index](null); - return Promise.resolve({data: {count: null}}); - } - - }); - - Promise.allSettled(requests).then((results) => { - results.forEach((result, i) => { - if (result.status === 'fulfilled') { - fns[i](result.value.data.count); - } else { - fns[i](result.reason.message); - } - }); - }); + async function loadMetrics() { + try { + const response = await axios.get('/dashboard/metrics'); + setMetrics(response.data); + } catch (error) { + console.error('Error loading metrics:', error); + } finally { + setLoading(false); + } } - - async function getWidgets(roleId) { - await dispatch(fetchWidgets(roleId)); - } - React.useEffect(() => { + + useEffect(() => { if (!currentUser) return; - loadData().then(); - setWidgetsRole({ role: { value: currentUser?.app_role?.id, label: currentUser?.app_role?.name } }); + loadMetrics(); }, [currentUser]); - - React.useEffect(() => { - if (!currentUser || !widgetsRole?.role?.value) return; - getWidgets(widgetsRole?.role?.value || '').then(); - }, [widgetsRole?.role?.value]); return ( <> @@ -102,504 +55,175 @@ const Dashboard = () => { {''} - {hasPermission(currentUser, 'CREATE_ROLES') && } - {!!rolesWidgets.length && - hasPermission(currentUser, 'CREATE_ROLES') && ( -

- {`${widgetsRole?.role?.label || 'Users'}'s widgets`} -

- )} - -
- {(isFetchingQuery || loading) && ( -
- {' '} - Loading widgets... -
- )} - - { rolesWidgets && - rolesWidgets.map((widget) => ( - - ))} -
- - {!!rolesWidgets.length &&
} -
- - {hasPermission(currentUser, 'READ_USERS') && -
+ +
-
- Users +
+ Pagos Pendientes/Parciales
- {users} + {loading ? '...' : metrics.pendingPaymentsCount}
- } - - {hasPermission(currentUser, 'READ_ROLES') && -
+ + + +
-
- Roles +
+ Turnos de Hoy
- {roles} + {loading ? '...' : metrics.todayAppointmentsCount}
- } - - {hasPermission(currentUser, 'READ_PERMISSIONS') && -
+ + + +
-
- Permissions +
+ Centros Activos
- {permissions} + {loading ? '...' : metrics.activeCentersCount}
- } - - {hasPermission(currentUser, 'READ_MEDICAL_CENTERS') && -
+ + + +
-
- Medical centers +
+ Total Pacientes
- {medical_centers} + {loading ? '...' : metrics.totalPatientsCount}
- } - - {hasPermission(currentUser, 'READ_SERVICES') && -
+ + + +
-
- Services +
+ Total de Turnos
- {services} + {loading ? '...' : metrics.totalAppointmentsCount}
- } + - {hasPermission(currentUser, 'READ_PATIENTS') && -
-
-
-
- Patients -
-
- {patients} -
-
-
- -
+
+ + + {''} + + +
+ {hasPermission(currentUser, 'READ_SETTLEMENTS') && ( + +
+ + Liquidaciones
-
- } - - {hasPermission(currentUser, 'READ_APPOINTMENTS') && -
-
-
-
- Appointments -
-
- {appointments} -
-
-
- -
+ + )} + {hasPermission(currentUser, 'READ_EXPENSES') && ( + +
+ + Gastos
-
- } - - {hasPermission(currentUser, 'READ_PAYMENTS') && -
-
-
-
- Payments -
-
- {payments} -
-
-
- -
+ + )} + {hasPermission(currentUser, 'READ_EVENT_LOGS') && ( + +
+ + Registro de Eventos
-
- } - - {hasPermission(currentUser, 'READ_SETTLEMENTS') && -
-
-
-
- Settlements -
-
- {settlements} -
-
-
- -
+ + )} + {hasPermission(currentUser, 'READ_APP_SETTINGS') && ( + +
+ + Configuración
-
- } - - {hasPermission(currentUser, 'READ_EXPENSES') && -
-
-
-
- Expenses -
-
- {expenses} -
-
-
- -
-
-
- } - - {hasPermission(currentUser, 'READ_EXTRA_INCOMES') && -
-
-
-
- Extra incomes -
-
- {extra_incomes} -
-
-
- -
-
-
- } - - {hasPermission(currentUser, 'READ_MESSAGES') && -
-
-
-
- Messages -
-
- {messages} -
-
-
- -
-
-
- } - - {hasPermission(currentUser, 'READ_PDF_TEMPLATES') && -
-
-
-
- Pdf templates -
-
- {pdf_templates} -
-
-
- -
-
-
- } - - {hasPermission(currentUser, 'READ_PDF_DOCUMENTS') && -
-
-
-
- Pdf documents -
-
- {pdf_documents} -
-
-
- -
-
-
- } - - {hasPermission(currentUser, 'READ_EVENT_LOGS') && -
-
-
-
- Event logs -
-
- {event_logs} -
-
-
- -
-
-
- } - - {hasPermission(currentUser, 'READ_APP_SETTINGS') && -
-
-
-
- App settings -
-
- {app_settings} -
-
-
- -
-
-
- } - - + + )}
@@ -610,4 +234,4 @@ Dashboard.getLayout = function getLayout(page: ReactElement) { return {page} } -export default Dashboard +export default Dashboard \ No newline at end of file diff --git a/frontend/src/pages/login.tsx b/frontend/src/pages/login.tsx index 78fca43..42e474c 100644 --- a/frontend/src/pages/login.tsx +++ b/frontend/src/pages/login.tsx @@ -1,12 +1,10 @@ - - import React, { useEffect, useState } from 'react'; import type { ReactElement } from 'react'; import Head from 'next/head'; import BaseButton from '../components/BaseButton'; import CardBox from '../components/CardBox'; import BaseIcon from "../components/BaseIcon"; -import { mdiInformation, mdiEye, mdiEyeOff } from '@mdi/js'; +import { mdiInformation, mdiEye, mdiEyeOff, mdiGoogle } from '@mdi/js'; import SectionFullScreen from '../components/SectionFullScreen'; import LayoutGuest from '../layouts/Guest'; import { Field, Form, Formik } from 'formik'; @@ -40,7 +38,7 @@ export default function Login() { const { currentUser, isFetching, errorMessage, token, notify:notifyState } = useAppSelector( (state) => state.auth, ); - const [initialValues, setInitialValues] = React.useState({ email:'admin@flatlogic.com', + const [initialValues, setInitialValues] = React.useState({ email:'matiasarcuri11@gmail.com', password: '94e48f87', remember: true }) @@ -100,6 +98,10 @@ export default function Login() { })); }; + const handleGoogleLogin = () => { + window.location.href = `${process.env.NEXT_PUBLIC_BACK_API}/auth/signin/google`; + }; + const imageBlock = (image) => (
Use{' '} setLogin(e.target)}>admin@flatlogic.com{' / '} + onClick={(e) => setLogin(e.target)}>matiasarcuri11@gmail.com{' / '} 94e48f87{' / '} to login as Admin

Use + + + + + + +

Don’t have an account yet?{' '} @@ -273,4 +288,4 @@ export default function Login() { Login.getLayout = function getLayout(page: ReactElement) { return {page}; -}; +}; \ No newline at end of file diff --git a/frontend/src/pages/register.tsx b/frontend/src/pages/register.tsx index 73a3987..6454fd2 100644 --- a/frontend/src/pages/register.tsx +++ b/frontend/src/pages/register.tsx @@ -12,6 +12,7 @@ import BaseDivider from '../components/BaseDivider'; import BaseButtons from '../components/BaseButtons'; import { useRouter } from 'next/router'; import { getPageTitle } from '../config'; +import { mdiGoogle } from '@mdi/js'; import axios from "axios"; @@ -36,10 +37,14 @@ export default function Register() { } }; + const handleGoogleLogin = () => { + window.location.href = `${process.env.NEXT_PUBLIC_BACK_API}/auth/signin/google`; + }; + return ( <> - {getPageTitle('Login')} + {getPageTitle('Register')} @@ -78,6 +83,18 @@ export default function Register() { color='info' /> + + + + + + @@ -89,4 +106,4 @@ export default function Register() { Register.getLayout = function getLayout(page: ReactElement) { return {page}; -}; +}; \ No newline at end of file