update frontend

This commit is contained in:
Parsa Nazer
2026-05-28 10:32:03 +03:30
parent 481452eea7
commit 35864e61dd
14 changed files with 473 additions and 35 deletions
@@ -26,7 +26,7 @@ const useGetAllOrders = () => {
const handleGetAllOrders = async () => {
const { data } = await axios.get<GetAllOrdersResponse>(API_ENDPOINTS.orders.get_all, {
params: {
sort: sort.value ?? "created_at",
sort: sort.value ?? "-created_at",
status: status.value,
offset: Number(page.value) * 10 - 10,
limit: 10,
@@ -0,0 +1,30 @@
// imports
import { useQuery } from "@tanstack/vue-query";
import type { ComputedRef } from "vue";
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
// types
export type GetOrderResponse = OrderDetail;
const useGetOrder = (id: ComputedRef<string>) => {
// state
const { $axios: axios } = useNuxtApp();
// methods
const handleGetOrder = async () => {
const { data } = await axios.get<GetOrderResponse>(`${API_ENDPOINTS.orders.get_one}/${id.value}`);
return data;
};
return useQuery({
queryKey: [QUERY_KEYS.order, id],
queryFn: () => handleGetOrder(),
enabled: computed(() => !!id.value),
});
};
export default useGetOrder;