diff --git a/frontend/lib/actions.ts b/frontend/lib/actions.ts
index 111632b..ff22058 100644
--- a/frontend/lib/actions.ts
+++ b/frontend/lib/actions.ts
@@ -210,6 +210,25 @@ export async function verifyPhoneCode(phoneNumber: string, code: string) {
body: JSON.stringify({ phone_number: phoneNumber, code }),
});
}
+// ------------------------------------------------------------
+// adding and removing listings from favorites
+// ------------------------------------------------------------
+
+export async function addToUsersFavorites(listingId: number) {
+ const res = await serverFetch
(`/market/listings/${listingId}/favorites/`, {
+ method: "POST",
+ });
+ return res;
+}
+export async function deleteFromUsersFavorites(listingId: number) {
+ return await serverFetch(`/market/listings/${listingId}/favorites/`, {
+ method: "DELETE",
+ });
+}
+
+export async function getUsersFavorites() {
+ return await serverFetch>("/market/favorites/");
+}
// ------------------------------------------------------------
// creating new listings
diff --git a/frontend/lib/types.ts b/frontend/lib/types.ts
index 84d5f68..2c16154 100644
--- a/frontend/lib/types.ts
+++ b/frontend/lib/types.ts
@@ -61,6 +61,7 @@ type BaseListing = {
images: string[];
tags: string[];
favorite_count: number;
+ is_favorited?: boolean;
seller: User;
};