@@ -33,8 +34,13 @@ const timeAgo = usePersianTimeAgo(new Date(data.value.created_at));
|
{{ data.subject ? data.subject : "--" }}
|
-
- {{ data.created_at ? timeAgo : "--" }}
+ |
+
+ ایجاد : {{ data.created_at ? createdTimeAgo : "--" }}
+
+
+ بروزرسانی : {{ data.updated_at ? updatedTimeAgo : "--" }}
+
|
;
+
+export type GetAllOrdersRequest = {
+ sort: string | undefined;
+ status: string | undefined;
+ page: string | string[];
+};
+
+const useGetAllOrders = (params: ComputedRef ) => {
+ // state
+
+ const { $axios: axios } = useNuxtApp();
+
+ // methods
+
+ const handleGetAllOrders = async (params: GetAllOrdersRequest) => {
+ const { data } = await axios.get(
+ API_ENDPOINTS.orders.get_all,
+ {
+ params: {
+ sort: params.sort,
+ filter: params.status,
+ offset: Number(params.page) * 7 - 7,
+ limit: 7,
+ },
+ }
+ );
+ return data;
+ };
+
+ return useQuery({
+ queryKey: [QUERY_KEYS.orders, params],
+ queryFn: () => handleGetAllOrders(params.value),
+ });
+};
+
+export default useGetAllOrders;
diff --git a/frontend/composables/api/orders/useGetOrdersCart.ts b/frontend/composables/api/orders/useGetCartOrders.ts
similarity index 57%
rename from frontend/composables/api/orders/useGetOrdersCart.ts
rename to frontend/composables/api/orders/useGetCartOrders.ts
index f726fb6..03ebe0a 100644
--- a/frontend/composables/api/orders/useGetOrdersCart.ts
+++ b/frontend/composables/api/orders/useGetCartOrders.ts
@@ -5,17 +5,17 @@ import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
// types
-export type GetOrdersCartResponse = Cart;
+export type GetCartOrdersResponse = Cart;
-const useGetOrdersCart = () => {
+const useGetCartOrders = () => {
// state
const { $axios: axios } = useNuxtApp();
// methods
- const handleGetOrdersCart = async () => {
- const { data } = await axios.get(
+ const handleGetCartOrders = async () => {
+ const { data } = await axios.get(
API_ENDPOINTS.orders.cart.get_all
);
return data;
@@ -23,8 +23,8 @@ const useGetOrdersCart = () => {
return useQuery({
queryKey: [QUERY_KEYS.cart],
- queryFn: () => handleGetOrdersCart(),
+ queryFn: () => handleGetCartOrders(),
});
};
-export default useGetOrdersCart;
+export default useGetCartOrders;
diff --git a/frontend/composables/api/orders/useGetOrdersAll.ts b/frontend/composables/api/orders/useGetOrdersAll.ts
deleted file mode 100644
index c6781fc..0000000
--- a/frontend/composables/api/orders/useGetOrdersAll.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-// imports
-
-import { useQuery } from "@tanstack/vue-query";
-import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
-
-// types
-
-export type GetOrdersAllResponse = Order[];
-
-const useGetOrdersAll = () => {
- // state
-
- const { $axios: axios } = useNuxtApp();
-
- // methods
-
- const handleGetOrdersAll = async () => {
- const { data } = await axios.get(
- API_ENDPOINTS.orders.get_all
- );
- return data;
- };
-
- return useQuery({
- queryKey: [QUERY_KEYS.orders],
- queryFn: () => handleGetOrdersAll(),
- });
-};
-
-export default useGetOrdersAll;
diff --git a/frontend/composables/api/tickets/useGetAllTickets.ts b/frontend/composables/api/tickets/useGetAllTickets.ts
index 9c26d2d..2fb48d4 100644
--- a/frontend/composables/api/tickets/useGetAllTickets.ts
+++ b/frontend/composables/api/tickets/useGetAllTickets.ts
@@ -7,28 +7,28 @@ import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";
export type GetAllTicketsResponse = ApiPaginated>;
-export type GetAllTicketsFilters = {
+export type GetAllTicketsRequest = {
sort: string | undefined;
status: string | undefined;
page: string | string[];
};
-const useGetAllTickets = (params: Ref) => {
+const useGetAllTickets = (params: ComputedRef) => {
// state
const { $axios: axios } = useNuxtApp();
// methods
- const handleGetAllTickets = async (params: GetAllTicketsFilters) => {
+ const handleGetAllTickets = async (params: GetAllTicketsRequest) => {
const { data } = await axios.get(
API_ENDPOINTS.tickets.get_all,
{
params: {
sort: params.sort,
filter: params.status,
- offset: Number(params.page) * 7 - 7,
- limit: 7,
+ offset: Number(params.page) * 10 - 10,
+ limit: 10,
},
}
);
diff --git a/frontend/layouts/Cart.vue b/frontend/layouts/Cart.vue
index cb9c338..edc240b 100644
--- a/frontend/layouts/Cart.vue
+++ b/frontend/layouts/Cart.vue
@@ -1,5 +1,5 @@
-
-
-
-
-
-
diff --git a/frontend/pages/profile/purchases-and-orders/[id].vue b/frontend/pages/profile/purchases-and-orders/[id].vue
new file mode 100644
index 0000000..4c44202
--- /dev/null
+++ b/frontend/pages/profile/purchases-and-orders/[id].vue
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/frontend/pages/profile/purchases-and-orders/index.vue b/frontend/pages/profile/purchases-and-orders/index.vue
new file mode 100644
index 0000000..07d579b
--- /dev/null
+++ b/frontend/pages/profile/purchases-and-orders/index.vue
@@ -0,0 +1,256 @@
+
+
+
+
+
+
+
+
+
+
+ ترتیب بر اساس
+
+
+
+ وضعیت
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ {{ tableHead }}
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/pages/profile/tickets/index.vue b/frontend/pages/profile/tickets/index.vue
index 26c153f..e6d7111 100644
--- a/frontend/pages/profile/tickets/index.vue
+++ b/frontend/pages/profile/tickets/index.vue
@@ -2,7 +2,7 @@
// imports
import useGetAllTickets, {
- type GetAllTicketsFilters,
+ type GetAllTicketsRequest,
} from "~/composables/api/tickets/useGetAllTickets";
// meta
@@ -14,7 +14,7 @@ definePageMeta({
// state
-const params: GetAllTicketsFilters = useUrlSearchParams("history");
+const params: GetAllTicketsRequest = useUrlSearchParams("history");
const filters = computed(() => {
return {
@@ -74,11 +74,24 @@ const tickets = computed(() => {
const hasTickets = computed(() => data.value?.count > 0);
+const hasFilters = computed(() =>
+ Object.keys(params)
+ .filter((key) => key != "page")
+ .some((key) => params[key] != undefined)
+);
+
const paginationData = computed(() => {
return data.value?.results.map((_, i: number) => {
return { type: "page", value: i };
});
});
+
+// methods
+
+const clearFilters = () => {
+ params.sort = undefined;
+ params.status = undefined;
+};
@@ -152,11 +165,27 @@ const paginationData = computed(() => {
-
- |