Compare commits
3 Commits
235fb538e1
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| c82c2166f2 | |||
| c8c2ca8c5b | |||
| 8b5c940976 |
@@ -1,6 +1,9 @@
|
|||||||
# API Configuration
|
# API Configuration
|
||||||
# Base URL da API do HGTX
|
# Base URL da API do HGTX
|
||||||
VITE_API_BASE_URL=https://prod-hgtx-intelligence-n8n.hgtx.com.br
|
VITE_API_BASE_URL=https://prod-hgtx-intelligence-n8n.hgtx.com.br
|
||||||
|
VITE_BASE_URL_OPEN_CODEX_APIs=https://codex-api.hgtx.com.br/api/
|
||||||
|
VITE_BASE_URL_HGTX_CORE_API=https://core-api.hgtx.com.br/api/
|
||||||
|
VITE_BASE_URL_HGTX_CORE=https://core.hgtx.com.br/
|
||||||
|
|
||||||
# API Key para autenticação
|
# API Key para autenticação
|
||||||
# IMPORTANTE: Mantenha esta chave segura e não compartilhe publicamente
|
# IMPORTANTE: Mantenha esta chave segura e não compartilhe publicamente
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="pt-br">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
@@ -10,11 +10,11 @@
|
|||||||
<meta property="og:title" content="HGTX Codex - AI Interface System" />
|
<meta property="og:title" content="HGTX Codex - AI Interface System" />
|
||||||
<meta property="og:description" content="Sistema moderno de interface conversacional com IA - Chat, Geração de Imagens e Processamento de Áudio" />
|
<meta property="og:description" content="Sistema moderno de interface conversacional com IA - Chat, Geração de Imagens e Processamento de Áudio" />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:image" content="https://lovable.dev/opengraph-image-p98pqg.png" />
|
<meta property="og:image" content="/favicon.png" />
|
||||||
|
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
<meta name="twitter:site" content="@lovable_dev" />
|
<meta name="twitter:site" content="@hgtx" />
|
||||||
<meta name="twitter:image" content="https://lovable.dev/opengraph-image-p98pqg.png" />
|
<meta name="twitter:image" content="/favicon.png" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Generated
+9
@@ -44,6 +44,7 @@
|
|||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"input-otp": "^1.4.2",
|
"input-otp": "^1.4.2",
|
||||||
|
"jwt-decode": "^4.0.0",
|
||||||
"lucide-react": "^0.462.0",
|
"lucide-react": "^0.462.0",
|
||||||
"next-themes": "^0.3.0",
|
"next-themes": "^0.3.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
@@ -4828,6 +4829,14 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/jwt-decode": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/keyv": {
|
"node_modules/keyv": {
|
||||||
"version": "4.5.4",
|
"version": "4.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
"input-otp": "^1.4.2",
|
"input-otp": "^1.4.2",
|
||||||
|
"jwt-decode": "^4.0.0",
|
||||||
"lucide-react": "^0.462.0",
|
"lucide-react": "^0.462.0",
|
||||||
"next-themes": "^0.3.0",
|
"next-themes": "^0.3.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
+21
-2
@@ -2,10 +2,13 @@ import { Toaster } from "@/components/ui/toaster";
|
|||||||
import { Toaster as Sonner } from "@/components/ui/sonner";
|
import { Toaster as Sonner } from "@/components/ui/sonner";
|
||||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
|
||||||
import { ThemeProvider } from "next-themes";
|
import { ThemeProvider } from "next-themes";
|
||||||
import Index from "./pages/Index";
|
import Index from "./pages/Index";
|
||||||
import NotFound from "./pages/NotFound";
|
import NotFound from "./pages/NotFound";
|
||||||
|
import Redirect from "./pages/Redirect";
|
||||||
|
import { GlobalFunctions } from "./GlobalFunctions";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
@@ -17,9 +20,15 @@ const App = () => (
|
|||||||
<Sonner />
|
<Sonner />
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Index />} />
|
<Route
|
||||||
|
path="/redir/:gsikey"
|
||||||
|
element={<Redirect />}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Route path="/*" element={GlobalFunctions.isUsuarioLogado() ? <Index /> : <HGTXLogin />} />
|
||||||
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
|
<Route path="/404" element={<NotFound />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
@@ -28,3 +37,13 @@ const App = () => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
||||||
|
|
||||||
|
const HGTXLogin = () =>{
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
window.location.replace(import.meta.env.VITE_BASE_URL_HGTX_CORE);
|
||||||
|
});
|
||||||
|
|
||||||
|
return(<></>);
|
||||||
|
}
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
import { jwtDecode } from 'jwt-decode';
|
||||||
|
import { RedirectService } from './pages/RedirectService';
|
||||||
|
|
||||||
|
export class GlobalFunctions {
|
||||||
|
|
||||||
|
public static getTranferAreaObj(): TransferAreaResponse {
|
||||||
|
let objRetorno: TransferAreaResponse = {
|
||||||
|
aplicativoID: 0,
|
||||||
|
aplicativoNome: "",
|
||||||
|
areaTransferenciaID: 0,
|
||||||
|
dataRegistro: "",
|
||||||
|
estabelecimentoID: 0,
|
||||||
|
usuarioID: 0,
|
||||||
|
usuarioEmail: "",
|
||||||
|
usuarioNome: "",
|
||||||
|
aplicativoShareCode: "",
|
||||||
|
nivelAcesso: 0
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const objTransferStr = sessionStorage.getItem("TRANSFER_AREA");
|
||||||
|
if (
|
||||||
|
objTransferStr != null &&
|
||||||
|
objTransferStr != undefined &&
|
||||||
|
objTransferStr.trim() != ""
|
||||||
|
) {
|
||||||
|
const objTransfer = <TransferAreaResponse>JSON.parse(objTransferStr);
|
||||||
|
objRetorno = objTransfer;
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
return objRetorno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getRedirectComponent(): string {
|
||||||
|
let objRetorno = "";
|
||||||
|
try {
|
||||||
|
const objTransfer = GlobalFunctions.getTranferAreaObj();
|
||||||
|
if (objTransfer != null) {
|
||||||
|
// let objRedir = objTransfer.find(x => x.name == 'REDIRECT');
|
||||||
|
// objRetorno = objRedir?.value ?? '';
|
||||||
|
objRetorno = objTransfer.urlDestino ?? "";
|
||||||
|
if (objRetorno.startsWith("/")) objRetorno = objRetorno.substring(1);
|
||||||
|
} else {
|
||||||
|
objRetorno = "";
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
//console.log(error);
|
||||||
|
objRetorno = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return objRetorno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getTransferProperty(propertyName: TransferAreaProperties): any {
|
||||||
|
let objRetorno: any = "";
|
||||||
|
try {
|
||||||
|
const objTransfer = this.getTranferAreaObj();
|
||||||
|
if (objTransfer != null) {
|
||||||
|
//let obj: any = objTransfer[propertyName];
|
||||||
|
const element = objTransfer[propertyName];
|
||||||
|
objRetorno = element;
|
||||||
|
} else {
|
||||||
|
objRetorno = null;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
objRetorno = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return objRetorno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static isUsuarioLogado(): boolean {
|
||||||
|
let jsonUsuario = sessionStorage.getItem('usuarioLogado');
|
||||||
|
if (jsonUsuario) {
|
||||||
|
let tokenDecode: any = GlobalFunctions.getUsuarioLogado();
|
||||||
|
let d: Date = new Date();
|
||||||
|
let dateAtual: number = Date.UTC(d.getFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes() + 5, d.getUTCSeconds()) / 1000;
|
||||||
|
if (dateAtual > tokenDecode.exp) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static tokenExpired(tokenDecode: any): boolean {
|
||||||
|
let d: Date = new Date();
|
||||||
|
let dateAtual: number = Date.UTC(d.getFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes() + 5, d.getUTCSeconds()) / 1000;
|
||||||
|
if (dateAtual > tokenDecode.exp) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static handleNavigateBack(): void {
|
||||||
|
try {
|
||||||
|
// Verifica se existe histórico de navegação
|
||||||
|
if (window.history && window.history.length > 1) {
|
||||||
|
window.history.back();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tenta fechar a janela
|
||||||
|
if (!window.closed) {
|
||||||
|
try {
|
||||||
|
const windowRef = window.open('', '_self');
|
||||||
|
if (windowRef) {
|
||||||
|
windowRef.close();
|
||||||
|
|
||||||
|
// Pequeno timeout para verificar se a janela foi fechada
|
||||||
|
setTimeout(() => {
|
||||||
|
// Se ainda estiver aberta, redireciona
|
||||||
|
if (!windowRef.closed) {
|
||||||
|
window.location.href = "https://core.hgtx.com.br/aplicativos/";
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (closeError) {
|
||||||
|
console.warn("Não foi possível fechar a janela:", closeError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Se não conseguiu fechar, redireciona
|
||||||
|
window.location.href = "https://core.hgtx.com.br/aplicativos/";
|
||||||
|
} catch (error) {
|
||||||
|
// Em caso de qualquer erro, garante o redirecionamento
|
||||||
|
console.error("Erro ao tentar navegar:", error);
|
||||||
|
window.location.href = "https://core.hgtx.com.br/aplicativos/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getUsuarioLogado(): UsuarioLogadoData {
|
||||||
|
const jsonUsuario = sessionStorage.getItem("usuarioLogado") ?? "";
|
||||||
|
try {
|
||||||
|
const objJwt = JSON.parse(jsonUsuario);
|
||||||
|
//return jwt_decode(objJwt.token);
|
||||||
|
return jwtDecode(objJwt.token);
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
return {
|
||||||
|
EID: "0",
|
||||||
|
email: "",
|
||||||
|
exp: 0,
|
||||||
|
iat: 0,
|
||||||
|
jti: "",
|
||||||
|
name: "",
|
||||||
|
nbf: 0,
|
||||||
|
UID: "0",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getUsuarioLogadoToken(): string {
|
||||||
|
let retorno = "";
|
||||||
|
const jsonUsuario = sessionStorage.getItem("usuarioLogado") ?? "";
|
||||||
|
try {
|
||||||
|
const objJwt = JSON.parse(jsonUsuario);
|
||||||
|
retorno = objJwt.token;
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
return retorno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getUsuarioLogadoRefreshToken(): string {
|
||||||
|
let retorno = "";
|
||||||
|
const jsonUsuario = sessionStorage.getItem("usuarioLogado") ?? "";
|
||||||
|
try {
|
||||||
|
const objJwt = JSON.parse(jsonUsuario);
|
||||||
|
retorno = objJwt.refreshToken;
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
return retorno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getPerfilUsuario(): PerfilUsuario | null {
|
||||||
|
let retorno: PerfilUsuario | null = null;
|
||||||
|
const jsonUsuario = sessionStorage.getItem("perfilUsuario") ?? "";
|
||||||
|
try {
|
||||||
|
const objJwt = <PerfilUsuario>JSON.parse(jsonUsuario);
|
||||||
|
retorno = objJwt;
|
||||||
|
} catch (error) {
|
||||||
|
retorno = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return retorno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getHighUserProfile(): number {
|
||||||
|
let retorno = 6;
|
||||||
|
const objPerfil = GlobalFunctions.getPerfilUsuario();
|
||||||
|
|
||||||
|
if (objPerfil) {
|
||||||
|
const tiposPerfil: number[] = objPerfil.results.map((v) => v.tipoPerfil);
|
||||||
|
retorno = Math.min(...tiposPerfil);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retorno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getToken(): Promise<string> {
|
||||||
|
let token: string = GlobalFunctions.getUsuarioLogadoToken();
|
||||||
|
|
||||||
|
const tokenDecode: any = GlobalFunctions.getUsuarioLogado();
|
||||||
|
|
||||||
|
let currentDate = new Date();
|
||||||
|
|
||||||
|
// JWT exp is in seconds
|
||||||
|
if ((tokenDecode.exp * 1000) < currentDate.getTime()) {
|
||||||
|
//console.log("Token expired.");
|
||||||
|
let gsikey: number = parseInt(sessionStorage.getItem('gsikey') ?? '0');
|
||||||
|
RedirectService.loadTransferArea(gsikey).then((response) => {
|
||||||
|
if(response.data.errorCode == 0){
|
||||||
|
sessionStorage.setItem('TRANSFER_AREA',JSON.stringify(response.data.areTrs));
|
||||||
|
sessionStorage.setItem('usuarioLogado',JSON.stringify({
|
||||||
|
token: response.data.jwt.token,
|
||||||
|
refreshToken: response.data.jwt.refreshToken
|
||||||
|
}));
|
||||||
|
|
||||||
|
token = response.data.jwt.token;
|
||||||
|
}
|
||||||
|
// else if(error !== 1401){
|
||||||
|
// navigate('/',{replace: true});
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// else {
|
||||||
|
// //console.log("Valid token");
|
||||||
|
// result = true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UsuarioLogadoData {
|
||||||
|
UID: string;
|
||||||
|
EID: string;
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
jti: string;
|
||||||
|
nbf: number;
|
||||||
|
exp: number;
|
||||||
|
iat: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TransferAreaResponse {
|
||||||
|
estabelecimentoID: number;
|
||||||
|
nivelAcesso: number;
|
||||||
|
aplicativoID: number;
|
||||||
|
usuarioID: number;
|
||||||
|
areaTransferenciaID: number;
|
||||||
|
dataRegistro: string;
|
||||||
|
urlBase?: string;
|
||||||
|
urlDestino?: string;
|
||||||
|
aplicativoNome: string;
|
||||||
|
usuarioNome: string;
|
||||||
|
usuarioEmail: string;
|
||||||
|
aplicativoShareCode: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TransferAreaProperties {
|
||||||
|
EstabelecimentoCodigo = "estabelecimentoID",
|
||||||
|
UsuarioCodigo = "usuarioID",
|
||||||
|
UsuarioNome = "usuarioNome",
|
||||||
|
UsuarioEmail = "usuarioEmail",
|
||||||
|
APP_COD = "aplicativoID",
|
||||||
|
APP_TITULO = "aplicativoNome",
|
||||||
|
areaTransferenciaID = "areaTransferenciaID",
|
||||||
|
urlBase = "urlBase",
|
||||||
|
urlDestino = "urlDestino",
|
||||||
|
aplicativoShareCode = "aplicativoShareCode",
|
||||||
|
nivelAcesso = "nivelAcesso",
|
||||||
|
}
|
||||||
|
|
||||||
|
type PerfilUsuario = {
|
||||||
|
errorCode: number;
|
||||||
|
errorMessage: string;
|
||||||
|
results: PerfilUsuarioResult[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PerfilUsuarioResult = {
|
||||||
|
tipoPerfil: number;
|
||||||
|
itens: PerfilUsuarioItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type PerfilUsuarioItem = {
|
||||||
|
id: number;
|
||||||
|
descricao: string;
|
||||||
|
identificador: string;
|
||||||
|
};
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { Loader2 } from "lucide-react";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
interface FullScreenLoaderProps {
|
||||||
|
show: boolean;
|
||||||
|
text?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function FullScreenLoader({ show, text = "Carregando..." }: FullScreenLoaderProps) {
|
||||||
|
const [visible, setVisible] = useState(show);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (show) setVisible(true);
|
||||||
|
else {
|
||||||
|
// adiciona um pequeno atraso para suavizar o fade-out
|
||||||
|
const timeout = setTimeout(() => setVisible(false), 200);
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
}
|
||||||
|
}, [show]);
|
||||||
|
|
||||||
|
if (!visible && !show) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`fixed inset-0 z-[9999] flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200 ${
|
||||||
|
show ? "opacity-100" : "opacity-0 pointer-events-none"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div className="flex flex-col items-center gap-3 p-6 rounded-2xl bg-card shadow-lg border border-border transition-all duration-200">
|
||||||
|
<Loader2 className="h-10 w-10 animate-spin text-primary" />
|
||||||
|
<p className="text-card-foreground text-sm font-medium">{text}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { MessageSquare, Image, AudioLines, Mic, ArrowLeft, Plus, ChevronLeft, Ch
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { ThemeToggle } from "@/components/ThemeToggle";
|
import { ThemeToggle } from "@/components/ThemeToggle";
|
||||||
|
import { GlobalFunctions } from "@/GlobalFunctions";
|
||||||
|
|
||||||
interface LayoutProps {
|
interface LayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@@ -75,7 +76,7 @@ export const Layout = ({ children, activeTab, onTabChange }: LayoutProps) => {
|
|||||||
<span className="text-sm font-medium text-sidebar-foreground">Tema</span>
|
<span className="text-sm font-medium text-sidebar-foreground">Tema</span>
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
</div>
|
</div>
|
||||||
<Button variant="ghost" className="w-full justify-start gap-2 text-sidebar-foreground">
|
<Button onClick={GlobalFunctions.handleNavigateBack} variant="ghost" className="w-full justify-start gap-2 text-sidebar-foreground">
|
||||||
<ArrowLeft className="w-4 h-4" />
|
<ArrowLeft className="w-4 h-4" />
|
||||||
Voltar
|
Voltar
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
+25
-15
@@ -7,6 +7,7 @@ import { GenerationView } from "@/components/audio/GenerationView";
|
|||||||
import { BotView } from "@/components/bots/BotView";
|
import { BotView } from "@/components/bots/BotView";
|
||||||
import { BotChat } from "@/components/bots/BotChat";
|
import { BotChat } from "@/components/bots/BotChat";
|
||||||
import { AgentView } from "@/components/agent/AgentView";
|
import { AgentView } from "@/components/agent/AgentView";
|
||||||
|
import { Navigate, Route, Routes } from "react-router-dom";
|
||||||
|
|
||||||
interface Bot {
|
interface Bot {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -27,21 +28,30 @@ const Index = () => {
|
|||||||
setActiveBotChat(null);
|
setActiveBotChat(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (<Routes>
|
||||||
<Layout activeTab={activeView} onTabChange={setActiveView}>
|
<Route path="" element={<Navigate to={`/404`} replace />} />
|
||||||
{activeView === "chat" && <ChatView />}
|
<Route path="codex">
|
||||||
{activeView === "images" && <ImageView />}
|
<Route path="" element={
|
||||||
{activeView === "transcription" && <TranscriptionView />}
|
<Layout activeTab={activeView} onTabChange={setActiveView}>
|
||||||
{activeView === "generation" && <GenerationView />}
|
{activeView === "chat" && <ChatView />}
|
||||||
{activeView === "bots" && (
|
{activeView === "images" && <ImageView />}
|
||||||
activeBotChat ? (
|
{activeView === "transcription" && <TranscriptionView />}
|
||||||
<BotChat bot={activeBotChat} onBack={handleBackFromBotChat} />
|
{activeView === "generation" && <GenerationView />}
|
||||||
) : (
|
{activeView === "bots" && (
|
||||||
<BotView onStartChat={handleStartBotChat} />
|
activeBotChat ? (
|
||||||
)
|
<BotChat bot={activeBotChat} onBack={handleBackFromBotChat} />
|
||||||
)}
|
) : (
|
||||||
{activeView === "agent" && <AgentView />}
|
<BotView onStartChat={handleStartBotChat} />
|
||||||
</Layout>
|
)
|
||||||
|
)}
|
||||||
|
{activeView === "agent" && <AgentView />}
|
||||||
|
</Layout>
|
||||||
|
} />
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
<Route path="*" element={<Navigate to={`/404`} replace />} />
|
||||||
|
</Routes>
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import FullScreenLoader from "@/components/FullScreenLoader";
|
||||||
|
import { GlobalFunctions } from "@/GlobalFunctions";
|
||||||
|
import { RedirectService } from "./RedirectService";
|
||||||
|
import React from "react";
|
||||||
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function Redirect() {
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
let { gsikey } = useParams();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
let error: number = 0;
|
||||||
|
sessionStorage.setItem('gsikey', gsikey ?? '0');
|
||||||
|
RedirectService.loadTransferArea(parseInt(gsikey ?? '0')).then((response) => {
|
||||||
|
//console.log(response);
|
||||||
|
error = response.data.errorCode;
|
||||||
|
//msg = response.data.errorMessage;
|
||||||
|
if(response.data.errorCode == 0){
|
||||||
|
sessionStorage.setItem('TRANSFER_AREA',JSON.stringify(response.data.areTrs));
|
||||||
|
sessionStorage.setItem('usuarioLogado',JSON.stringify({
|
||||||
|
token: response.data.jwt.token,
|
||||||
|
refreshToken: response.data.jwt.refreshToken
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
// else if(error !== 1401){
|
||||||
|
// navigate('/',{replace: true});
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
.catch((_err) => {
|
||||||
|
navigate('/404',{replace: true});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if(error == 0 || error === 1401){
|
||||||
|
navigate(`/${GlobalFunctions.getRedirectComponent()}`,{replace: true});
|
||||||
|
}
|
||||||
|
// else if(error === 1401){
|
||||||
|
// navigate({pathname: '/',search:`?p=${window.btoa(msg)}`},{replace: true});
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FullScreenLoader show={true} text="Carregando...Aguarde..." />
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { GlobalFunctions, TransferAreaProperties } from "@/GlobalFunctions";
|
||||||
|
import axios from "axios";
|
||||||
|
const endPoint: string = 'v1/login/';
|
||||||
|
|
||||||
|
export class RedirectService{
|
||||||
|
|
||||||
|
public static loadTransferArea(gsikey: number): Promise<any>{
|
||||||
|
return axios.post(`${import.meta.env.VITE_BASE_URL_OPEN_CODEX_APIs}${endPoint}login_by_gsikey`,{
|
||||||
|
"gsikey" : gsikey
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async validaAcessoApp(urlDestino: string): Promise<any>{
|
||||||
|
//let token = await GlobalFunctions.getToken();
|
||||||
|
let usuLogado = GlobalFunctions.getUsuarioLogado();
|
||||||
|
let usuCod: string = GlobalFunctions.getTransferProperty(TransferAreaProperties.UsuarioCodigo);
|
||||||
|
let estCod: string = usuLogado.EID;
|
||||||
|
|
||||||
|
let urlDestinoPost: string = urlDestino;//urlDestino.trim().length < 1 ? GlobalFunctions.getTransferProperty(TransferAreaProperties.urlDestino) : urlDestino;
|
||||||
|
if(urlDestinoPost.trim().length < 1){
|
||||||
|
try {
|
||||||
|
let pathSplit = window.location.pathname.split('/');
|
||||||
|
|
||||||
|
urlDestinoPost = `/${pathSplit[pathSplit.length-2]}/${pathSplit[pathSplit.length-1]}`;
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//const heads = { headers: {'Content-Type':'application/json; charset=utf-8','Authorization': `Bearer ${token}`} };
|
||||||
|
const heads = { headers: {'Content-Type':'application/json; charset=utf-8'} };
|
||||||
|
return axios.post(`${import.meta.env.VITE_BASE_URL_HGTX_CORE_API}v1/aplicativos/validar_acesso_app?usuCod=${usuCod}&estCod=${estCod}`,{
|
||||||
|
"urlDestino": urlDestinoPost
|
||||||
|
},heads);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { GlobalFunctions, TransferAreaProperties } from '@/GlobalFunctions';
|
||||||
import { apiService } from './api';
|
import { apiService } from './api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,8 +84,8 @@ class AudioGenerationService {
|
|||||||
const { message, voice, userEmail, estabelecimentoId } = request;
|
const { message, voice, userEmail, estabelecimentoId } = request;
|
||||||
|
|
||||||
// Usa valores do .env se não forem fornecidos
|
// Usa valores do .env se não forem fornecidos
|
||||||
const email = userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
const email = GlobalFunctions.getTransferProperty(TransferAreaProperties.UsuarioEmail);//userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
||||||
const estabId = estabelecimentoId || parseInt(import.meta.env.VITE_ESTABELECIMENTO_ID) || 1;
|
const estabId = GlobalFunctions.getTransferProperty(TransferAreaProperties.EstabelecimentoCodigo);//estabelecimentoId || parseInt(import.meta.env.VITE_ESTABELECIMENTO_ID) || 1;
|
||||||
|
|
||||||
// Valida o texto
|
// Valida o texto
|
||||||
if (!message || message.trim().length === 0) {
|
if (!message || message.trim().length === 0) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { GlobalFunctions, TransferAreaProperties } from '@/GlobalFunctions';
|
||||||
import { apiService } from './api';
|
import { apiService } from './api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,8 +127,8 @@ class ChatService {
|
|||||||
} = request;
|
} = request;
|
||||||
|
|
||||||
// Usa valores do .env se não forem fornecidos
|
// Usa valores do .env se não forem fornecidos
|
||||||
const email = userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
const email = GlobalFunctions.getTransferProperty(TransferAreaProperties.UsuarioEmail);//userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
||||||
const estabId = estabelecimentoId || import.meta.env.VITE_ESTABELECIMENTO_ID || '';
|
const estabId = GlobalFunctions.getTransferProperty(TransferAreaProperties.EstabelecimentoCodigo);//estabelecimentoId || import.meta.env.VITE_ESTABELECIMENTO_ID || '';
|
||||||
|
|
||||||
// Validações
|
// Validações
|
||||||
if (!chatId) {
|
if (!chatId) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { GlobalFunctions, TransferAreaProperties } from '@/GlobalFunctions';
|
||||||
import { apiService } from './api';
|
import { apiService } from './api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,8 +66,8 @@ class ImageGenerationService {
|
|||||||
const { description, size, userEmail, estabelecimentoId } = request;
|
const { description, size, userEmail, estabelecimentoId } = request;
|
||||||
|
|
||||||
// Usa valores do .env se não forem fornecidos
|
// Usa valores do .env se não forem fornecidos
|
||||||
const email = userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
const email = GlobalFunctions.getTransferProperty(TransferAreaProperties.UsuarioEmail);//userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
||||||
const estabId = estabelecimentoId || parseInt(import.meta.env.VITE_ESTABELECIMENTO_ID) || 1;
|
const estabId = GlobalFunctions.getTransferProperty(TransferAreaProperties.EstabelecimentoCodigo);//estabelecimentoId || parseInt(import.meta.env.VITE_ESTABELECIMENTO_ID) || 1;
|
||||||
|
|
||||||
// Valida a descrição
|
// Valida a descrição
|
||||||
if (!description || description.trim().length === 0) {
|
if (!description || description.trim().length === 0) {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { GlobalFunctions, TransferAreaProperties } from '@/GlobalFunctions';
|
||||||
import { apiService } from './api';
|
import { apiService } from './api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,8 +40,8 @@ class TranscriptionService {
|
|||||||
formData.append('data', audioFile);
|
formData.append('data', audioFile);
|
||||||
|
|
||||||
// Usa valores do .env se não forem fornecidos
|
// Usa valores do .env se não forem fornecidos
|
||||||
const email = userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
const email = GlobalFunctions.getTransferProperty(TransferAreaProperties.UsuarioEmail);//userEmail || import.meta.env.VITE_USER_EMAIL || '';
|
||||||
const estabId = estabelecimentoId || import.meta.env.VITE_ESTABELECIMENTO_ID || '';
|
const estabId = GlobalFunctions.getTransferProperty(TransferAreaProperties.EstabelecimentoCodigo);//estabelecimentoId || import.meta.env.VITE_ESTABELECIMENTO_ID || '';
|
||||||
|
|
||||||
formData.append('user_email', email);
|
formData.append('user_email', email);
|
||||||
formData.append('estabelecimento_id', estabId.toString());
|
formData.append('estabelecimento_id', estabId.toString());
|
||||||
|
|||||||
Vendored
+3
@@ -5,6 +5,9 @@ interface ImportMetaEnv {
|
|||||||
readonly VITE_API_KEY: string
|
readonly VITE_API_KEY: string
|
||||||
readonly VITE_USER_EMAIL: string
|
readonly VITE_USER_EMAIL: string
|
||||||
readonly VITE_ESTABELECIMENTO_ID: string
|
readonly VITE_ESTABELECIMENTO_ID: string
|
||||||
|
readonly VITE_BASE_URL_OPEN_CODEX_APIs: string
|
||||||
|
readonly VITE_BASE_URL_HGTX_CORE_API: string
|
||||||
|
readonly VITE_BASE_URL_HGTX_CORE: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|
|||||||
Reference in New Issue
Block a user