Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 117x 33x 33x 33x 33x 117x 717x 717x 33x 33x | import { customInstance } from "../index";
import { useQuery } from "react-query";
import { ROWS_PER_PAGE } from "@hooks/common/usePagination";
import { MERCHANT_FILE_TEXT } from "@constants/stringConstants";
import {
GENERAL_STALE_TIME_15,
MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS,
} from "@features/Merchants/MerchantSidePanel/constants";
interface Params {
id: number;
queryString?: string;
sorting?: string;
page?: number;
searchQuery?: string;
filter?: string;
enabled?: boolean;
}
export const getChangelog = ({
id,
queryString = "",
page,
sorting,
searchQuery,
filter,
}: Params) => {
const search = searchQuery ? `&q="${searchQuery}"` : "";
const filterQuery = filter
? "filter=" + encodeURIComponent(`;${filter}`)
: "filter=";
const pageQuery = page ? `&page=${page}` : "";
return customInstance({
url: `/merchants/${id}/changelogs?${filterQuery}${queryString}&sort=${
sorting || "-changelogMerchAccID"
}${search}${pageQuery}&max=${ROWS_PER_PAGE}`,
method: "GET",
});
};
export const useGetChangelog = (props: Params) => {
const {
id,
queryString,
searchQuery,
filter,
page,
sorting,
enabled = true,
} = props;
return useQuery(
[
MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET_CHANGELOG,
id,
queryString,
searchQuery,
filter,
page,
sorting,
],
async () => {
const data = await getChangelog({
id,
queryString,
searchQuery,
filter,
page,
sorting,
});
return data;
},
{
refetchOnWindowFocus: false,
refetchOnMount: false,
staleTime: GENERAL_STALE_TIME_15,
enabled: enabled,
},
);
};
export type OperationType = "insert" | "update" | "upload";
export type ChangelogData = {
userAccID: number;
userAccFullName: string;
email: string;
avatarImageURL: string;
changeDate: number;
resourceTypeDisplayName: GroupType;
fieldChanges: ChangeItem[];
changelogMerchAccID: number;
resourceName: string;
};
export type ChangeItem = {
operation: OperationType;
fieldName: string;
oldValue?: string | number;
newValue: string | number;
};
export type GroupType =
| typeof MERCHANT_FILE_TEXT
| "Business Profile"
| "Primary Account Holder"
| "Bank Account"
| "Business Owner"
| "Documents";
|