explor
This commit is contained in:
@@ -18,6 +18,7 @@ export async function fetchPosts(
|
||||
lng?: string;
|
||||
feedMode?: "grid" | "reels";
|
||||
seedPostId?: string;
|
||||
sort?: "latest";
|
||||
},
|
||||
token: string
|
||||
) {
|
||||
|
||||
@@ -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 || "خطا در ویرایش استوری");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user