feat(opendock): added in new article link setup for fine tuning how od works
This commit is contained in:
25
frontend/src/lib/queries/getActiveArticles.ts
Normal file
25
frontend/src/lib/queries/getActiveArticles.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { keepPreviousData, queryOptions } from "@tanstack/react-query";
|
||||
import { api } from "../apiHelper";
|
||||
|
||||
export function getActiveArticle() {
|
||||
return queryOptions({
|
||||
queryKey: ["getActiveArticle"],
|
||||
queryFn: () => dataFetch(),
|
||||
staleTime: 5000,
|
||||
refetchOnWindowFocus: true,
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
const dataFetch = async () => {
|
||||
if (window.location.hostname === "localhost") {
|
||||
await new Promise((res) => setTimeout(res, 1500));
|
||||
}
|
||||
|
||||
const { data } = await api.get("/datamart/activeArticles");
|
||||
if (!data.success) {
|
||||
throw new Error(data.message ?? "Failed to load articles");
|
||||
}
|
||||
|
||||
return data.data ?? [];
|
||||
};
|
||||
25
frontend/src/lib/queries/getArticleLinks.ts
Normal file
25
frontend/src/lib/queries/getArticleLinks.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { keepPreviousData, queryOptions } from "@tanstack/react-query";
|
||||
import { api } from "../apiHelper";
|
||||
|
||||
export function getArticleLinks() {
|
||||
return queryOptions({
|
||||
queryKey: ["getArticleLinks"],
|
||||
queryFn: () => dataFetch(),
|
||||
staleTime: 5000,
|
||||
refetchOnWindowFocus: true,
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
const dataFetch = async () => {
|
||||
if (window.location.hostname === "localhost") {
|
||||
await new Promise((res) => setTimeout(res, 1500));
|
||||
}
|
||||
|
||||
const { data } = await api.get("/opendock/articleCheck");
|
||||
if (!data.success) {
|
||||
throw new Error(data.message ?? "Failed to load article links");
|
||||
}
|
||||
|
||||
return data.data ?? [];
|
||||
};
|
||||
26
frontend/src/lib/queries/getCustomerByAv.ts
Normal file
26
frontend/src/lib/queries/getCustomerByAv.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
import { api } from "../apiHelper";
|
||||
|
||||
export function getCustomerByAv(av: string) {
|
||||
return queryOptions({
|
||||
queryKey: ["getCustomerByAv", av],
|
||||
queryFn: () => dataFetch(av),
|
||||
staleTime: 5000,
|
||||
enabled: !!av,
|
||||
refetchOnWindowFocus: true,
|
||||
//placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
const dataFetch = async (av: string) => {
|
||||
if (window.location.hostname === "localhost") {
|
||||
await new Promise((res) => setTimeout(res, 1500));
|
||||
}
|
||||
|
||||
const { data } = await api.get(`/opendock/articleCheck/customers/${av}`);
|
||||
if (!data.success) {
|
||||
throw new Error(data.message ?? "Failed to load customers");
|
||||
}
|
||||
|
||||
return data.data ?? [];
|
||||
};
|
||||
Reference in New Issue
Block a user