Compare commits
4 Commits
658b9f0257
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cbb6771de | |||
| 4f10582599 | |||
| 43639e4de7 | |||
| 893b64737d |
@@ -0,0 +1,23 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# Stage 1: Build frontend
|
||||||
|
FROM node:20-alpine AS frontend-builder
|
||||||
|
WORKDIR /app/frontend
|
||||||
|
COPY crmDashboard/package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY crmDashboard/ ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Bun backend
|
||||||
|
FROM oven/bun:1-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY backend/package.json backend/bun.lockb* ./
|
||||||
|
RUN bun install --production
|
||||||
|
|
||||||
|
COPY backend/ ./
|
||||||
|
COPY --from=frontend-builder /app/frontend/dist ./public
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["bun", "run", "server.js"]
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "crm-backend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"start": "bun server.js"
|
||||||
|
},
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
const PUBLIC_DIR = './public'
|
||||||
|
const PORT = process.env.PORT ? Number(process.env.PORT) : 3000
|
||||||
|
|
||||||
|
function getContentType(path) {
|
||||||
|
if (path.endsWith('.html')) return 'text/html'
|
||||||
|
if (path.endsWith('.js')) return 'application/javascript'
|
||||||
|
if (path.endsWith('.css')) return 'text/css'
|
||||||
|
if (path.endsWith('.json')) return 'application/json'
|
||||||
|
if (path.endsWith('.png')) return 'image/png'
|
||||||
|
if (path.endsWith('.jpg') || path.endsWith('.jpeg')) return 'image/jpeg'
|
||||||
|
if (path.endsWith('.svg')) return 'image/svg+xml'
|
||||||
|
if (path.endsWith('.woff2')) return 'font/woff2'
|
||||||
|
if (path.endsWith('.woff')) return 'font/woff'
|
||||||
|
if (path.endsWith('.ttf')) return 'font/ttf'
|
||||||
|
return 'application/octet-stream'
|
||||||
|
}
|
||||||
|
|
||||||
|
Bun.serve({
|
||||||
|
port: PORT,
|
||||||
|
async fetch(req) {
|
||||||
|
const url = new URL(req.url)
|
||||||
|
|
||||||
|
if (url.pathname === '/health') {
|
||||||
|
return new Response('OK', { status: 200 })
|
||||||
|
}
|
||||||
|
|
||||||
|
const filePath = url.pathname === '/' ? '/index.html' : url.pathname
|
||||||
|
const fullPath = `${PUBLIC_DIR}${filePath}`
|
||||||
|
const file = Bun.file(fullPath)
|
||||||
|
|
||||||
|
if (await file.exists()) {
|
||||||
|
return new Response(file, {
|
||||||
|
headers: { 'Content-Type': getContentType(filePath) },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SPA fallback
|
||||||
|
const indexFile = Bun.file(`${PUBLIC_DIR}/index.html`)
|
||||||
|
if (await indexFile.exists()) {
|
||||||
|
return new Response(indexFile, {
|
||||||
|
headers: { 'Content-Type': 'text/html' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response('Not Found', { status: 404 })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(`Server running on http://localhost:${PORT}`)
|
||||||
@@ -8,7 +8,7 @@ pnpm-debug.log*
|
|||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
#dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
|
||||||
|
|||||||
+206
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.3 KiB |
Vendored
+24
@@ -0,0 +1,24 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||||
|
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||||
|
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||||
|
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||||
|
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||||
|
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||||
|
</symbol>
|
||||||
|
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||||
|
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||||
|
</symbol>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.9 KiB |
Vendored
+16
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="dark">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Panel de Campañas</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet" />
|
||||||
|
<script type="module" crossorigin src="/assets/index-BB6EjotN.js"></script>
|
||||||
|
<link rel="stylesheet" crossorigin href="/assets/index-Dp8mftuy.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Generated
+132
@@ -12,11 +12,13 @@
|
|||||||
"@emotion/styled": "^11.14.1",
|
"@emotion/styled": "^11.14.1",
|
||||||
"@mui/icons-material": "^9.0.1",
|
"@mui/icons-material": "^9.0.1",
|
||||||
"@mui/material": "^9.0.1",
|
"@mui/material": "^9.0.1",
|
||||||
|
"@mui/x-date-pickers": "^9.5.0",
|
||||||
"@supabase/supabase-js": "^2.106.2",
|
"@supabase/supabase-js": "^2.106.2",
|
||||||
"@tailwindcss/vite": "^4.3.0",
|
"@tailwindcss/vite": "^4.3.0",
|
||||||
"@tanstack/react-query": "^5.100.14",
|
"@tanstack/react-query": "^5.100.14",
|
||||||
"@tanstack/react-router": "^1.170.10",
|
"@tanstack/react-router": "^1.170.10",
|
||||||
"autoprefixer": "^10.5.0",
|
"autoprefixer": "^10.5.0",
|
||||||
|
"dayjs": "^1.11.21",
|
||||||
"postcss": "^8.5.15",
|
"postcss": "^8.5.15",
|
||||||
"react": "^19.2.6",
|
"react": "^19.2.6",
|
||||||
"react-dom": "^19.2.6",
|
"react-dom": "^19.2.6",
|
||||||
@@ -928,6 +930,124 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@mui/x-date-pickers": {
|
||||||
|
"version": "9.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mui/x-date-pickers/-/x-date-pickers-9.5.0.tgz",
|
||||||
|
"integrity": "sha512-Pzd8gU2qOoIAUMMesjbrq3gFs6akWXcSsEkFIHVA4dtuoh6SeWISu+WR+ymq/sBOcn2tk9IBIjqRQkqLhkm+tg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.29.7",
|
||||||
|
"@mui/utils": "9.0.1",
|
||||||
|
"@mui/x-internals": "^9.1.0",
|
||||||
|
"@types/react-transition-group": "^4.4.12",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"prop-types": "^15.8.1",
|
||||||
|
"react-transition-group": "^4.4.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/mui-org"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@emotion/react": "^11.9.0",
|
||||||
|
"@emotion/styled": "^11.8.1",
|
||||||
|
"@mui/material": "^7.3.0 || ^9.0.0",
|
||||||
|
"@mui/system": "^7.3.0 || ^9.0.0",
|
||||||
|
"date-fns": "^2.25.0 || ^3.2.0 || ^4.0.0",
|
||||||
|
"date-fns-jalali": "^2.13.0-0 || ^3.2.0-0 || ^4.0.0-0",
|
||||||
|
"dayjs": "^1.10.7",
|
||||||
|
"luxon": "^3.0.2",
|
||||||
|
"moment": "^2.29.4",
|
||||||
|
"moment-hijri": "^2.1.2 || ^3.0.0",
|
||||||
|
"moment-jalaali": "^0.7.4 || ^0.8.0 || ^0.9.0 || ^0.10.0",
|
||||||
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||||
|
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@emotion/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@emotion/styled": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"date-fns": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"date-fns-jalali": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"dayjs": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"luxon": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"moment": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"moment-hijri": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"moment-jalaali": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@mui/x-internals": {
|
||||||
|
"version": "9.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-9.1.0.tgz",
|
||||||
|
"integrity": "sha512-fVezTa1lU+Hb3y9UMI8D/iWXADhs0I8PaZqoh2LOUXjGEUJmKqwsRD19ZXInZsH2yu+YS0dqYMPDvzjYTTyo+Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.29.2",
|
||||||
|
"@mui/utils": "9.0.0",
|
||||||
|
"reselect": "^5.1.1",
|
||||||
|
"use-sync-external-store": "^1.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/mui-org"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@mui/x-internals/node_modules/@mui/utils": {
|
||||||
|
"version": "9.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mui/utils/-/utils-9.0.0.tgz",
|
||||||
|
"integrity": "sha512-bQcqyg/gjULUqTuyUjSAFr6LQGLvtkNtDbJerAtoUn9kGZ0hg5QJiN1PLHMLbeFpe3te1831uq7GFl2ITokGdg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.29.2",
|
||||||
|
"@mui/types": "^9.0.0",
|
||||||
|
"@types/prop-types": "^15.7.15",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"prop-types": "^15.8.1",
|
||||||
|
"react-is": "^19.2.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/mui-org"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||||
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@napi-rs/wasm-runtime": {
|
"node_modules/@napi-rs/wasm-runtime": {
|
||||||
"version": "1.1.4",
|
"version": "1.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz",
|
||||||
@@ -2016,6 +2136,12 @@
|
|||||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/dayjs": {
|
||||||
|
"version": "1.11.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.21.tgz",
|
||||||
|
"integrity": "sha512-98IT+HOahAisibz/yjKbzuOBwYcjJ7BCLPzARyHiyEBmRz4fatF+KPJszEHXsGYjUG234aH/cOjW1wwTbKUZlA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
"version": "4.4.3",
|
"version": "4.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||||
@@ -3326,6 +3452,12 @@
|
|||||||
"react-dom": ">=16.6.0"
|
"react-dom": ">=16.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/reselect": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/reselect/-/reselect-5.2.0.tgz",
|
||||||
|
"integrity": "sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/resolve": {
|
"node_modules/resolve": {
|
||||||
"version": "1.22.12",
|
"version": "1.22.12",
|
||||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz",
|
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz",
|
||||||
|
|||||||
@@ -14,11 +14,13 @@
|
|||||||
"@emotion/styled": "^11.14.1",
|
"@emotion/styled": "^11.14.1",
|
||||||
"@mui/icons-material": "^9.0.1",
|
"@mui/icons-material": "^9.0.1",
|
||||||
"@mui/material": "^9.0.1",
|
"@mui/material": "^9.0.1",
|
||||||
|
"@mui/x-date-pickers": "^9.5.0",
|
||||||
"@supabase/supabase-js": "^2.106.2",
|
"@supabase/supabase-js": "^2.106.2",
|
||||||
"@tailwindcss/vite": "^4.3.0",
|
"@tailwindcss/vite": "^4.3.0",
|
||||||
"@tanstack/react-query": "^5.100.14",
|
"@tanstack/react-query": "^5.100.14",
|
||||||
"@tanstack/react-router": "^1.170.10",
|
"@tanstack/react-router": "^1.170.10",
|
||||||
"autoprefixer": "^10.5.0",
|
"autoprefixer": "^10.5.0",
|
||||||
|
"dayjs": "^1.11.21",
|
||||||
"postcss": "^8.5.15",
|
"postcss": "^8.5.15",
|
||||||
"react": "^19.2.6",
|
"react": "^19.2.6",
|
||||||
"react-dom": "^19.2.6",
|
"react-dom": "^19.2.6",
|
||||||
|
|||||||
@@ -47,13 +47,15 @@ export default function AppShell() {
|
|||||||
<Tabs
|
<Tabs
|
||||||
value={location.pathname}
|
value={location.pathname}
|
||||||
onChange={(_e, path) => navigate({ to: path })}
|
onChange={(_e, path) => navigate({ to: path })}
|
||||||
variant="fullWidth"
|
variant="scrollable"
|
||||||
|
scrollButtons="auto"
|
||||||
textColor="primary"
|
textColor="primary"
|
||||||
indicatorColor="primary"
|
indicatorColor="primary"
|
||||||
>
|
>
|
||||||
<Tab label="Campañas" value="/campaigns" />
|
<Tab label="Campañas" value="/campaigns" />
|
||||||
<Tab label="Sesiones" value="/sessions" />
|
<Tab label="Sesiones" value="/sessions" />
|
||||||
<Tab label="Archivos" value="/media" />
|
<Tab label="Archivos" value="/media" />
|
||||||
|
<Tab label="Instancias" value="/instances" />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Paper>
|
</Paper>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ function ThemedRoot() {
|
|||||||
MuiCard: {
|
MuiCard: {
|
||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
root: {
|
root: {
|
||||||
border: '1px solid #27272a',
|
border: mode === 'dark' ? '1px solid #27272a' : '1px solid #e4e4e7',
|
||||||
backgroundImage: 'none',
|
backgroundImage: 'none',
|
||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
borderRadius: 20,
|
borderRadius: 20,
|
||||||
@@ -46,8 +46,8 @@ function ThemedRoot() {
|
|||||||
MuiAppBar: {
|
MuiAppBar: {
|
||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
root: {
|
root: {
|
||||||
backgroundColor: '#18181b',
|
backgroundColor: mode === 'dark' ? '#18181b' : '#ffffff',
|
||||||
borderBottom: '1px solid #27272a',
|
borderBottom: mode === 'dark' ? '1px solid #27272a' : '1px solid #e4e4e7',
|
||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -55,8 +55,8 @@ function ThemedRoot() {
|
|||||||
MuiDrawer: {
|
MuiDrawer: {
|
||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
paper: {
|
paper: {
|
||||||
backgroundColor: '#18181b',
|
backgroundColor: mode === 'dark' ? '#18181b' : '#ffffff',
|
||||||
borderRight: '1px solid #27272a',
|
borderRight: mode === 'dark' ? '1px solid #27272a' : '1px solid #e4e4e7',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import CampaignIcon from '@mui/icons-material/Campaign'
|
import CampaignIcon from '@mui/icons-material/Campaign'
|
||||||
import ChatIcon from '@mui/icons-material/Chat'
|
import ChatIcon from '@mui/icons-material/Chat'
|
||||||
import PermMediaIcon from '@mui/icons-material/PermMedia'
|
import PermMediaIcon from '@mui/icons-material/PermMedia'
|
||||||
|
import DnsIcon from '@mui/icons-material/Dns'
|
||||||
import { Link, useLocation } from '@tanstack/react-router'
|
import { Link, useLocation } from '@tanstack/react-router'
|
||||||
|
|
||||||
const DRAWER_WIDTH = 240
|
const DRAWER_WIDTH = 240
|
||||||
@@ -19,6 +20,7 @@ const items = [
|
|||||||
{ path: '/campaigns', label: 'Campañas', icon: <CampaignIcon /> },
|
{ path: '/campaigns', label: 'Campañas', icon: <CampaignIcon /> },
|
||||||
{ path: '/sessions', label: 'Sesiones', icon: <ChatIcon /> },
|
{ path: '/sessions', label: 'Sesiones', icon: <ChatIcon /> },
|
||||||
{ path: '/media', label: 'Archivos', icon: <PermMediaIcon /> },
|
{ path: '/media', label: 'Archivos', icon: <PermMediaIcon /> },
|
||||||
|
{ path: '/instances', label: 'Instancias', icon: <DnsIcon /> },
|
||||||
]
|
]
|
||||||
|
|
||||||
export default function Sidebar({ collapsed }) {
|
export default function Sidebar({ collapsed }) {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export default function TopBar({
|
|||||||
return (
|
return (
|
||||||
<AppBar
|
<AppBar
|
||||||
position="fixed"
|
position="fixed"
|
||||||
|
color="default"
|
||||||
sx={{
|
sx={{
|
||||||
width: { md: `calc(100% - ${collapsed ? 72 : 240}px)` },
|
width: { md: `calc(100% - ${collapsed ? 72 : 240}px)` },
|
||||||
ml: { md: `${collapsed ? 72 : 240}px` },
|
ml: { md: `${collapsed ? 72 : 240}px` },
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
import { useState, useEffect } from 'react'
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardMedia,
|
||||||
|
Typography,
|
||||||
|
Box,
|
||||||
|
IconButton,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
Skeleton,
|
||||||
|
} from '@mui/material'
|
||||||
|
import MoreVertIcon from '@mui/icons-material/MoreVert'
|
||||||
|
|
||||||
|
export default function InstanceCard({ instance }) {
|
||||||
|
const [anchor, setAnchor] = useState(null)
|
||||||
|
const [showScreenshot, setShowScreenshot] = useState(false)
|
||||||
|
const [qrUrl, setQrUrl] = useState(null)
|
||||||
|
const [qrLoading, setQrLoading] = useState(true)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchQr = async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch(instance.qr_url, {
|
||||||
|
headers: { xtoken: instance.token },
|
||||||
|
})
|
||||||
|
if (!response.ok) throw new Error('Failed to fetch QR')
|
||||||
|
const { mimetype, data } = await response.json()
|
||||||
|
setQrUrl(`data:${mimetype};base64,${data}`)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('QR fetch error:', err)
|
||||||
|
} finally {
|
||||||
|
setQrLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchQr()
|
||||||
|
}, [instance.qr_url, instance.token])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card
|
||||||
|
sx={{
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
transition: 'transform 0.15s, box-shadow 0.15s',
|
||||||
|
'&:hover': {
|
||||||
|
transform: 'translateY(-2px)',
|
||||||
|
boxShadow: 4,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ position: 'relative' }}>
|
||||||
|
{qrLoading ? (
|
||||||
|
<Skeleton
|
||||||
|
variant="rectangular"
|
||||||
|
sx={{ width: '100%', aspectRatio: '1', bgcolor: 'grey.100' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<CardMedia
|
||||||
|
component="img"
|
||||||
|
image={qrUrl}
|
||||||
|
alt={`QR ${instance.name}`}
|
||||||
|
sx={{
|
||||||
|
width: '100%',
|
||||||
|
height: 'auto',
|
||||||
|
objectFit: 'contain',
|
||||||
|
bgcolor: 'grey.50',
|
||||||
|
p: 2,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<IconButton
|
||||||
|
onClick={(e) => setAnchor(e.currentTarget)}
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 8,
|
||||||
|
right: 8,
|
||||||
|
bgcolor: 'rgba(0,0,0,0.55)',
|
||||||
|
color: 'white',
|
||||||
|
'&:hover': { bgcolor: 'rgba(0,0,0,0.75)' },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MoreVertIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
<CardContent sx={{ flexGrow: 1, pb: 2 }}>
|
||||||
|
<Typography variant="subtitle1" sx={{ fontWeight: 700, lineHeight: 1.3 }}>
|
||||||
|
{instance.name}
|
||||||
|
</Typography>
|
||||||
|
{instance.description && (
|
||||||
|
<Typography variant="body2" color="text.secondary" sx={{ mt: 0.5, lineHeight: 1.5 }}>
|
||||||
|
{instance.description}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
<Menu anchorEl={anchor} open={Boolean(anchor)} onClose={() => setAnchor(null)}>
|
||||||
|
<MenuItem
|
||||||
|
onClick={() => {
|
||||||
|
setAnchor(null)
|
||||||
|
setShowScreenshot(true)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Ver screenshot
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
<Dialog
|
||||||
|
open={showScreenshot}
|
||||||
|
onClose={() => setShowScreenshot(false)}
|
||||||
|
maxWidth="lg"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
<DialogContent sx={{ p: 0, lineHeight: 0 }}>
|
||||||
|
<img
|
||||||
|
src={instance.schenshoot_url}
|
||||||
|
alt={`Screenshot ${instance.name}`}
|
||||||
|
style={{ width: '100%', display: 'block' }}
|
||||||
|
/>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { Box, Typography, Grid, CircularProgress, Paper } from '@mui/material'
|
||||||
|
import { useInstances } from './api'
|
||||||
|
import InstanceCard from './InstanceCard'
|
||||||
|
|
||||||
|
export default function InstancesPage() {
|
||||||
|
const { data: instances, isLoading } = useInstances()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Typography variant="h5" sx={{ fontWeight: 700, mb: 3 }}>
|
||||||
|
Instancias
|
||||||
|
</Typography>
|
||||||
|
{isLoading ? (
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'center', mt: 8 }}>
|
||||||
|
<CircularProgress />
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
<Grid container spacing={{ xs: 2, sm: 3, md: 4 }} columns={{ xs: 1, sm: 2, md: 2, lg: 3, xl: 4 }}>
|
||||||
|
{instances?.map((inst) => (
|
||||||
|
<Grid item xs={1} key={inst.id}>
|
||||||
|
<InstanceCard instance={inst} />
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
{instances?.length === 0 && (
|
||||||
|
<Grid item xs={1}>
|
||||||
|
<Paper sx={{ p: 4, textAlign: 'center' }}>
|
||||||
|
<Typography color="text.secondary">
|
||||||
|
No hay instancias.
|
||||||
|
</Typography>
|
||||||
|
</Paper>
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { useQuery } from '@tanstack/react-query'
|
||||||
|
import { supabase } from '../../lib/supabase'
|
||||||
|
|
||||||
|
export function useInstances() {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['instances'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const { data: { session } } = await supabase.auth.getSession()
|
||||||
|
const { data, error } = await supabase
|
||||||
|
.from('instances')
|
||||||
|
.select('*')
|
||||||
|
.order('created_at', { ascending: false })
|
||||||
|
.setHeader('xtoken', session?.access_token || '')
|
||||||
|
if (error) throw new Error(error.message)
|
||||||
|
return data || []
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -77,18 +77,19 @@ export default function ChatSessionModal({ session, onClose }) {
|
|||||||
>
|
>
|
||||||
{messages?.map((msg) => {
|
{messages?.map((msg) => {
|
||||||
const parsed = parseMessage(msg.message)
|
const parsed = parseMessage(msg.message)
|
||||||
const isAi = parsed?.type === 'ai'
|
if (!parsed?.content) return null
|
||||||
|
const isHuman = parsed?.type === 'human'
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
key={msg.id}
|
key={msg.id}
|
||||||
sx={(theme) => ({
|
sx={(theme) => ({
|
||||||
alignSelf: isAi ? 'flex-start' : 'flex-end',
|
alignSelf: isHuman ? 'flex-start' : 'flex-end',
|
||||||
bgcolor: isAi
|
bgcolor: isHuman
|
||||||
? theme.palette.mode === 'dark'
|
? theme.palette.mode === 'dark'
|
||||||
? 'grey.800'
|
? 'grey.800'
|
||||||
: 'grey.200'
|
: 'grey.200'
|
||||||
: 'primary.main',
|
: 'primary.main',
|
||||||
color: isAi
|
color: isHuman
|
||||||
? theme.palette.mode === 'dark'
|
? theme.palette.mode === 'dark'
|
||||||
? 'grey.100'
|
? 'grey.100'
|
||||||
: 'text.primary'
|
: 'text.primary'
|
||||||
@@ -100,7 +101,7 @@ export default function ChatSessionModal({ session, onClose }) {
|
|||||||
wordBreak: 'break-word',
|
wordBreak: 'break-word',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Typography variant="body2">{parsed?.content || ''}</Typography>
|
<Typography variant="body2">{parsed.content}</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -0,0 +1,233 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogTitle,
|
||||||
|
DialogContent,
|
||||||
|
DialogActions,
|
||||||
|
Button,
|
||||||
|
TextField,
|
||||||
|
Box,
|
||||||
|
Typography,
|
||||||
|
Alert,
|
||||||
|
IconButton,
|
||||||
|
Divider,
|
||||||
|
CircularProgress,
|
||||||
|
} from '@mui/material'
|
||||||
|
import EditIcon from '@mui/icons-material/Edit'
|
||||||
|
import DeleteIcon from '@mui/icons-material/Delete'
|
||||||
|
import { LocalizationProvider, DateTimePicker } from '@mui/x-date-pickers'
|
||||||
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import {
|
||||||
|
useScheduledMessages,
|
||||||
|
useCreateScheduledMessage,
|
||||||
|
useUpdateScheduledMessage,
|
||||||
|
useDeleteScheduledMessage,
|
||||||
|
} from './api'
|
||||||
|
|
||||||
|
function formatDate(d) {
|
||||||
|
try {
|
||||||
|
return new Date(d).toLocaleString()
|
||||||
|
} catch {
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ScheduleMessageModal({ session, onClose }) {
|
||||||
|
const [message, setMessage] = useState('')
|
||||||
|
const [scheduledAt, setScheduledAt] = useState(() => dayjs().add(1, 'hour'))
|
||||||
|
const [editingId, setEditingId] = useState(null)
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const [success, setSuccess] = useState('')
|
||||||
|
|
||||||
|
const { data: scheduledMessages, isLoading } = useScheduledMessages(session?.id)
|
||||||
|
const createMutation = useCreateScheduledMessage()
|
||||||
|
const updateMutation = useUpdateScheduledMessage()
|
||||||
|
const deleteMutation = useDeleteScheduledMessage()
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
setMessage('')
|
||||||
|
setScheduledAt(dayjs().add(1, 'hour'))
|
||||||
|
setEditingId(null)
|
||||||
|
setError('')
|
||||||
|
setSuccess('')
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEdit = (msg) => {
|
||||||
|
setMessage(msg.message)
|
||||||
|
setScheduledAt(dayjs(msg.scheduled_at))
|
||||||
|
setEditingId(msg.id)
|
||||||
|
setError('')
|
||||||
|
setSuccess('')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCancelEdit = () => {
|
||||||
|
setMessage('')
|
||||||
|
setScheduledAt(dayjs().add(1, 'hour'))
|
||||||
|
setEditingId(null)
|
||||||
|
setError('')
|
||||||
|
setSuccess('')
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
setError('')
|
||||||
|
setSuccess('')
|
||||||
|
if (!message.trim()) {
|
||||||
|
setError('El mensaje no puede estar vacío')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!session) return
|
||||||
|
const isoDate = scheduledAt.toISOString()
|
||||||
|
try {
|
||||||
|
if (editingId) {
|
||||||
|
await updateMutation.mutateAsync({
|
||||||
|
id: editingId,
|
||||||
|
sessionId: session.id,
|
||||||
|
message: message.trim(),
|
||||||
|
scheduledAt: isoDate,
|
||||||
|
})
|
||||||
|
setSuccess('Mensaje programado actualizado')
|
||||||
|
} else {
|
||||||
|
await createMutation.mutateAsync({
|
||||||
|
sessionId: session.id,
|
||||||
|
message: message.trim(),
|
||||||
|
scheduledAt: isoDate,
|
||||||
|
})
|
||||||
|
setSuccess('Mensaje programado creado')
|
||||||
|
}
|
||||||
|
setMessage('')
|
||||||
|
setScheduledAt(dayjs().add(1, 'hour'))
|
||||||
|
setEditingId(null)
|
||||||
|
} catch (err) {
|
||||||
|
setError(err.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDelete = async (id) => {
|
||||||
|
if (!session) return
|
||||||
|
if (!window.confirm('¿Eliminar este mensaje programado?')) return
|
||||||
|
setError('')
|
||||||
|
setSuccess('')
|
||||||
|
try {
|
||||||
|
await deleteMutation.mutateAsync({ id, sessionId: session.id })
|
||||||
|
setSuccess('Mensaje programado eliminado')
|
||||||
|
} catch (err) {
|
||||||
|
setError(err.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog open={!!session} onClose={handleClose} maxWidth="sm" fullWidth>
|
||||||
|
<DialogTitle>
|
||||||
|
Programar mensaje: {session?.name || session?.phone || session?.id}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2, mt: 1 }}>
|
||||||
|
<DateTimePicker
|
||||||
|
label="Fecha y hora"
|
||||||
|
value={scheduledAt}
|
||||||
|
onChange={(v) => setScheduledAt(v)}
|
||||||
|
ampm={false}
|
||||||
|
slotProps={{
|
||||||
|
textField: {
|
||||||
|
fullWidth: true,
|
||||||
|
size: 'small',
|
||||||
|
readOnly: true,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
disablePast
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
fullWidth
|
||||||
|
size="small"
|
||||||
|
label="Mensaje"
|
||||||
|
multiline
|
||||||
|
minRows={3}
|
||||||
|
maxRows={6}
|
||||||
|
value={message}
|
||||||
|
onChange={(e) => setMessage(e.target.value)}
|
||||||
|
placeholder="Escribe el mensaje a programar..."
|
||||||
|
/>
|
||||||
|
{error && <Alert severity="error">{error}</Alert>}
|
||||||
|
{success && <Alert severity="success">{success}</Alert>}
|
||||||
|
<Box sx={{ display: 'flex', gap: 1, justifyContent: 'flex-end' }}>
|
||||||
|
{editingId && (
|
||||||
|
<Button onClick={handleCancelEdit} color="inherit">
|
||||||
|
Cancelar edición
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={!message.trim() || createMutation.isPending || updateMutation.isPending}
|
||||||
|
>
|
||||||
|
{createMutation.isPending || updateMutation.isPending ? (
|
||||||
|
<CircularProgress size={20} color="inherit" />
|
||||||
|
) : editingId ? (
|
||||||
|
'Guardar'
|
||||||
|
) : (
|
||||||
|
'Programar'
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</LocalizationProvider>
|
||||||
|
|
||||||
|
<Divider sx={{ my: 2 }} />
|
||||||
|
|
||||||
|
<Typography variant="subtitle2" gutterBottom>
|
||||||
|
Mensajes programados pendientes
|
||||||
|
</Typography>
|
||||||
|
{isLoading ? (
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'center', py: 2 }}>
|
||||||
|
<CircularProgress size={24} />
|
||||||
|
</Box>
|
||||||
|
) : scheduledMessages?.length === 0 ? (
|
||||||
|
<Typography variant="body2" color="text.secondary">
|
||||||
|
No hay mensajes programados pendientes.
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
||||||
|
{scheduledMessages?.map((msg) => (
|
||||||
|
<Box
|
||||||
|
key={msg.id}
|
||||||
|
sx={{
|
||||||
|
p: 1.5,
|
||||||
|
border: '1px solid',
|
||||||
|
borderColor: 'divider',
|
||||||
|
borderRadius: 1,
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
gap: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<Typography variant="body2" sx={{ wordBreak: 'break-word' }}>
|
||||||
|
{msg.message}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
{formatDate(msg.scheduled_at)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ display: 'flex', gap: 0.5 }}>
|
||||||
|
<IconButton size="small" onClick={() => handleEdit(msg)} disabled={deleteMutation.isPending}>
|
||||||
|
<EditIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
<IconButton size="small" onClick={() => handleDelete(msg.id)} disabled={deleteMutation.isPending}>
|
||||||
|
<DeleteIcon fontSize="small" color="error" />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={handleClose}>Cerrar</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ function formatDate(d) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SessionCard({ session, onBlock, onChat }) {
|
export default function SessionCard({ session, onBlock, onChat, onSchedule }) {
|
||||||
const [anchor, setAnchor] = useState(null)
|
const [anchor, setAnchor] = useState(null)
|
||||||
const deleteMutation = useDeleteSession()
|
const deleteMutation = useDeleteSession()
|
||||||
const unblockMutation = useUnblockSession()
|
const unblockMutation = useUnblockSession()
|
||||||
@@ -91,6 +91,9 @@ export default function SessionCard({ session, onBlock, onChat }) {
|
|||||||
<MenuItem onClick={handleChat}>
|
<MenuItem onClick={handleChat}>
|
||||||
Chat
|
Chat
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem onClick={() => { setAnchor(null); onSchedule(session) }}>
|
||||||
|
Programar
|
||||||
|
</MenuItem>
|
||||||
{session.block ? (
|
{session.block ? (
|
||||||
<MenuItem onClick={handleUnblock} sx={{ color: 'error.main' }}>
|
<MenuItem onClick={handleUnblock} sx={{ color: 'error.main' }}>
|
||||||
Desbloquear
|
Desbloquear
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ import { useSessions } from './api'
|
|||||||
import SessionCard from './SessionCard'
|
import SessionCard from './SessionCard'
|
||||||
import BlockSessionModal from './BlockSessionModal'
|
import BlockSessionModal from './BlockSessionModal'
|
||||||
import ChatSessionModal from './ChatSessionModal'
|
import ChatSessionModal from './ChatSessionModal'
|
||||||
|
import ScheduleMessageModal from './ScheduleMessageModal'
|
||||||
|
|
||||||
export default function SessionsPage() {
|
export default function SessionsPage() {
|
||||||
const [campaignFilter, setCampaignFilter] = useState('')
|
const [campaignFilter, setCampaignFilter] = useState('')
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
const [blockingSession, setBlockingSession] = useState(null)
|
const [blockingSession, setBlockingSession] = useState(null)
|
||||||
const [chatSession, setChatSession] = useState(null)
|
const [chatSession, setChatSession] = useState(null)
|
||||||
|
const [scheduleSession, setScheduleSession] = useState(null)
|
||||||
const { data: campaigns } = useCampaigns()
|
const { data: campaigns } = useCampaigns()
|
||||||
const { data: sessions, isLoading, refetch } = useSessions(campaignFilter)
|
const { data: sessions, isLoading, refetch } = useSessions(campaignFilter)
|
||||||
|
|
||||||
@@ -100,6 +102,7 @@ export default function SessionsPage() {
|
|||||||
session={s}
|
session={s}
|
||||||
onBlock={(session) => setBlockingSession(session)}
|
onBlock={(session) => setBlockingSession(session)}
|
||||||
onChat={(session) => setChatSession(session)}
|
onChat={(session) => setChatSession(session)}
|
||||||
|
onSchedule={(session) => setScheduleSession(session)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
@@ -115,6 +118,10 @@ export default function SessionsPage() {
|
|||||||
session={chatSession}
|
session={chatSession}
|
||||||
onClose={() => setChatSession(null)}
|
onClose={() => setChatSession(null)}
|
||||||
/>
|
/>
|
||||||
|
<ScheduleMessageModal
|
||||||
|
session={scheduleSession}
|
||||||
|
onClose={() => setScheduleSession(null)}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export function useChatHistory(sessionId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const WEBHOOK_URL = 'https://n8n.beroth.moe/webhook/send-msg'
|
const WEBHOOK_URL = 'https://n8n.beroth.moe/webhook/send-msg'
|
||||||
const XTOKEN = 'PLACEHOLDER_XTOKEN'
|
const XTOKEN = 'j07hUOhSXhWSN'
|
||||||
|
|
||||||
export function useSendMessage() {
|
export function useSendMessage() {
|
||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
@@ -104,7 +104,7 @@ export function useSendMessage() {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'xtoken': XTOKEN,
|
'xtoken': XTOKEN,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ phone: sessionId, msg: message }),
|
body: JSON.stringify({ session: sessionId, message: message }),
|
||||||
})
|
})
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const errText = await res.text().catch(() => 'Unknown error')
|
const errText = await res.text().catch(() => 'Unknown error')
|
||||||
@@ -130,3 +130,80 @@ export function useSendMessage() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useScheduledMessages(sessionId) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['scheduledMessages', sessionId],
|
||||||
|
queryFn: async () => {
|
||||||
|
if (!sessionId) return []
|
||||||
|
const { data, error } = await supabase
|
||||||
|
.from('scheduled_messages')
|
||||||
|
.select('*')
|
||||||
|
.eq('session_id', sessionId)
|
||||||
|
.eq('status', 'pending')
|
||||||
|
.order('scheduled_at', { ascending: true })
|
||||||
|
if (error) throw new Error(error.message)
|
||||||
|
return data || []
|
||||||
|
},
|
||||||
|
enabled: !!sessionId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCreateScheduledMessage() {
|
||||||
|
const qc = useQueryClient()
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ sessionId, message, scheduledAt }) => {
|
||||||
|
const { data, error } = await supabase
|
||||||
|
.from('scheduled_messages')
|
||||||
|
.insert({
|
||||||
|
session_id: sessionId,
|
||||||
|
message,
|
||||||
|
scheduled_at: scheduledAt,
|
||||||
|
status: 'pending',
|
||||||
|
})
|
||||||
|
.select()
|
||||||
|
.single()
|
||||||
|
if (error) throw new Error(error.message)
|
||||||
|
return data
|
||||||
|
},
|
||||||
|
onSuccess: (_, { sessionId }) => {
|
||||||
|
qc.invalidateQueries({ queryKey: ['scheduledMessages', sessionId] })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpdateScheduledMessage() {
|
||||||
|
const qc = useQueryClient()
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ id, message, scheduledAt }) => {
|
||||||
|
const { error } = await supabase
|
||||||
|
.from('scheduled_messages')
|
||||||
|
.update({
|
||||||
|
message,
|
||||||
|
scheduled_at: scheduledAt,
|
||||||
|
updated_at: new Date().toISOString(),
|
||||||
|
})
|
||||||
|
.eq('id', id)
|
||||||
|
if (error) throw new Error(error.message)
|
||||||
|
},
|
||||||
|
onSuccess: (_, { sessionId }) => {
|
||||||
|
qc.invalidateQueries({ queryKey: ['scheduledMessages', sessionId] })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDeleteScheduledMessage() {
|
||||||
|
const qc = useQueryClient()
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({ id }) => {
|
||||||
|
const { error } = await supabase
|
||||||
|
.from('scheduled_messages')
|
||||||
|
.delete()
|
||||||
|
.eq('id', id)
|
||||||
|
if (error) throw new Error(error.message)
|
||||||
|
},
|
||||||
|
onSuccess: (_, { sessionId }) => {
|
||||||
|
qc.invalidateQueries({ queryKey: ['scheduledMessages', sessionId] })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import LoginPage from './features/auth/LoginPage'
|
|||||||
import CampaignsPage from './features/campaigns/CampaignsPage'
|
import CampaignsPage from './features/campaigns/CampaignsPage'
|
||||||
import SessionsPage from './features/sessions/SessionsPage'
|
import SessionsPage from './features/sessions/SessionsPage'
|
||||||
import MediaPage from './features/media/MediaPage'
|
import MediaPage from './features/media/MediaPage'
|
||||||
|
import InstancesPage from './features/instances/InstancesPage'
|
||||||
import { supabase } from './lib/supabase'
|
import { supabase } from './lib/supabase'
|
||||||
|
|
||||||
const rootRoute = createRootRoute({
|
const rootRoute = createRootRoute({
|
||||||
@@ -58,10 +59,16 @@ const mediaRoute = createRoute({
|
|||||||
component: MediaPage,
|
component: MediaPage,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const instancesRoute = createRoute({
|
||||||
|
getParentRoute: () => appLayoutRoute,
|
||||||
|
path: '/instances',
|
||||||
|
component: InstancesPage,
|
||||||
|
})
|
||||||
|
|
||||||
const routeTree = rootRoute.addChildren([
|
const routeTree = rootRoute.addChildren([
|
||||||
indexRoute,
|
indexRoute,
|
||||||
loginRoute,
|
loginRoute,
|
||||||
appLayoutRoute.addChildren([campaignsRoute, sessionsRoute, mediaRoute]),
|
appLayoutRoute.addChildren([campaignsRoute, sessionsRoute, mediaRoute, instancesRoute]),
|
||||||
])
|
])
|
||||||
|
|
||||||
export const router = createRouter({ routeTree })
|
export const router = createRouter({ routeTree })
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: backend/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- PORT=3000
|
||||||
Reference in New Issue
Block a user