feat: reconcile application vertical slices
Backfill the completed acquisitions, sales, dashboard, pricing, search, public detail, worker, migration, contracts, validation, tests, and implementation-status changes into one verified application slice.
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref, watch } from "vue";
|
||||
|
||||
import { searchCatalog } from '@/services/catalog-service.js';
|
||||
import { searchCatalog } from "@/services/catalog-service.js";
|
||||
|
||||
export function useCatalogSearch({ initialQuery = '', initialCategory = '', initialConditionId = '', initialMinPriceMinor, initialMaxPriceMinor, initialSort = 'recent', initialPage = 1 } = {}) {
|
||||
export function useCatalogSearch({
|
||||
initialQuery = "",
|
||||
initialCategory = "",
|
||||
initialConditionId = "",
|
||||
initialMinPriceMinor,
|
||||
initialMaxPriceMinor,
|
||||
initialSort = "recent",
|
||||
initialPage = 1,
|
||||
} = {}) {
|
||||
const query = ref(initialQuery);
|
||||
const category = ref(initialCategory);
|
||||
const conditionId = ref(initialConditionId);
|
||||
@@ -10,7 +18,10 @@ export function useCatalogSearch({ initialQuery = '', initialCategory = '', init
|
||||
const maxPriceMinor = ref(initialMaxPriceMinor);
|
||||
const sort = ref(initialSort);
|
||||
const page = ref(initialPage);
|
||||
const result = ref({ items: [], pagination: { page: 1, limit: 20, total: 0, totalPages: 0 } });
|
||||
const result = ref({
|
||||
items: [],
|
||||
pagination: { page: 1, limit: 20, total: 0, totalPages: 0 },
|
||||
});
|
||||
const isLoading = ref(false);
|
||||
const error = ref(null);
|
||||
let requestId = 0;
|
||||
@@ -21,7 +32,15 @@ export function useCatalogSearch({ initialQuery = '', initialCategory = '', init
|
||||
error.value = null;
|
||||
|
||||
try {
|
||||
const nextResult = await searchCatalog({ query: query.value, category: category.value, conditionId: conditionId.value, minPriceMinor: minPriceMinor.value, maxPriceMinor: maxPriceMinor.value, sort: sort.value, page: page.value });
|
||||
const nextResult = await searchCatalog({
|
||||
query: query.value,
|
||||
category: category.value,
|
||||
conditionId: conditionId.value,
|
||||
minPriceMinor: minPriceMinor.value,
|
||||
maxPriceMinor: maxPriceMinor.value,
|
||||
sort: sort.value,
|
||||
page: page.value,
|
||||
});
|
||||
if (currentRequestId === requestId) result.value = nextResult;
|
||||
} catch (requestError) {
|
||||
if (currentRequestId === requestId) error.value = requestError;
|
||||
@@ -30,10 +49,13 @@ export function useCatalogSearch({ initialQuery = '', initialCategory = '', init
|
||||
}
|
||||
}
|
||||
|
||||
watch([query, category, conditionId, minPriceMinor, maxPriceMinor, sort], () => {
|
||||
if (page.value !== 1) page.value = 1;
|
||||
else load();
|
||||
});
|
||||
watch(
|
||||
[query, category, conditionId, minPriceMinor, maxPriceMinor, sort],
|
||||
() => {
|
||||
if (page.value !== 1) page.value = 1;
|
||||
else load();
|
||||
},
|
||||
);
|
||||
watch(page, load);
|
||||
|
||||
function goToPage(nextPage) {
|
||||
@@ -42,5 +64,18 @@ export function useCatalogSearch({ initialQuery = '', initialCategory = '', init
|
||||
}
|
||||
}
|
||||
|
||||
return { query, category, conditionId, minPriceMinor, maxPriceMinor, sort, page, result, isLoading, error, load, goToPage };
|
||||
}
|
||||
return {
|
||||
query,
|
||||
category,
|
||||
conditionId,
|
||||
minPriceMinor,
|
||||
maxPriceMinor,
|
||||
sort,
|
||||
page,
|
||||
result,
|
||||
isLoading,
|
||||
error,
|
||||
load,
|
||||
goToPage,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user