brands-in-shops feature implemented

This commit is contained in:
2025-05-27 23:41:04 +02:00
parent 7037be370e
commit 2846bcbb1c
9 changed files with 559 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
import { Product, ProductCreate, Shop, ShopCreate, ShoppingEvent, ShoppingEventCreate, Brand, BrandCreate, Grocery, GroceryCreate, GroceryCategory, GroceryCategoryCreate } from '../types';
import { Product, ProductCreate, Shop, ShopCreate, ShoppingEvent, ShoppingEventCreate, Brand, BrandCreate, Grocery, GroceryCreate, GroceryCategory, GroceryCategoryCreate, BrandInShop, BrandInShopCreate } from '../types';
// Use different API URLs based on environment
const API_BASE_URL = process.env.NODE_ENV === 'production'
@@ -54,6 +54,16 @@ export const brandApi = {
delete: (id: number) => api.delete(`/brands/${id}`),
};
// BrandInShop API functions
export const brandInShopApi = {
getAll: () => api.get<BrandInShop[]>('/brands-in-shops/'),
getByShop: (shopId: number) => api.get<BrandInShop[]>(`/brands-in-shops/shop/${shopId}`),
getByBrand: (brandId: number) => api.get<BrandInShop[]>(`/brands-in-shops/brand/${brandId}`),
getById: (id: number) => api.get<BrandInShop>(`/brands-in-shops/${id}`),
create: (brandInShop: BrandInShopCreate) => api.post<BrandInShop>('/brands-in-shops/', brandInShop),
delete: (id: number) => api.delete(`/brands-in-shops/${id}`),
};
// Grocery Category API functions
export const groceryCategoryApi = {
getAll: () => api.get<GroceryCategory[]>('/grocery-categories/'),