import Link from 'next/link' import { notFound } from 'next/navigation' import { supabaseAdmin, listAuthUsers } from '@/lib/supabaseAdmin' import { updateUserAction } from '../actions' import DeleteUserButton from './DeleteUserButton' interface ProfileRow { id: string full_name: string | null bar_association_no: string | null bar_name: string | null phone: string | null license_status: string | null license_expires_at: string | null license_started_at: string | null trial_start_date: string | null trial_end_date: string | null org_id: string | null created_at: string } interface LicenseRow { id: string plan: string status: string max_devices: number expires_at: string | null } function toDateInputValue(iso: string | null) { if (!iso) return '' return new Date(iso).toISOString().slice(0, 10) } function formatDate(iso: string | null) { if (!iso) return '—' return new Date(iso).toLocaleDateString('tr-TR', { day: 'numeric', month: 'short', year: 'numeric' }) } export default async function UserEditPage({ params, searchParams, }: { params: Promise<{ id: string }> searchParams: Promise<{ error?: string; success?: string }> }) { const { id } = await params const { error, success } = await searchParams const [{ data: profile }, authUsers, { data: licenses }] = await Promise.all([ supabaseAdmin .from('profiles') .select('id, full_name, bar_association_no, bar_name, phone, license_status, license_expires_at, license_started_at, trial_start_date, trial_end_date, org_id, created_at') .eq('id', id) .maybeSingle(), listAuthUsers(), supabaseAdmin.from('licenses').select('id, plan, status, max_devices, expires_at').eq('customer_id', id), ]) if (!profile) notFound() const p = profile as ProfileRow const email = authUsers.get(p.id)?.email || '' const linkedLicenses = (licenses as LicenseRow[] | null) || [] return (
← Kullanıcılar

Kullanıcı Düzenle

{email || p.id}

{error && (
{error}
)} {success && (
Değişiklikler kaydedildi.
)}

Ülke koduyla (+90) girin — WhatsApp AI hattının bu numarayı hesapla eşleştirmesi için kullanılır.

Vazgeç

Bağlı Lisanslar

{linkedLicenses.length === 0 ? (

Bu kullanıcıya bağlı lisans yok.

) : ( )}

Tehlikeli Bölge

) }