This commit is contained in:
eric
2026-06-08 03:06:12 -05:00
parent 60dfe538b0
commit ebfec37e47
34 changed files with 1753 additions and 31 deletions

View File

@@ -23,12 +23,10 @@ function ProfileRow({
badge?: string;
onSelect?: () => void;
}) {
return (
<button
type="button"
onClick={onSelect}
className="flex w-full items-center gap-3 rounded-xl border border-gray-100 bg-white p-3 text-left shadow-sm transition-shadow hover:shadow-md dark:border-gray-800 dark:bg-gray-900"
>
const className =
"flex w-full items-center gap-3 rounded-xl border border-gray-100 bg-white p-3 text-left shadow-sm transition-shadow hover:shadow-md dark:border-gray-800 dark:bg-gray-900";
const content = (
<>
<img
src={mediaUrl(profile.photo)}
alt={profile.name}
@@ -46,8 +44,16 @@ function ProfileRow({
<span className="flex-shrink-0 rounded-full bg-gray-50 px-2 py-1 text-[10px] text-gray-400 dark:bg-gray-800 dark:text-gray-500">
{timeLabel}
</span>
</button>
</>
);
if (onSelect) {
return (
<button type="button" onClick={onSelect} className={className}>
{content}
</button>
);
}
return <div className={className}>{content}</div>;
}
export default function LikesPanel({ likes, mutual, formatTime, t, onSelectProfile }: LikesPanelProps) {
@@ -93,15 +99,29 @@ export default function LikesPanel({ likes, mutual, formatTime, t, onSelectProfi
</div>
<div className="space-y-3">
{mutual.length ? (
mutual.map((profile) => (
<ProfileRow
key={profile.id}
profile={profile}
timeLabel={formatTime(profile.matchedAt)}
badge={t("mutualBadge")}
onSelect={() => onSelectProfile?.(profile)}
/>
))
mutual.map((profile) =>
profile.conversationId ? (
<Link
key={profile.id}
href={`/chat/${profile.conversationId}`}
className="block"
>
<ProfileRow
profile={profile}
timeLabel={formatTime(profile.matchedAt)}
badge={t("mutualBadge")}
/>
</Link>
) : (
<ProfileRow
key={profile.id}
profile={profile}
timeLabel={formatTime(profile.matchedAt)}
badge={t("mutualBadge")}
onSelect={() => onSelectProfile?.(profile)}
/>
)
)
) : (
<div className="rounded-xl border border-dashed border-gray-200 p-4 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400">
{t("noMutualYet")}
@@ -110,7 +130,7 @@ export default function LikesPanel({ likes, mutual, formatTime, t, onSelectProfi
</div>
{mutual.length > 0 ? (
<Link
href="/messages"
href="/chat"
className="mt-3 inline-flex w-full items-center justify-center rounded-full bg-[#ff4d4f] px-4 py-2 text-sm font-semibold text-white transition hover:bg-red-600"
>
{t("goMessages")}

View File

@@ -6,11 +6,12 @@ import type { DatingProfile } from "../types";
interface MatchModalProps {
profile: DatingProfile | null;
conversationId?: string;
onClose: () => void;
t: (key: string) => string;
}
export default function MatchModal({ profile, onClose, t }: MatchModalProps) {
export default function MatchModal({ profile, conversationId, onClose, t }: MatchModalProps) {
if (!profile) return null;
return (
@@ -33,7 +34,7 @@ export default function MatchModal({ profile, onClose, t }: MatchModalProps) {
<p className="mt-1 text-sm text-gray-500 dark:text-gray-400">📍 {profile.location}</p>
<div className="mt-6 flex flex-col gap-3">
<Link
href="/messages"
href={conversationId ? `/chat/${conversationId}` : "/chat"}
onClick={onClose}
className="inline-flex items-center justify-center rounded-full bg-[#ff4d4f] px-4 py-3 text-sm font-semibold text-white transition hover:bg-red-600"
>

View File

@@ -63,7 +63,10 @@ function DatingPageInner() {
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
const [showQuotaPrompt, setShowQuotaPrompt] = useState(false);
const [canUndo, setCanUndo] = useState(false);
const [matchCelebration, setMatchCelebration] = useState<DatingProfile | null>(null);
const [matchCelebration, setMatchCelebration] = useState<{
profile: DatingProfile;
conversationId?: string;
} | null>(null);
const [mobilePanelOpen, setMobilePanelOpen] = useState(false);
const [dragX, setDragX] = useState(0);
const [isDragging, setIsDragging] = useState(false);
@@ -193,7 +196,10 @@ function DatingPageInner() {
const result = await saveSwipe(currentProfile.id, action, activeTab);
setCanUndo(true);
if (result.matched) {
setMatchCelebration(currentProfile);
setMatchCelebration({
profile: currentProfile,
conversationId: result.match?.conversationId,
});
refreshSidePanels();
} else if (action === "like") {
refreshSidePanels();
@@ -467,7 +473,12 @@ function DatingPageInner() {
</div>
) : null}
<MatchModal profile={matchCelebration} onClose={() => setMatchCelebration(null)} t={t} />
<MatchModal
profile={matchCelebration?.profile ?? null}
conversationId={matchCelebration?.conversationId}
onClose={() => setMatchCelebration(null)}
t={t}
/>
<Footer />
</div>
);

View File

@@ -16,6 +16,7 @@ export interface ProfileRecord {
matchedAt?: string;
intent?: MatchIntent;
connectionId?: string;
conversationId?: string;
}
export interface DatingProfile {
@@ -36,10 +37,16 @@ export interface DatingProfile {
likedAt?: string;
matchedAt?: string;
intent?: MatchIntent;
connectionId?: string;
conversationId?: string;
}
export interface SwipeResult {
ok: boolean;
matched: boolean;
match?: Record<string, unknown> | null;
match?: {
id?: string;
conversationId?: string;
[key: string]: unknown;
} | null;
}

View File

@@ -24,6 +24,8 @@ export function mapProfile(record: ProfileRecord, index: number): DatingProfile
likedAt: record.likedAt,
matchedAt: record.matchedAt,
intent: record.intent,
connectionId: record.connectionId,
conversationId: record.conversationId,
};
}