From 55ac2a1c4232f61f4bb745ad4ab319a559ff537f Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Wed, 21 May 2025 17:35:13 +0330 Subject: [PATCH] added use get resellers categories --- .../resellers/useGetResellersCategories.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 frontend/composables/api/resellers/useGetResellersCategories.ts diff --git a/frontend/composables/api/resellers/useGetResellersCategories.ts b/frontend/composables/api/resellers/useGetResellersCategories.ts new file mode 100644 index 0000000..9e97ec8 --- /dev/null +++ b/frontend/composables/api/resellers/useGetResellersCategories.ts @@ -0,0 +1,37 @@ +// imports + +import { useQuery } from "@tanstack/vue-query"; +import { API_ENDPOINTS, QUERY_KEYS } from "~/constants"; + +// types + +export type GetResellersCategoriesResponse = { + id: number; + title: string; + description: string; + link: string; + image: string; +}[]; + +const useGetResellersCategories = () => { + // state + + const { $axios: axios } = useNuxtApp(); + + // methods + + const handleGetResellersCategories = async () => { + const { data } = await axios.get( + `${API_ENDPOINTS.resellers_products.categories}` + ); + + return data; + }; + + return useQuery({ + queryKey: [QUERY_KEYS.resellers_categories], + queryFn: () => handleGetResellersCategories(), + }); +}; + +export default useGetResellersCategories;