From 1d5ad5f62f060e7edc15fd01b648fc4a94f987e6 Mon Sep 17 00:00:00 2001 From: egecankomur Date: Tue, 5 May 2026 20:19:02 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20presentation=20expiresAt=20=E2=80=94=20s?= =?UTF-8?q?kip=20empty=20date,=20convert=20YYYY-MM-DD=20to=20end-of-day=20?= =?UTF-8?q?UTC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Empty string sent to Appwrite datetime column was being interpreted as creation timestamp, making every no-expiry sunum immediately expired. Fix: - Only include expiresAt in payload when user actually set a date - Convert date-only string (YYYY-MM-DD) to YYYY-MM-DDT23:59:59.000Z so the sunum stays valid for the entire chosen day across all time zones - Strip empty customerId/notes to avoid empty-string writes --- .../(auth)/sign-in/components/login-form-1.tsx | 5 ----- src/lib/appwrite/presentation-actions.ts | 16 ++++++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/app/(auth)/sign-in/components/login-form-1.tsx b/src/app/(auth)/sign-in/components/login-form-1.tsx index dbb0623..d4aff3f 100644 --- a/src/app/(auth)/sign-in/components/login-form-1.tsx +++ b/src/app/(auth)/sign-in/components/login-form-1.tsx @@ -191,11 +191,6 @@ export function LoginForm1({

- - {/* Alt logo — sadece geniş ekranda gizli olan mobil için */} -

- Emlak CRM · Kovak Yazılım -

); diff --git a/src/lib/appwrite/presentation-actions.ts b/src/lib/appwrite/presentation-actions.ts index a48a3bb..3330038 100644 --- a/src/lib/appwrite/presentation-actions.ts +++ b/src/lib/appwrite/presentation-actions.ts @@ -30,6 +30,8 @@ export async function createPresentationAction( const data = parsed.data; const id = ID.unique(); const shareToken = crypto.randomBytes(16).toString("hex"); + // Convert "YYYY-MM-DD" → end-of-day UTC so the sunum is valid the full chosen day. + const expiresAt = data.expiresAt ? `${data.expiresAt}T23:59:59.000Z` : undefined; try { await tablesDB.createRow( @@ -39,12 +41,12 @@ export async function createPresentationAction( { tenantId: ctx.tenantId, title: data.title, - customerId: data.customerId, + customerId: data.customerId || undefined, propertyIds: data.propertyIds, shareToken, - expiresAt: data.expiresAt, + ...(expiresAt ? { expiresAt } : {}), viewCount: 0, - notes: data.notes, + notes: data.notes || undefined, createdBy: ctx.user.id, }, [ @@ -81,13 +83,15 @@ export async function updatePresentationAction( const { tablesDB } = createAdminClient(); const data = parsed.data; + const expiresAt = data.expiresAt ? `${data.expiresAt}T23:59:59.000Z` : undefined; + try { await tablesDB.updateRow(DATABASE_ID, TABLES.presentations, id, { title: data.title, - customerId: data.customerId, + customerId: data.customerId || undefined, propertyIds: data.propertyIds, - expiresAt: data.expiresAt, - notes: data.notes, + ...(expiresAt ? { expiresAt } : {}), + notes: data.notes || undefined, }); } catch { return { ok: false, error: "Sunum güncellenemedi." };