Merge pull request 'Bug fixes and improvements' (#14) from dev into main
Reviewed-on: #14
This commit is contained in:
21
README.md
21
README.md
@@ -64,6 +64,8 @@ npm run start
|
|||||||
npm run db:generate
|
npm run db:generate
|
||||||
npm run db:migrate
|
npm run db:migrate
|
||||||
npm run db:studio
|
npm run db:studio
|
||||||
|
npm run db:export # Backup database
|
||||||
|
npm run db:import # Restore from backup
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also run per workspace:
|
You can also run per workspace:
|
||||||
@@ -117,6 +119,25 @@ Then run:
|
|||||||
npm run db:migrate
|
npm run db:migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Backups (export / import)
|
||||||
|
|
||||||
|
Create backups and restore if needed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Export (creates timestamped file in backend/data/backups/)
|
||||||
|
npm run db:export
|
||||||
|
|
||||||
|
# Export to custom path
|
||||||
|
npm run db:export -- -o ./my-backup.db # SQLite
|
||||||
|
npm run db:export -- -o ./my-backup.sql # PostgreSQL
|
||||||
|
|
||||||
|
# Import (stop the backend server first)
|
||||||
|
npm run db:import -- ./data/backups/spanglish-2025-03-07-143022.db
|
||||||
|
npm run db:import -- --yes ./data/backups/spanglish-2025-03-07.sql # Skip confirmation
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Stop the backend before importing so the database file is not locked.
|
||||||
|
|
||||||
## Production deployment (nginx + systemd)
|
## Production deployment (nginx + systemd)
|
||||||
|
|
||||||
This repo includes example configs in `deploy/`:
|
This repo includes example configs in `deploy/`:
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
"start": "NODE_ENV=production node dist/index.js",
|
"start": "NODE_ENV=production node dist/index.js",
|
||||||
"db:generate": "drizzle-kit generate",
|
"db:generate": "drizzle-kit generate",
|
||||||
"db:migrate": "tsx src/db/migrate.ts",
|
"db:migrate": "tsx src/db/migrate.ts",
|
||||||
"db:studio": "drizzle-kit studio"
|
"db:studio": "drizzle-kit studio",
|
||||||
|
"db:export": "tsx src/db/export.ts",
|
||||||
|
"db:import": "tsx src/db/import.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hono/node-server": "^1.11.4",
|
"@hono/node-server": "^1.11.4",
|
||||||
|
|||||||
96
backend/src/db/export.ts
Normal file
96
backend/src/db/export.ts
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
|
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
||||||
|
import { dirname, resolve } from 'path';
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
import Database from 'better-sqlite3';
|
||||||
|
|
||||||
|
const dbType = process.env.DB_TYPE || 'sqlite';
|
||||||
|
const dbPath = process.env.DATABASE_URL || './data/spanglish.db';
|
||||||
|
const BACKUP_DIR = resolve(process.cwd(), 'data', 'backups');
|
||||||
|
|
||||||
|
function parseArgs(): { output?: string } {
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const result: { output?: string } = {};
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
if (args[i] === '-o' || args[i] === '--output') {
|
||||||
|
result.output = args[i + 1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTimestamp(): string {
|
||||||
|
const now = new Date();
|
||||||
|
const y = now.getFullYear();
|
||||||
|
const m = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const d = String(now.getDate()).padStart(2, '0');
|
||||||
|
const h = String(now.getHours()).padStart(2, '0');
|
||||||
|
const min = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
const s = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
return `${y}-${m}-${d}-${h}${min}${s}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportSqlite(outputPath: string): void {
|
||||||
|
const db = new Database(resolve(process.cwd(), dbPath), { readonly: true });
|
||||||
|
try {
|
||||||
|
db.backup(outputPath);
|
||||||
|
console.log(`Exported to ${outputPath}`);
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportPostgres(outputPath: string): void {
|
||||||
|
const connString = process.env.DATABASE_URL || 'postgresql://localhost:5432/spanglish';
|
||||||
|
const result = spawnSync(
|
||||||
|
'pg_dump',
|
||||||
|
['--clean', '--if-exists', connString],
|
||||||
|
{
|
||||||
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
|
encoding: 'utf-8',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
console.error('pg_dump failed. Ensure pg_dump is installed and in PATH.');
|
||||||
|
console.error(result.error.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.status !== 0) {
|
||||||
|
console.error('pg_dump failed:', result.stderr);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFileSync(outputPath, result.stdout);
|
||||||
|
console.log(`Exported to ${outputPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const { output } = parseArgs();
|
||||||
|
const ext = dbType === 'postgres' ? '.sql' : '.db';
|
||||||
|
const defaultName = `spanglish-${getTimestamp()}${ext}`;
|
||||||
|
|
||||||
|
const outputPath = output
|
||||||
|
? resolve(process.cwd(), output)
|
||||||
|
: resolve(BACKUP_DIR, defaultName);
|
||||||
|
|
||||||
|
const dir = dirname(outputPath);
|
||||||
|
if (!existsSync(dir)) {
|
||||||
|
mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Database type: ${dbType}`);
|
||||||
|
if (dbType === 'sqlite') {
|
||||||
|
exportSqlite(outputPath);
|
||||||
|
} else {
|
||||||
|
exportPostgres(outputPath);
|
||||||
|
}
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error('Export failed:', err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
91
backend/src/db/import.ts
Normal file
91
backend/src/db/import.ts
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import 'dotenv/config';
|
||||||
|
import { copyFileSync, existsSync, readFileSync } from 'fs';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
|
||||||
|
const dbType = process.env.DB_TYPE || 'sqlite';
|
||||||
|
const dbPath = process.env.DATABASE_URL || './data/spanglish.db';
|
||||||
|
|
||||||
|
function parseArgs(): { file?: string; yes?: boolean } {
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const result: { file?: string; yes?: boolean } = {};
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
if (args[i] === '-y' || args[i] === '--yes') {
|
||||||
|
result.yes = true;
|
||||||
|
} else if (!args[i].startsWith('-')) {
|
||||||
|
result.file = args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function importSqlite(backupPath: string): void {
|
||||||
|
const targetPath = resolve(process.cwd(), dbPath);
|
||||||
|
copyFileSync(backupPath, targetPath);
|
||||||
|
console.log(`Restored from ${backupPath} to ${targetPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function importPostgres(backupPath: string): void {
|
||||||
|
const connString = process.env.DATABASE_URL || 'postgresql://localhost:5432/spanglish';
|
||||||
|
const sql = readFileSync(backupPath, 'utf-8');
|
||||||
|
|
||||||
|
const result = spawnSync(
|
||||||
|
'psql',
|
||||||
|
[connString],
|
||||||
|
{
|
||||||
|
stdio: ['pipe', 'inherit', 'inherit'],
|
||||||
|
input: sql,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
console.error('psql failed. Ensure psql is installed and in PATH.');
|
||||||
|
console.error(result.error.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.status !== 0) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Restored from ${backupPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const { file, yes } = parseArgs();
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
console.error('Usage: npm run db:import -- <backup-file> [--yes]');
|
||||||
|
console.error('Example: npm run db:import -- ./data/backups/spanglish-2025-03-07.db');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const backupPath = resolve(process.cwd(), file);
|
||||||
|
if (!existsSync(backupPath)) {
|
||||||
|
console.error(`Backup file not found: ${backupPath}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!yes) {
|
||||||
|
console.log('WARNING: Import will overwrite the current database.');
|
||||||
|
console.log('Stop the backend server before importing.');
|
||||||
|
console.log('Press Ctrl+C to cancel, or run with --yes to skip this warning.');
|
||||||
|
await new Promise((r) => setTimeout(r, 3000));
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Database type: ${dbType}`);
|
||||||
|
if (dbType === 'sqlite') {
|
||||||
|
importSqlite(backupPath);
|
||||||
|
} else if (dbType === 'postgres') {
|
||||||
|
importPostgres(backupPath);
|
||||||
|
} else {
|
||||||
|
console.error('Unknown DB_TYPE. Use sqlite or postgres.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error('Import failed:', err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -30,6 +30,8 @@ paymentsRouter.get('/', requireAuth(['admin']), async (c) => {
|
|||||||
const status = c.req.query('status');
|
const status = c.req.query('status');
|
||||||
const provider = c.req.query('provider');
|
const provider = c.req.query('provider');
|
||||||
const pendingApproval = c.req.query('pendingApproval');
|
const pendingApproval = c.req.query('pendingApproval');
|
||||||
|
const eventId = c.req.query('eventId');
|
||||||
|
const eventIds = c.req.query('eventIds');
|
||||||
|
|
||||||
// Get all payments with their associated tickets
|
// Get all payments with their associated tickets
|
||||||
let allPayments = await dbAll<any>(
|
let allPayments = await dbAll<any>(
|
||||||
@@ -55,7 +57,7 @@ paymentsRouter.get('/', requireAuth(['admin']), async (c) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enrich with ticket and event data
|
// Enrich with ticket and event data
|
||||||
const enrichedPayments = await Promise.all(
|
let enrichedPayments = await Promise.all(
|
||||||
allPayments.map(async (payment: any) => {
|
allPayments.map(async (payment: any) => {
|
||||||
const ticket = await dbGet<any>(
|
const ticket = await dbGet<any>(
|
||||||
(db as any)
|
(db as any)
|
||||||
@@ -94,6 +96,16 @@ paymentsRouter.get('/', requireAuth(['admin']), async (c) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Filter by event(s)
|
||||||
|
if (eventId) {
|
||||||
|
enrichedPayments = enrichedPayments.filter((p: any) => p.event?.id === eventId);
|
||||||
|
} else if (eventIds) {
|
||||||
|
const ids = eventIds.split(',').map((s: string) => s.trim()).filter(Boolean);
|
||||||
|
if (ids.length > 0) {
|
||||||
|
enrichedPayments = enrichedPayments.filter((p: any) => p.event && ids.includes(p.event.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return c.json({ payments: enrichedPayments });
|
return c.json({ payments: enrichedPayments });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -200,6 +200,13 @@ siteSettingsRouter.put('/featured-event', requireAuth(['admin']), zValidator('js
|
|||||||
if (event.status !== 'published') {
|
if (event.status !== 'published') {
|
||||||
return c.json({ error: 'Event must be published to be featured' }, 400);
|
return c.json({ error: 'Event must be published to be featured' }, 400);
|
||||||
}
|
}
|
||||||
|
const eventEndTime = event.endDatetime || event.startDatetime;
|
||||||
|
if (new Date(eventEndTime).getTime() <= Date.now()) {
|
||||||
|
return c.json(
|
||||||
|
{ error: 'Cannot feature an event that has already ended' },
|
||||||
|
400
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get or create settings
|
// Get or create settings
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ NEXT_PUBLIC_TIKTOK=spanglishsocialpy
|
|||||||
# Must match the REVALIDATE_SECRET in backend/.env
|
# Must match the REVALIDATE_SECRET in backend/.env
|
||||||
REVALIDATE_SECRET=change-me-to-a-random-secret
|
REVALIDATE_SECRET=change-me-to-a-random-secret
|
||||||
|
|
||||||
|
# Next event cache revalidation (seconds) - homepage metadata/social preview refresh interval. Default: 3600
|
||||||
|
NEXT_EVENT_REVALIDATE_SECONDS=3600
|
||||||
|
|
||||||
# Plausible Analytics (optional - leave empty to disable tracking)
|
# Plausible Analytics (optional - leave empty to disable tracking)
|
||||||
NEXT_PUBLIC_PLAUSIBLE_URL=https://analytics.azzamo.net
|
NEXT_PUBLIC_PLAUSIBLE_URL=https://analytics.azzamo.net
|
||||||
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=spanglishcommunity.com
|
NEXT_PUBLIC_PLAUSIBLE_DOMAIN=spanglishcommunity.com
|
||||||
|
|||||||
BIN
frontend/public/images/spanglish-icon.png
Normal file
BIN
frontend/public/images/spanglish-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
@@ -38,8 +38,10 @@ interface NextEvent {
|
|||||||
|
|
||||||
async function getNextUpcomingEvent(): Promise<NextEvent | null> {
|
async function getNextUpcomingEvent(): Promise<NextEvent | null> {
|
||||||
try {
|
try {
|
||||||
|
const revalidateSeconds =
|
||||||
|
parseInt(process.env.NEXT_EVENT_REVALIDATE_SECONDS || '3600', 10) || 3600;
|
||||||
const response = await fetch(`${apiUrl}/api/events/next/upcoming`, {
|
const response = await fetch(`${apiUrl}/api/events/next/upcoming`, {
|
||||||
next: { tags: ['next-event'] },
|
next: { tags: ['next-event'], revalidate: revalidateSeconds },
|
||||||
});
|
});
|
||||||
if (!response.ok) return null;
|
if (!response.ok) return null;
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|||||||
@@ -154,12 +154,23 @@ export default function AdminBookingsPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getPaymentMethodLabel = (provider: string) => {
|
const getPaymentMethodLabel = (provider: string) => {
|
||||||
switch (provider) {
|
const labels: Record<string, string> = {
|
||||||
case 'bancard': return 'TPago / Card';
|
cash: locale === 'es' ? 'Efectivo en el Evento' : 'Cash at Event',
|
||||||
case 'lightning': return 'Bitcoin Lightning';
|
bank_transfer: locale === 'es' ? 'Transferencia Bancaria' : 'Bank Transfer',
|
||||||
case 'cash': return 'Cash at Event';
|
lightning: 'Lightning',
|
||||||
default: return provider;
|
tpago: 'TPago',
|
||||||
|
bancard: 'Bancard',
|
||||||
|
};
|
||||||
|
return labels[provider] || provider;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDisplayProvider = (ticket: TicketWithDetails) => {
|
||||||
|
if (ticket.payment?.provider) return ticket.payment.provider;
|
||||||
|
if (ticket.bookingId) {
|
||||||
|
const sibling = tickets.find(t => t.bookingId === ticket.bookingId && t.payment?.provider);
|
||||||
|
return sibling?.payment?.provider ?? 'cash';
|
||||||
}
|
}
|
||||||
|
return 'cash';
|
||||||
};
|
};
|
||||||
|
|
||||||
const filteredTickets = tickets.filter((ticket) => {
|
const filteredTickets = tickets.filter((ticket) => {
|
||||||
@@ -394,7 +405,7 @@ export default function AdminBookingsPage() {
|
|||||||
<span className={`inline-block px-2 py-0.5 rounded-full text-xs font-medium ${getPaymentStatusColor(ticket.payment?.status || 'pending')}`}>
|
<span className={`inline-block px-2 py-0.5 rounded-full text-xs font-medium ${getPaymentStatusColor(ticket.payment?.status || 'pending')}`}>
|
||||||
{ticket.payment?.status || 'pending'}
|
{ticket.payment?.status || 'pending'}
|
||||||
</span>
|
</span>
|
||||||
<p className="text-xs text-gray-500 mt-0.5">{getPaymentMethodLabel(ticket.payment?.provider || 'cash')}</p>
|
<p className="text-xs text-gray-500 mt-0.5">{getPaymentMethodLabel(getDisplayProvider(ticket))}</p>
|
||||||
{ticket.payment && (
|
{ticket.payment && (
|
||||||
<p className="text-xs font-medium mt-0.5">{bookingInfo.bookingTotal.toLocaleString()} {ticket.payment.currency}</p>
|
<p className="text-xs font-medium mt-0.5">{bookingInfo.bookingTotal.toLocaleString()} {ticket.payment.currency}</p>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
CreditCardIcon,
|
CreditCardIcon,
|
||||||
EnvelopeIcon,
|
EnvelopeIcon,
|
||||||
FunnelIcon,
|
FunnelIcon,
|
||||||
|
MagnifyingGlassIcon,
|
||||||
XMarkIcon,
|
XMarkIcon,
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
@@ -38,6 +39,8 @@ export default function AdminPaymentsPage() {
|
|||||||
const [activeTab, setActiveTab] = useState<Tab>('pending_approval');
|
const [activeTab, setActiveTab] = useState<Tab>('pending_approval');
|
||||||
const [statusFilter, setStatusFilter] = useState<string>('');
|
const [statusFilter, setStatusFilter] = useState<string>('');
|
||||||
const [providerFilter, setProviderFilter] = useState<string>('');
|
const [providerFilter, setProviderFilter] = useState<string>('');
|
||||||
|
const [eventFilter, setEventFilter] = useState<string[]>([]);
|
||||||
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [mobileFilterOpen, setMobileFilterOpen] = useState(false);
|
const [mobileFilterOpen, setMobileFilterOpen] = useState(false);
|
||||||
|
|
||||||
// Modal state
|
// Modal state
|
||||||
@@ -59,7 +62,7 @@ export default function AdminPaymentsPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadData();
|
loadData();
|
||||||
}, [statusFilter, providerFilter]);
|
}, [statusFilter, providerFilter, eventFilter]);
|
||||||
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -68,7 +71,8 @@ export default function AdminPaymentsPage() {
|
|||||||
paymentsApi.getPendingApproval(),
|
paymentsApi.getPendingApproval(),
|
||||||
paymentsApi.getAll({
|
paymentsApi.getAll({
|
||||||
status: statusFilter || undefined,
|
status: statusFilter || undefined,
|
||||||
provider: providerFilter || undefined
|
provider: providerFilter || undefined,
|
||||||
|
eventIds: eventFilter.length > 0 ? eventFilter : undefined,
|
||||||
}),
|
}),
|
||||||
eventsApi.getAll(),
|
eventsApi.getAll(),
|
||||||
]);
|
]);
|
||||||
@@ -751,11 +755,40 @@ export default function AdminPaymentsPage() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* All Payments Tab */}
|
{/* All Payments Tab */}
|
||||||
{activeTab === 'all' && (
|
{activeTab === 'all' && (() => {
|
||||||
|
const q = searchQuery.trim().toLowerCase();
|
||||||
|
const filteredPayments = q
|
||||||
|
? payments.filter((p) => {
|
||||||
|
const name = `${p.ticket?.attendeeFirstName || ''} ${p.ticket?.attendeeLastName || ''}`.trim().toLowerCase();
|
||||||
|
const email = (p.ticket?.attendeeEmail || '').toLowerCase();
|
||||||
|
const phone = (p.ticket?.attendeePhone || '').toLowerCase();
|
||||||
|
const eventTitle = (p.event?.title || '').toLowerCase();
|
||||||
|
const payerName = (p.payerName || '').toLowerCase();
|
||||||
|
const reference = (p.reference || '').toLowerCase();
|
||||||
|
const id = (p.id || '').toLowerCase();
|
||||||
|
return name.includes(q) || email.includes(q) || phone.includes(q) ||
|
||||||
|
eventTitle.includes(q) || payerName.includes(q) || reference.includes(q) || id.includes(q);
|
||||||
|
})
|
||||||
|
: payments;
|
||||||
|
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Desktop Filters */}
|
{/* Desktop Filters */}
|
||||||
<Card className="p-4 mb-6 hidden md:block">
|
<Card className="p-4 mb-6 hidden md:block">
|
||||||
<div className="flex flex-wrap gap-4">
|
<div className="flex flex-wrap gap-4">
|
||||||
|
<div className="flex-1 min-w-[200px]">
|
||||||
|
<label className="block text-sm font-medium mb-1">{locale === 'es' ? 'Buscar' : 'Search'}</label>
|
||||||
|
<div className="relative">
|
||||||
|
<MagnifyingGlassIcon className="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder={locale === 'es' ? 'Nombre, email, evento...' : 'Name, email, event...'}
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
|
className="w-full pl-9 pr-3 py-2 rounded-btn border border-secondary-light-gray text-sm focus:outline-none focus:ring-2 focus:ring-primary-yellow min-w-[200px]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1">Status</label>
|
<label className="block text-sm font-medium mb-1">Status</label>
|
||||||
<select value={statusFilter} onChange={(e) => setStatusFilter(e.target.value)}
|
<select value={statusFilter} onChange={(e) => setStatusFilter(e.target.value)}
|
||||||
@@ -779,20 +812,65 @@ export default function AdminPaymentsPage() {
|
|||||||
<option value="tpago">TPago</option>
|
<option value="tpago">TPago</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex-1 min-w-[200px]">
|
||||||
|
<label className="block text-sm font-medium mb-1">{locale === 'es' ? 'Evento(s)' : 'Event(s)'}</label>
|
||||||
|
<select
|
||||||
|
value=""
|
||||||
|
onChange={(e) => {
|
||||||
|
const id = e.target.value;
|
||||||
|
if (id && !eventFilter.includes(id)) setEventFilter([...eventFilter, id]);
|
||||||
|
e.target.value = '';
|
||||||
|
}}
|
||||||
|
className="px-4 py-2 rounded-btn border border-secondary-light-gray w-full text-sm"
|
||||||
|
>
|
||||||
|
<option value="">{locale === 'es' ? 'Agregar evento...' : 'Add event...'}</option>
|
||||||
|
{events.filter(e => !eventFilter.includes(e.id)).map((event) => (
|
||||||
|
<option key={event.id} value={event.id}>{event.title}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{eventFilter.length > 0 && (
|
||||||
|
<div className="flex flex-wrap gap-1.5 mt-2">
|
||||||
|
{eventFilter.map((id) => {
|
||||||
|
const ev = events.find(e => e.id === id);
|
||||||
|
return (
|
||||||
|
<span key={id} className="inline-flex items-center gap-1 px-2 py-0.5 bg-primary-yellow/20 rounded text-xs">
|
||||||
|
{ev?.title || id}
|
||||||
|
<button type="button" onClick={() => setEventFilter(eventFilter.filter(x => x !== id))} className="hover:text-red-600">×</button>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
<button type="button" onClick={() => setEventFilter([])} className="text-xs text-gray-500 hover:text-primary-dark">
|
||||||
|
{locale === 'es' ? 'Limpiar' : 'Clear'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{/* Mobile Filter Toolbar */}
|
{/* Mobile Search & Filter Toolbar */}
|
||||||
<div className="md:hidden mb-4 flex items-center gap-2">
|
<div className="md:hidden mb-4 space-y-2">
|
||||||
<button onClick={() => setMobileFilterOpen(true)}
|
<div className="relative">
|
||||||
className={clsx('flex items-center gap-1.5 px-3 py-2 rounded-btn border text-sm min-h-[44px]',
|
<MagnifyingGlassIcon className="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" />
|
||||||
(statusFilter || providerFilter) ? 'border-primary-yellow bg-yellow-50 text-primary-dark' : 'border-secondary-light-gray text-gray-600')}>
|
<input
|
||||||
<FunnelIcon className="w-4 h-4" /> Filters
|
type="text"
|
||||||
</button>
|
placeholder={locale === 'es' ? 'Nombre, email, evento...' : 'Name, email, event...'}
|
||||||
{(statusFilter || providerFilter) && (
|
value={searchQuery}
|
||||||
<button onClick={() => { setStatusFilter(''); setProviderFilter(''); }}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
className="text-xs text-primary-yellow min-h-[44px] flex items-center">Clear</button>
|
className="w-full pl-9 pr-3 py-2.5 rounded-btn border border-secondary-light-gray text-sm focus:outline-none focus:ring-2 focus:ring-primary-yellow"
|
||||||
)}
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button onClick={() => setMobileFilterOpen(true)}
|
||||||
|
className={clsx('flex items-center gap-1.5 px-3 py-2 rounded-btn border text-sm min-h-[44px]',
|
||||||
|
(statusFilter || providerFilter || eventFilter.length > 0) ? 'border-primary-yellow bg-yellow-50 text-primary-dark' : 'border-secondary-light-gray text-gray-600')}>
|
||||||
|
<FunnelIcon className="w-4 h-4" /> Filters
|
||||||
|
</button>
|
||||||
|
{(statusFilter || providerFilter || eventFilter.length > 0 || searchQuery) && (
|
||||||
|
<button onClick={() => { setStatusFilter(''); setProviderFilter(''); setEventFilter([]); setSearchQuery(''); }}
|
||||||
|
className="text-xs text-primary-yellow min-h-[44px] flex items-center">Clear</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Desktop: Table */}
|
{/* Desktop: Table */}
|
||||||
@@ -810,10 +888,10 @@ export default function AdminPaymentsPage() {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y divide-secondary-light-gray">
|
<tbody className="divide-y divide-secondary-light-gray">
|
||||||
{payments.length === 0 ? (
|
{filteredPayments.length === 0 ? (
|
||||||
<tr><td colSpan={6} className="px-4 py-12 text-center text-gray-500 text-sm">{locale === 'es' ? 'No se encontraron pagos' : 'No payments found'}</td></tr>
|
<tr><td colSpan={6} className="px-4 py-12 text-center text-gray-500 text-sm">{locale === 'es' ? 'No se encontraron pagos' : 'No payments found'}</td></tr>
|
||||||
) : (
|
) : (
|
||||||
payments.map((payment) => {
|
filteredPayments.map((payment) => {
|
||||||
const bookingInfo = getBookingInfo(payment);
|
const bookingInfo = getBookingInfo(payment);
|
||||||
return (
|
return (
|
||||||
<tr key={payment.id} className="hover:bg-gray-50">
|
<tr key={payment.id} className="hover:bg-gray-50">
|
||||||
@@ -858,13 +936,18 @@ export default function AdminPaymentsPage() {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
{(searchQuery || filteredPayments.length !== payments.length) && (
|
||||||
|
<p className="hidden md:block text-sm text-gray-500 mb-2">
|
||||||
|
{locale === 'es' ? 'Mostrando' : 'Showing'} {filteredPayments.length} {locale === 'es' ? 'de' : 'of'} {payments.length}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Mobile: Card List */}
|
{/* Mobile: Card List */}
|
||||||
<div className="md:hidden space-y-2">
|
<div className="md:hidden space-y-2">
|
||||||
{payments.length === 0 ? (
|
{filteredPayments.length === 0 ? (
|
||||||
<div className="text-center py-10 text-gray-500 text-sm">{locale === 'es' ? 'No se encontraron pagos' : 'No payments found'}</div>
|
<div className="text-center py-10 text-gray-500 text-sm">{locale === 'es' ? 'No se encontraron pagos' : 'No payments found'}</div>
|
||||||
) : (
|
) : (
|
||||||
payments.map((payment) => {
|
filteredPayments.map((payment) => {
|
||||||
const bookingInfo = getBookingInfo(payment);
|
const bookingInfo = getBookingInfo(payment);
|
||||||
return (
|
return (
|
||||||
<Card key={payment.id} className="p-3">
|
<Card key={payment.id} className="p-3">
|
||||||
@@ -911,6 +994,25 @@ export default function AdminPaymentsPage() {
|
|||||||
{/* Mobile Filter BottomSheet */}
|
{/* Mobile Filter BottomSheet */}
|
||||||
<BottomSheet open={mobileFilterOpen} onClose={() => setMobileFilterOpen(false)} title={locale === 'es' ? 'Filtros' : 'Filters'}>
|
<BottomSheet open={mobileFilterOpen} onClose={() => setMobileFilterOpen(false)} title={locale === 'es' ? 'Filtros' : 'Filters'}>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-1">{locale === 'es' ? 'Evento(s)' : 'Event(s)'}</label>
|
||||||
|
<div className="max-h-40 overflow-y-auto border border-secondary-light-gray rounded-btn p-2 space-y-1">
|
||||||
|
{events.map((event) => (
|
||||||
|
<label key={event.id} className="flex items-center gap-2 py-1.5 cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={eventFilter.includes(event.id)}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (e.target.checked) setEventFilter([...eventFilter, event.id]);
|
||||||
|
else setEventFilter(eventFilter.filter(id => id !== event.id));
|
||||||
|
}}
|
||||||
|
className="w-4 h-4 rounded border-gray-300 text-primary-yellow focus:ring-primary-yellow"
|
||||||
|
/>
|
||||||
|
<span className="text-sm">{event.title}</span>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
<label className="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
||||||
<select value={statusFilter} onChange={(e) => setStatusFilter(e.target.value)}
|
<select value={statusFilter} onChange={(e) => setStatusFilter(e.target.value)}
|
||||||
@@ -935,13 +1037,14 @@ export default function AdminPaymentsPage() {
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-3 pt-2">
|
<div className="flex gap-3 pt-2">
|
||||||
<Button variant="outline" onClick={() => { setStatusFilter(''); setProviderFilter(''); setMobileFilterOpen(false); }} className="flex-1 min-h-[44px]">Clear</Button>
|
<Button variant="outline" onClick={() => { setStatusFilter(''); setProviderFilter(''); setEventFilter([]); setSearchQuery(''); setMobileFilterOpen(false); }} className="flex-1 min-h-[44px]">Clear</Button>
|
||||||
<Button onClick={() => setMobileFilterOpen(false)} className="flex-1 min-h-[44px]">Apply</Button>
|
<Button onClick={() => setMobileFilterOpen(false)} className="flex-1 min-h-[44px]">Apply</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</BottomSheet>
|
</BottomSheet>
|
||||||
</>
|
</>
|
||||||
)}
|
);
|
||||||
|
})()}
|
||||||
|
|
||||||
<AdminMobileStyles />
|
<AdminMobileStyles />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
import Image from 'next/image';
|
||||||
import { useLanguage } from '@/context/LanguageContext';
|
import { useLanguage } from '@/context/LanguageContext';
|
||||||
import { eventsApi, Event } from '@/lib/api';
|
import { eventsApi, Event } from '@/lib/api';
|
||||||
import { formatPrice, formatDateShort, formatTime } from '@/lib/utils';
|
import { formatPrice, formatDateShort, formatTime } from '@/lib/utils';
|
||||||
import {
|
import {
|
||||||
CalendarIcon,
|
CalendarIcon,
|
||||||
MapPinIcon,
|
MapPinIcon,
|
||||||
ChatBubbleLeftRightIcon,
|
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
|
|
||||||
export default function LinktreePage() {
|
export default function LinktreePage() {
|
||||||
@@ -59,8 +59,8 @@ export default function LinktreePage() {
|
|||||||
<div className="max-w-md mx-auto px-4 py-8 pb-16">
|
<div className="max-w-md mx-auto px-4 py-8 pb-16">
|
||||||
{/* Profile Header */}
|
{/* Profile Header */}
|
||||||
<div className="text-center mb-8">
|
<div className="text-center mb-8">
|
||||||
<div className="w-24 h-24 mx-auto bg-primary-yellow rounded-full flex items-center justify-center mb-4 shadow-lg">
|
<div className="w-24 h-24 mx-auto rounded-full overflow-hidden flex items-center justify-center mb-4 shadow-lg bg-white">
|
||||||
<ChatBubbleLeftRightIcon className="w-12 h-12 text-primary-dark" />
|
<Image src="/images/spanglish-icon.png" alt="Spanglish" width={96} height={96} className="object-contain" />
|
||||||
</div>
|
</div>
|
||||||
<h1 className="text-2xl font-bold text-white">Spanglish</h1>
|
<h1 className="text-2xl font-bold text-white">Spanglish</h1>
|
||||||
<p className="text-gray-400 mt-1">{t('linktree.tagline')}</p>
|
<p className="text-gray-400 mt-1">{t('linktree.tagline')}</p>
|
||||||
|
|||||||
@@ -236,11 +236,13 @@ export const usersApi = {
|
|||||||
|
|
||||||
// Payments API
|
// Payments API
|
||||||
export const paymentsApi = {
|
export const paymentsApi = {
|
||||||
getAll: (params?: { status?: string; provider?: string; pendingApproval?: boolean }) => {
|
getAll: (params?: { status?: string; provider?: string; pendingApproval?: boolean; eventId?: string; eventIds?: string[] }) => {
|
||||||
const query = new URLSearchParams();
|
const query = new URLSearchParams();
|
||||||
if (params?.status) query.set('status', params.status);
|
if (params?.status) query.set('status', params.status);
|
||||||
if (params?.provider) query.set('provider', params.provider);
|
if (params?.provider) query.set('provider', params.provider);
|
||||||
if (params?.pendingApproval) query.set('pendingApproval', 'true');
|
if (params?.pendingApproval) query.set('pendingApproval', 'true');
|
||||||
|
if (params?.eventId) query.set('eventId', params.eventId);
|
||||||
|
if (params?.eventIds && params.eventIds.length > 0) query.set('eventIds', params.eventIds.join(','));
|
||||||
return fetchApi<{ payments: PaymentWithDetails[] }>(`/api/payments?${query}`);
|
return fetchApi<{ payments: PaymentWithDetails[] }>(`/api/payments?${query}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
"start:frontend": "npm run start --workspace=frontend",
|
"start:frontend": "npm run start --workspace=frontend",
|
||||||
"db:generate": "npm run db:generate --workspace=backend",
|
"db:generate": "npm run db:generate --workspace=backend",
|
||||||
"db:migrate": "npm run db:migrate --workspace=backend",
|
"db:migrate": "npm run db:migrate --workspace=backend",
|
||||||
"db:studio": "npm run db:studio --workspace=backend"
|
"db:studio": "npm run db:studio --workspace=backend",
|
||||||
|
"db:export": "npm run db:export --workspace=backend --",
|
||||||
|
"db:import": "npm run db:import --workspace=backend --"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"backend",
|
"backend",
|
||||||
|
|||||||
Reference in New Issue
Block a user