SPB Git forge

spb/toveli

Public
14commits 1branches 0releases
1.1 MBsize
maindefault branch
4 h agolast push
TypeScript 50.6% JavaScript 46.1% SQL 2.1% Shell 0.6% CSS 0.5%
1.0 KB · 14 lines tsx
Raw Blame History
1import { requireUser } from "@/lib/auth/session";2import { db } from "@/db/client";3import { users, userProfiles } from "@/db/schema";4import { eq } from "drizzle-orm";5import { decrypt } from "@/lib/auth/crypto";6import { ProfileForm } from "./profile-form";7export const dynamic = "force-dynamic";8export default async function Profil() {9  const u = await requireUser(); const d = db();10  const [row] = await d.select({ u: users, p: userProfiles }).from(users).leftJoin(userProfiles, eq(userProfiles.userId, users.id)).where(eq(users.id, u.id)).limit(1);11  let phone = ""; try { phone = row.u.phoneEncrypted ? decrypt(row.u.phoneEncrypted) : ""; } catch { phone = ""; }12  return <ProfileForm initial={{ email: row.u.email, displayName: row.u.displayName ?? "", publicName: row.p?.publicName ?? "", phone, sellerType: (row.p?.sellerType as "OWNER" | "AGENT") ?? "OWNER", bio: row.p?.bio ?? "", prefs: (row.u.prefs ?? {}) as { notifications?: Record<string, boolean>; privacy?: Record<string, boolean>; termsAcceptedAt?: string } }} />;13}14