improve: add production stage
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import {useQuery, useMutation, useQueryClient} from 'react-query';
|
||||
import {fetch_} from "./request-utils";
|
||||
import config from "../config";
|
||||
import {useConfig} from "../ConfigProvider";
|
||||
|
||||
|
||||
|
||||
export const useMarkdown = (id) => {
|
||||
const config = useConfig();
|
||||
return useQuery(
|
||||
["markdown", id],
|
||||
() => fetch_(`${config.BACKEND_HOST}/api/markdown/${id}`),
|
||||
@@ -13,6 +16,7 @@ export const useMarkdown = (id) => {
|
||||
|
||||
export const useIndexMarkdown = (path_id) => {
|
||||
const queryClient = useQueryClient();
|
||||
const config = useConfig();
|
||||
return useQuery(
|
||||
["index_markdown", path_id],
|
||||
() => fetch_(`${config.BACKEND_HOST}/api/markdown/get_index/${path_id}`),{
|
||||
@@ -26,6 +30,7 @@ export const useIndexMarkdown = (path_id) => {
|
||||
};
|
||||
|
||||
export const useMarkdownsByPath = (pathId) => {
|
||||
const config = useConfig();
|
||||
return useQuery(
|
||||
["markdownsByPath", pathId],
|
||||
() => fetch_(`${config.BACKEND_HOST}/api/markdown/by_path/${pathId}`),
|
||||
@@ -36,6 +41,7 @@ export const useMarkdownsByPath = (pathId) => {
|
||||
|
||||
export const useSaveMarkdown = () => {
|
||||
const queryClient = useQueryClient();
|
||||
const config = useConfig();
|
||||
return useMutation(({id, data}) => {
|
||||
const url = id
|
||||
? `${config.BACKEND_HOST}/api/markdown/${id}`
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { useQuery, useMutation, useQueryClient } from "react-query";
|
||||
import { fetch_ } from "./request-utils";
|
||||
import config from "../config";
|
||||
import {useConfig} from "../ConfigProvider";
|
||||
|
||||
|
||||
export const usePaths = (parent_id) => {
|
||||
const queryClient = useQueryClient();
|
||||
const config = useConfig();
|
||||
return useQuery(
|
||||
["paths", parent_id],
|
||||
() => fetch_(`${config.BACKEND_HOST}/api/path/parent/${parent_id}`),
|
||||
@@ -24,6 +25,7 @@ export const usePaths = (parent_id) => {
|
||||
|
||||
|
||||
export const usePath = (id) => {
|
||||
const config = useConfig();
|
||||
const queryClient = useQueryClient();
|
||||
const cachedData = queryClient.getQueryData(["path", id]);
|
||||
|
||||
@@ -41,6 +43,7 @@ export const usePath = (id) => {
|
||||
};
|
||||
|
||||
export const useCreatePath = () => {
|
||||
const config = useConfig();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(
|
||||
@@ -58,6 +61,7 @@ export const useCreatePath = () => {
|
||||
};
|
||||
|
||||
export const useUpdatePath = () => {
|
||||
const config = useConfig();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(
|
||||
@@ -75,6 +79,7 @@ export const useUpdatePath = () => {
|
||||
};
|
||||
|
||||
export const useDeletePath = () => {
|
||||
const config = useConfig();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(
|
||||
|
||||
Reference in New Issue
Block a user