···
1
-
import { useState } from "preact/hooks";
1
+
import { useState, useEffect } from "preact/hooks";
2
+
import { IS_BROWSER } from "fresh/runtime";
interface MigrationSetupProps {
···
interface ServerDescription {
inviteCodeRequired: boolean;
availableUserDomains: string[];
16
+
interface UserPassport {
export default function MigrationSetup(props: MigrationSetupProps) {
···
const [isLoading, setIsLoading] = useState(false);
const [showConfirmation, setShowConfirmation] = useState(false);
const [confirmationText, setConfirmationText] = useState("");
38
+
const [passport, setPassport] = useState<UserPassport | null>(null);
41
+
if (!IS_BROWSER) return;
43
+
const fetchPassport = async () => {
45
+
const response = await fetch("/api/me", {
46
+
credentials: "include",
49
+
throw new Error("Failed to fetch user profile");
51
+
const userData = await response.json();
53
+
// Get PDS URL from the current service
54
+
const pdsResponse = await fetch(`/api/resolve-pds?did=${userData.did}`);
55
+
const pdsData = await pdsResponse.json();
59
+
handle: userData.handle,
60
+
pds: pdsData.pds || "Unknown",
61
+
createdAt: new Date().toISOString() // TODO: Get actual creation date from API
65
+
console.error("Failed to fetch passport:", error);
const checkServerDescription = async (serviceUrl: string) => {
···
<div class="mt-2 text-sm text-gray-500 dark:text-gray-400 font-mono">FLIGHT: MIG-2024</div>
166
+
{/* Passport Section */}
168
+
<div class="mb-8 bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 border border-gray-200 dark:border-gray-700">
169
+
<div class="flex items-center justify-between mb-4">
170
+
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Current Passport</h3>
171
+
<div class="text-xs text-gray-500 dark:text-gray-400 font-mono">ISSUED: {new Date().toLocaleDateString()}</div>
173
+
<div class="grid grid-cols-2 gap-4 text-sm">
175
+
<div class="text-gray-500 dark:text-gray-400 mb-1">Handle</div>
176
+
<div class="font-mono text-gray-900 dark:text-white">{passport.handle}</div>
179
+
<div class="text-gray-500 dark:text-gray-400 mb-1">DID</div>
180
+
<div class="font-mono text-gray-900 dark:text-white break-all">{passport.did}</div>
183
+
<div class="text-gray-500 dark:text-gray-400 mb-1">Citizen of PDS</div>
184
+
<div class="font-mono text-gray-900 dark:text-white break-all">{passport.pds}</div>
187
+
<div class="text-gray-500 dark:text-gray-400 mb-1">Account Age</div>
188
+
<div class="font-mono text-gray-900 dark:text-white">
189
+
{passport.createdAt ? new Date(passport.createdAt).toLocaleDateString() : "Unknown"}
<form onSubmit={handleSubmit} class="space-y-6">
<div class="bg-red-50 dark:bg-red-900 rounded-lg">
···
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">
<span class="text-xs text-gray-500 ml-1">(Emergency Contact)</span>