Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@
# Admin credentials
VITE_ADMIN_EMAIL=admin@example.com
VITE_ADMIN_PASSWORD=adminpassword

# EmailJS configuration
VITE_EMAILJS_SERVICE_ID=your_service_id
VITE_EMAILJS_TEMPLATE_ID=your_template_id
VITE_EMAILJS_USER_ID=your_user_id
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
<body class="overflow-hidden">
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script src="https://api.tempolabs.ai/proxy-asset?url=https://storage.googleapis.com/tempo-public-assets/error-handling.js"></script>
</body>
</html>
1,367 changes: 653 additions & 714 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"preview": "vite preview"
},
"dependencies": {
"@emailjs/browser": "^4.1.0",
"lucide-react": "^0.344.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand All @@ -30,7 +29,6 @@
"globals": "^15.9.0",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"tempo-devtools": "^2.0.109",
"typescript": "^5.5.3",
"typescript-eslint": "^8.46.0",
"vite": "^6.3.6"
Expand Down
25 changes: 1 addition & 24 deletions src/components/chat/useChatState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react";
import emailjs from "@emailjs/browser";
import { MessageType, ChatState } from "./types";
import { Translation } from "../../config/i18n";

Expand All @@ -11,29 +10,7 @@ export const useChatState = (t: Translation) => {
isAdmin: false,
});

const setUserName = async (name: string, chatLanguage: "fr" | "en") => {
try {
// Use environment variables for sensitive information
const serviceId =
import.meta.env.VITE_EMAILJS_SERVICE_ID || "service_w523fo9";
const templateId =
import.meta.env.VITE_EMAILJS_TEMPLATE_ID || "template_oxo5oyw";
const userId =
import.meta.env.VITE_EMAILJS_USER_ID || "AdrLQxBNJX5QgN1ZX";

await emailjs.send(
serviceId,
templateId,
{
user_name: name,
date: new Date().toLocaleString(),
},
userId,
);
} catch (error) {
console.error("Failed to send email notification:", error);
}

const setUserName = (name: string, chatLanguage: "fr" | "en") => {
setState((prev) => ({
...prev,
userName: name,
Expand Down
4 changes: 0 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { createRoot } from "react-dom/client";
import { RouterProvider } from "react-router-dom";
import { router } from "./routes";
import "./index.css";
import { TempoDevtools } from "tempo-devtools";

// Initialize Tempo Devtools
TempoDevtools.init();

createRoot(document.getElementById("root")!).render(
<StrictMode>
Expand Down
3 changes: 0 additions & 3 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { createBrowserRouter } from "react-router-dom";
import App from "../App";
import LiveChat from "../pages/LiveChat";
import routes from "tempo-routes";

export const router = createBrowserRouter([
// For the tempo routes
...(import.meta.env.VITE_TEMPO ? routes : []),
{
path: "/",
element: <App />,
Expand Down
18 changes: 1 addition & 17 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { defineConfig } from "vite";
import type { ServerOptions } from "vite";
import react from "@vitejs/plugin-react";
import { tempo } from "tempo-devtools/dist/vite"; // Add Tempo import

// Add conditional plugins for Tempo
const conditionalPlugins = [];
if (process.env.TEMPO === "true") {
conditionalPlugins.push("tempo-devtools/dist/babel-plugin");
}

const allowedHosts: ServerOptions["allowedHosts"] | undefined =
process.env.TEMPO === "true" ? true : undefined;

const serverConfig: ServerOptions = {
port: 3000,
...(allowedHosts !== undefined ? { allowedHosts } : {}),
headers: {
'Cross-Origin-Embedder-Policy': 'credentialless',
'Cross-Origin-Opener-Policy': 'same-origin',
Expand All @@ -24,12 +13,7 @@ const serverConfig: ServerOptions = {

export default defineConfig({
plugins: [
react({
babel: {
plugins: [...conditionalPlugins],
},
}),
tempo(), // Add the tempo plugin
react(),
],
server: serverConfig,
build: {
Expand Down