This commit is contained in:
payacom
2026-07-11 20:48:36 +03:30
parent 8e75913441
commit 0864ae4723
27 changed files with 917 additions and 146 deletions

View File

@@ -18,6 +18,7 @@ export async function fetchPosts(
lng?: string;
feedMode?: "grid" | "reels";
seedPostId?: string;
sort?: "latest";
},
token: string
) {

View File

@@ -1,9 +1,21 @@
import { getApiBaseUrl } from "@/components/main/BaseUrl";
export type StoryTextOverlay = {
text: string;
x: number;
y: number;
font_size: number;
color: string;
background?: string;
rotation?: number;
align?: "left" | "center" | "right";
};
export type StoryItem = {
_id: string;
media_path: string;
media_type: "image" | "video";
overlays?: StoryTextOverlay[];
createdAt?: string;
expires_at?: string;
viewed?: boolean;
@@ -56,7 +68,8 @@ export async function markStoryViewed(
export async function createStoryBase64(
file: { name: string; type: string; data: string },
token: string
token: string,
overlays: StoryTextOverlay[] = []
): Promise<void> {
const res = await fetch(`${getApiBaseUrl()}/stories/create-base64`, {
method: "POST",
@@ -64,10 +77,29 @@ export async function createStoryBase64(
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ file }),
body: JSON.stringify({ file, overlays }),
});
if (!res.ok) {
const json = await res.json().catch(() => ({}));
throw new Error(json?.message || "خطا در انتشار استوری");
}
}
export async function updateStoryOverlays(
storyId: string,
overlays: StoryTextOverlay[],
token: string
): Promise<void> {
const res = await fetch(`${getApiBaseUrl()}/stories/${storyId}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ overlays }),
});
if (!res.ok) {
const json = await res.json().catch(() => ({}));
throw new Error(json?.message || "خطا در ویرایش استوری");
}
}