Fixed various build errors
This commit is contained in:
@@ -154,14 +154,12 @@ export default function ProfilePage() {
|
||||
const method = isFollowing ? 'DELETE' : 'POST';
|
||||
const res = await fetch(`/api/users/${handle}/follow`, { method });
|
||||
|
||||
if (res.ok) {
|
||||
if (res.ok && user) {
|
||||
setIsFollowing(!isFollowing);
|
||||
if (user) {
|
||||
setUser({
|
||||
...user,
|
||||
followersCount: isFollowing ? user.followersCount - 1 : user.followersCount + 1,
|
||||
});
|
||||
}
|
||||
setUser({
|
||||
...user,
|
||||
followersCount: isFollowing ? (user.followersCount || 0) - 1 : (user.followersCount || 0) + 1,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -352,7 +350,7 @@ export default function ProfilePage() {
|
||||
fontSize: '14px',
|
||||
}}>
|
||||
<CalendarIcon />
|
||||
<span>Joined {formatDate(user.createdAt)}</span>
|
||||
<span>Joined {formatDate(user.createdAt || new Date().toISOString())}</span>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: '16px', marginTop: '12px' }}>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { db, posts, users, notifications } from '@/db';
|
||||
import { requireAuth } from '@/lib/auth';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { eq, and } from 'drizzle-orm';
|
||||
|
||||
type RouteContext = { params: Promise<{ id: string }> };
|
||||
|
||||
|
||||
@@ -70,13 +70,13 @@ export async function GET(
|
||||
...post,
|
||||
isLiked: likedPostIds.has(post.id),
|
||||
isReposted: repostedPostIds.has(post.id),
|
||||
};
|
||||
} as any;
|
||||
|
||||
replyPosts = replies.map(r => ({
|
||||
...r,
|
||||
isLiked: likedPostIds.has(r.id),
|
||||
isReposted: repostedPostIds.has(r.id),
|
||||
}));
|
||||
})) as any;
|
||||
}
|
||||
} catch {
|
||||
// Not authenticated or other error, skip flags
|
||||
|
||||
@@ -328,7 +328,7 @@ export async function GET(request: Request) {
|
||||
...p,
|
||||
isLiked: likedPostIds.has(p.id),
|
||||
isReposted: repostedPostIds.has(p.id),
|
||||
}));
|
||||
})) as any;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { HeartIcon, RepeatIcon, MessageIcon, FlagIcon } from '@/components/Icons';
|
||||
import { Post } from '@/lib/types';
|
||||
|
||||
interface PostCardProps {
|
||||
post: Post;
|
||||
onLike?: (id: string) => void;
|
||||
onRepost?: (id: string) => void;
|
||||
onLike?: (id: string, currentLiked: boolean) => void;
|
||||
onRepost?: (id: string, currentReposted: boolean) => void;
|
||||
onComment?: (post: Post) => void;
|
||||
isDetail?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user