All checks were successful
Build and Deploy LSFE Frontend / build-and-deploy (push) Successful in 4m36s
18 lines
516 B
TypeScript
18 lines
516 B
TypeScript
import { useState } from "react";
|
|
import { Product } from "../../types/doctor/generic";
|
|
import { ProductAPI } from "../../services/generic/productApi";
|
|
|
|
export const useProductApi = () => {
|
|
const [products, setProducts] = useState<Product[]>([]);
|
|
|
|
const fetchProducts = async () => {
|
|
try {
|
|
const result = await ProductAPI.getAll();
|
|
setProducts(result);
|
|
} catch (error) {
|
|
console.error("Error fetching Districts", error);
|
|
}
|
|
};
|
|
|
|
return { products, setProducts, fetchProducts };
|
|
}; |