tia/src/app/api/time/route.ts
Mannu e99a874309 Wardrobe: gallery picker + non-blocking vision AI; add /api/time endpoint
Wardrobe add page:
- Remove capture="environment" so Android shows the Camera/Gallery chooser
  instead of opening the camera directly
- Vision AI no longer blocks the UI: photo preview + form appear instantly
  after selecting an image; upload spinner shows on the thumbnail while R2
  upload runs; vision AI fires in the background and fills in tags when done
  without interrupting the user (they can pick size/occasions in parallel)
- "AI tagging…" pulsing badge in header while vision runs; " AI pre-filled"
  badge when done; form fields are only overwritten if the user hasn't already
  typed/selected something (functional state updater with prev-value guard)
- Save button is disabled (with "Uploading photo…" label) until R2 upload
  completes — prevents saving a garment with no imageKey

/api/time endpoint (GET, no auth):
- Returns { utc, istDate, istTime, ist, offsetMinutes } for the current server
  time in Asia/Kolkata so the app can verify server clock and surface IST time
  reliably (can be called from browser console at /api/time)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 23:31:18 +05:30

50 lines
1.4 KiB
TypeScript

import { NextResponse } from "next/server";
const TZ = "Asia/Kolkata";
/**
* GET /api/time
* Returns the server's current time in IST. The app can call this to verify
* that the user's device clock matches the server, and to use a trusted
* timestamp source for log entries if needed.
*
* No auth required — time is not sensitive.
*/
export async function GET() {
const now = new Date();
const istDate = now.toLocaleDateString("sv-SE", { timeZone: TZ }); // YYYY-MM-DD
const istTime = now.toLocaleTimeString("en-IN", {
timeZone: TZ,
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
});
const istLabel = now.toLocaleString("en-IN", {
timeZone: TZ,
weekday: "short",
day: "numeric",
month: "short",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
hour12: true,
});
return NextResponse.json(
{
utc: now.toISOString(), // e.g. "2026-05-28T09:00:00.000Z"
istDate, // e.g. "2026-05-28"
istTime, // e.g. "14:30:00"
ist: istLabel, // e.g. "Wed, 28 May 2026, 02:30 PM"
offsetMinutes: 330, // IST = UTC +5:30
},
{
headers: {
// Do not cache — always return live server time
"Cache-Control": "no-store",
},
}
);
}