fix: guardar OAuth Google con upsert real (PATCH vacío no insertaba)

El callback creía haber guardado el token y fallaba al emparejar Drive
con «no conectado». Upsert on_conflict=provider + match no bloquea OAuth.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
4Ventures
2026-09-24 12:17:46 +02:00
parent 5d04a79de7
commit 5501f45a67
3 changed files with 59 additions and 46 deletions

View File

@@ -38,14 +38,17 @@ export default function DriveConnectPanel() {
const params = new URLSearchParams(window.location.search);
if (params.get('drive') === 'ok') {
setMsg(
`Drive conectado. Enlazadas ${params.get('linked') || 0} carpetas` +
`Google conectado. Enlazadas ${params.get('linked') || 0} carpetas Drive` +
(params.get('ambiguous') && params.get('ambiguous') !== '0'
? ` · ${params.get('ambiguous')} ambiguas (revisa abajo)`
: '')
);
}
if (params.get('drive') === 'error') {
setErr(params.get('msg') || 'Error OAuth Drive');
setErr(params.get('msg') || 'Error OAuth Google');
}
if (params.get('drive')) {
window.history.replaceState({}, '', '/dashboard/agencia');
}
void loadStatus();
}, []);
@@ -133,13 +136,21 @@ export default function DriveConnectPanel() {
</div>
</div>
{connected && (
<p className="text-xs text-emerald-400">
{connected ? (
<p className="text-xs text-emerald-700">
Conectado{email ? ` · ${email}` : ''}
</p>
) : (
<p className="text-xs text-amber-800">
Aún no conectado — pulsa el botón naranja.
</p>
)}
{msg && <p className="text-xs text-gray-600">{msg}</p>}
{err && <p className="text-xs text-red-400">{err}</p>}
{err && (
<p className="text-xs text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2">
{err}
</p>
)}
{matches && matches.length > 0 && (
<ul className="space-y-2 max-h-72 overflow-y-auto">