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