Loading Dockerfile +1 −1 Original line number Diff line number Diff line FROM node:14 FROM node:18 WORKDIR /app COPY package*.json ./ RUN npm install Loading actions/cart.tsx +3 −6 Original line number Diff line number Diff line import { Product } from "@prisma/client"; import { useEffect, useState } from "react"; import { getStorageItem, setStorageItem } from "../utils/storage"; import { ShoppingCart } from "../config/types"; import { shoppingCart } from "../signals"; import { ProductWithPhotosAndCategories, ShoppingCart } from "../config/types"; import { getStorageItem, setStorageItem } from "../utils/storage"; export const useCart = () => { if (getStorageItem("cart") === null) setStorageItem("cart", []); Loading @@ -16,10 +16,7 @@ export const useCart = () => { saveCart(); }, [shoppingCart.value]); const addToCart = ( product: ProductWithPhotosAndCategories, quantity: number ) => { const addToCart = (product: Product, quantity: number) => { shoppingCart.value = [...shoppingCart.value, { product, quantity }]; }; Loading actions/categories.tsx +4 −4 Original line number Diff line number Diff line import { Category } from "@prisma/client"; import { API_URL } from "../config/paths"; import { CATEGORIES_URL } from "../config/paths"; export const fetchCategories = async () => { const res = await fetch(`${API_URL}/categories`); const res = await fetch(`${CATEGORIES_URL}`); const data = await res.json(); return data; }; export const deleteCategory = async (id: number) => { return fetch(`${API_URL}/categories/${id}`, { return fetch(`${CATEGORIES_URL}${id}`, { method: "DELETE", }).then((res) => res.json()); }; export const createCategory = async (category: Omit<Category, "id">) => { return await fetch(`${API_URL}/categories`, { return await fetch(`${CATEGORIES_URL}`, { method: "POST", body: JSON.stringify(category), }).then((res) => res.json()); Loading actions/orders.tsx +7 −8 Original line number Diff line number Diff line import { Order } from "@prisma/client"; import { API_URL } from "../config/paths"; import { API_URL, ORDERS_URL, PRODUCTS_URL, USERS_URL } from "../config/paths"; import { OrderPatchData, OrderPostData } from "../config/types"; export const createOrder = async (order: OrderPostData) => { return await fetch(`${API_URL}/orders`, { return await fetch(`${ORDERS_URL}`, { method: "POST", body: JSON.stringify(order), }); }; export const updateOrder = async (order: OrderPatchData) => { return fetch(`${API_URL}/orders/${order.id}`, { return fetch(`${ORDERS_URL}/${order.id}`, { method: "PATCH", body: JSON.stringify(order), }).then((res) => res.json()); }; export const deleteOrder = async (id: number) => { return fetch(`${API_URL}/orders/${id}`, { return fetch(`${ORDERS_URL}/${id}`, { method: "DELETE", }).then((res) => res.json()); }; export const fetchOneOrder = async (id: number) => { return fetch(`${API_URL}/orders/${id}`, { return fetch(`${ORDERS_URL}/${id}`, { method: "GET", }).then((res) => res.json()); }; export const fetchProductOrders = async (productId: number) => { return fetch(`${API_URL}/products/${productId}/orders`, { return fetch(`${PRODUCTS_URL}/${productId}/orders`, { method: "GET", }).then((res) => res.json()); }; export const fetchUserOrders = async (userId: number) => { return fetch(`${API_URL}/user/${userId}/orders`, { return fetch(`${USERS_URL}/${userId}/orders`, { method: "GET", }).then((res) => res.json()); }; actions/products.tsx +16 −18 Original line number Diff line number Diff line import queryString from "query-string"; import { API_URL } from "../config/paths"; import { ProductWithPhotosAndCategories } from "../config/types"; import { API_URL, PRODUCTS_URL } from "../config/paths"; import { ProductData, ProductPostData, ProductWithCategories, } from "../config/types"; import { searchFilters } from "../signals"; export const fetchOneProduct = async ( id: number ): Promise<ProductWithPhotosAndCategories> => { return fetch(`${API_URL}/products/${id}`, { ): Promise<ProductWithCategories> => { return fetch(`${PRODUCTS_URL}/${id}`, { method: "GET", }).then((res) => res.json()); }; export const fetchProducts = async (): Promise< ProductWithPhotosAndCategories[] > => { export const fetchProducts = async (): Promise<ProductWithCategories[]> => { return fetch( `${API_URL}/products?` + queryString.stringify(searchFilters.value), `${PRODUCTS_URL}?` + queryString.stringify(searchFilters.value), { method: "GET", } Loading @@ -24,26 +26,22 @@ export const fetchProducts = async (): Promise< }); }; export const createProduct = async ( product: Omit<ProductWithPhotosAndCategories, "id"> ) => { return await fetch(`${API_URL}/products`, { export const createProduct = async (product: ProductPostData) => { return await fetch(`${PRODUCTS_URL}`, { method: "POST", body: JSON.stringify(product), }); }; export const updateProduct = async ( product: Partial<ProductWithPhotosAndCategories> ) => { return fetch(`${API_URL}/products/${product.id}`, { export const updateProduct = async (product: ProductData) => { return fetch(`${PRODUCTS_URL}/${product.id}`, { method: "PATCH", body: JSON.stringify(product), }).then((res) => res.json()); }; export const deleteProduct = async (id: number) => { return fetch(`${API_URL}/products/${id}`, { return fetch(`${PRODUCTS_URL}/${id}`, { method: "DELETE", }).then((res) => res.json()); }; Loading @@ -67,7 +65,7 @@ const modifyProductCategory = async ( categoryId: number, method: "POST" | "DELETE" ) => { return fetch(`${API_URL}/products/${productId}/categories`, { return fetch(`${PRODUCTS_URL}/${productId}/categories`, { method: method, body: JSON.stringify({ categoryId: categoryId }), }).then((res) => res.json()); Loading Loading
Dockerfile +1 −1 Original line number Diff line number Diff line FROM node:14 FROM node:18 WORKDIR /app COPY package*.json ./ RUN npm install Loading
actions/cart.tsx +3 −6 Original line number Diff line number Diff line import { Product } from "@prisma/client"; import { useEffect, useState } from "react"; import { getStorageItem, setStorageItem } from "../utils/storage"; import { ShoppingCart } from "../config/types"; import { shoppingCart } from "../signals"; import { ProductWithPhotosAndCategories, ShoppingCart } from "../config/types"; import { getStorageItem, setStorageItem } from "../utils/storage"; export const useCart = () => { if (getStorageItem("cart") === null) setStorageItem("cart", []); Loading @@ -16,10 +16,7 @@ export const useCart = () => { saveCart(); }, [shoppingCart.value]); const addToCart = ( product: ProductWithPhotosAndCategories, quantity: number ) => { const addToCart = (product: Product, quantity: number) => { shoppingCart.value = [...shoppingCart.value, { product, quantity }]; }; Loading
actions/categories.tsx +4 −4 Original line number Diff line number Diff line import { Category } from "@prisma/client"; import { API_URL } from "../config/paths"; import { CATEGORIES_URL } from "../config/paths"; export const fetchCategories = async () => { const res = await fetch(`${API_URL}/categories`); const res = await fetch(`${CATEGORIES_URL}`); const data = await res.json(); return data; }; export const deleteCategory = async (id: number) => { return fetch(`${API_URL}/categories/${id}`, { return fetch(`${CATEGORIES_URL}${id}`, { method: "DELETE", }).then((res) => res.json()); }; export const createCategory = async (category: Omit<Category, "id">) => { return await fetch(`${API_URL}/categories`, { return await fetch(`${CATEGORIES_URL}`, { method: "POST", body: JSON.stringify(category), }).then((res) => res.json()); Loading
actions/orders.tsx +7 −8 Original line number Diff line number Diff line import { Order } from "@prisma/client"; import { API_URL } from "../config/paths"; import { API_URL, ORDERS_URL, PRODUCTS_URL, USERS_URL } from "../config/paths"; import { OrderPatchData, OrderPostData } from "../config/types"; export const createOrder = async (order: OrderPostData) => { return await fetch(`${API_URL}/orders`, { return await fetch(`${ORDERS_URL}`, { method: "POST", body: JSON.stringify(order), }); }; export const updateOrder = async (order: OrderPatchData) => { return fetch(`${API_URL}/orders/${order.id}`, { return fetch(`${ORDERS_URL}/${order.id}`, { method: "PATCH", body: JSON.stringify(order), }).then((res) => res.json()); }; export const deleteOrder = async (id: number) => { return fetch(`${API_URL}/orders/${id}`, { return fetch(`${ORDERS_URL}/${id}`, { method: "DELETE", }).then((res) => res.json()); }; export const fetchOneOrder = async (id: number) => { return fetch(`${API_URL}/orders/${id}`, { return fetch(`${ORDERS_URL}/${id}`, { method: "GET", }).then((res) => res.json()); }; export const fetchProductOrders = async (productId: number) => { return fetch(`${API_URL}/products/${productId}/orders`, { return fetch(`${PRODUCTS_URL}/${productId}/orders`, { method: "GET", }).then((res) => res.json()); }; export const fetchUserOrders = async (userId: number) => { return fetch(`${API_URL}/user/${userId}/orders`, { return fetch(`${USERS_URL}/${userId}/orders`, { method: "GET", }).then((res) => res.json()); };
actions/products.tsx +16 −18 Original line number Diff line number Diff line import queryString from "query-string"; import { API_URL } from "../config/paths"; import { ProductWithPhotosAndCategories } from "../config/types"; import { API_URL, PRODUCTS_URL } from "../config/paths"; import { ProductData, ProductPostData, ProductWithCategories, } from "../config/types"; import { searchFilters } from "../signals"; export const fetchOneProduct = async ( id: number ): Promise<ProductWithPhotosAndCategories> => { return fetch(`${API_URL}/products/${id}`, { ): Promise<ProductWithCategories> => { return fetch(`${PRODUCTS_URL}/${id}`, { method: "GET", }).then((res) => res.json()); }; export const fetchProducts = async (): Promise< ProductWithPhotosAndCategories[] > => { export const fetchProducts = async (): Promise<ProductWithCategories[]> => { return fetch( `${API_URL}/products?` + queryString.stringify(searchFilters.value), `${PRODUCTS_URL}?` + queryString.stringify(searchFilters.value), { method: "GET", } Loading @@ -24,26 +26,22 @@ export const fetchProducts = async (): Promise< }); }; export const createProduct = async ( product: Omit<ProductWithPhotosAndCategories, "id"> ) => { return await fetch(`${API_URL}/products`, { export const createProduct = async (product: ProductPostData) => { return await fetch(`${PRODUCTS_URL}`, { method: "POST", body: JSON.stringify(product), }); }; export const updateProduct = async ( product: Partial<ProductWithPhotosAndCategories> ) => { return fetch(`${API_URL}/products/${product.id}`, { export const updateProduct = async (product: ProductData) => { return fetch(`${PRODUCTS_URL}/${product.id}`, { method: "PATCH", body: JSON.stringify(product), }).then((res) => res.json()); }; export const deleteProduct = async (id: number) => { return fetch(`${API_URL}/products/${id}`, { return fetch(`${PRODUCTS_URL}/${id}`, { method: "DELETE", }).then((res) => res.json()); }; Loading @@ -67,7 +65,7 @@ const modifyProductCategory = async ( categoryId: number, method: "POST" | "DELETE" ) => { return fetch(`${API_URL}/products/${productId}/categories`, { return fetch(`${PRODUCTS_URL}/${productId}/categories`, { method: method, body: JSON.stringify({ categoryId: categoryId }), }).then((res) => res.json()); Loading