full update

This commit is contained in:
payacom
2026-07-18 14:29:05 +03:30
parent 17f334d0f1
commit af5b27b610
239 changed files with 10283 additions and 3041 deletions

View File

@@ -0,0 +1,32 @@
import { getApiBaseUrl } from "@/components/main/BaseUrl";
import { Post } from "@/types/types";
export async function fetchBookmarkPosts(
page: number,
limit: number,
token: string
): Promise<{ posts: Post[]; hasMore: boolean; totalItems: number }> {
const base = getApiBaseUrl();
const res = await fetch(
`${base}/posts/bookmarks?page=${page}&limit=${limit}`,
{
cache: "no-store",
headers: { Authorization: `Bearer ${token}` },
}
);
if (!res.ok) {
return { posts: [], hasMore: false, totalItems: 0 };
}
const data = await res.json();
const posts = (data?.posts ?? []) as Post[];
const totalItems = data?.totalItems ?? posts.length;
const totalPages = data?.totalPages ?? 1;
return {
posts,
hasMore: page < totalPages,
totalItems,
};
}

View File

@@ -11,7 +11,7 @@ export async function fetchPosts(
userLevel?: string;
rateFilter?: string;
_id?: string;
type?: string;
type?: "image" | "video";
exploreFilter?: string;
subExpertise?: string;
lat?: string;
@@ -19,6 +19,17 @@ export async function fetchPosts(
feedMode?: "grid" | "reels";
seedPostId?: string;
sort?: "latest";
reelsTab?: "for_you" | "following" | "saved";
heightMin?: string;
heightMax?: string;
weightMin?: string;
weightMax?: string;
sizeMin?: string;
sizeMax?: string;
hair_color?: string;
eye_color?: string;
q?: string;
hashtag?: string;
},
token: string
) {
@@ -53,5 +64,16 @@ export async function fetchPosts(
throw new Error(`Network response was not ok: ${response.status}`);
}
return response.json();
return response.json() as Promise<{
posts: unknown[];
totalPages?: number;
totalItems?: number;
feedMeta?: {
isColdStart?: boolean;
emptyFollowing?: boolean;
emptySaved?: boolean;
requiresAuth?: boolean;
suggestedUsers?: unknown[];
};
}>;
}

23
src/api/fetchProject.ts Normal file
View File

@@ -0,0 +1,23 @@
import { getApiBaseUrl } from "@/components/main/BaseUrl";
import { Project } from "@/types/types";
export async function fetchProject(
id: string,
token = ""
): Promise<Project | null> {
try {
const response = await fetch(`${getApiBaseUrl()}/projects/get/web/${id}`, {
cache: "no-store",
headers: {
Authorization: token ? `Bearer ${token}` : "",
},
});
if (!response.ok) return null;
const data = await response.json();
return data?.project ?? null;
} catch {
return null;
}
}

View File

@@ -19,6 +19,8 @@ export type StoryItem = {
createdAt?: string;
expires_at?: string;
viewed?: boolean;
liked?: boolean;
likes_count?: number;
};
export type StoryFeedUser = {
@@ -103,3 +105,64 @@ export async function updateStoryOverlays(
throw new Error(json?.message || "خطا در ویرایش استوری");
}
}
export type StoryViewerUser = {
_id: string;
user_name: string;
first_name: string;
last_name: string;
profile_image?: string;
viewed_at?: string;
};
export async function likeStory(
storyId: string,
token: string
): Promise<{ liked: boolean; already?: boolean }> {
const res = await fetch(`${getApiBaseUrl()}/stories/like`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ storyId }),
});
if (!res.ok) {
const json = await res.json().catch(() => ({}));
throw new Error(json?.message || "خطا در لایک استوری");
}
return res.json();
}
export async function commentOnStory(
storyId: string,
comment: string,
token: string
): Promise<void> {
const res = await fetch(`${getApiBaseUrl()}/stories/comment`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ storyId, comment }),
});
if (!res.ok) {
const json = await res.json().catch(() => ({}));
throw new Error(json?.message || "خطا در ارسال کامنت");
}
}
export async function fetchStoryViewers(
storyId: string,
token: string
): Promise<{ viewers: StoryViewerUser[]; total: number }> {
const res = await fetch(`${getApiBaseUrl()}/stories/${storyId}/viewers`, {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) {
const json = await res.json().catch(() => ({}));
throw new Error(json?.message || "خطا در دریافت بازدیدکنندگان");
}
return res.json();
}