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 | 66x 3x 3x 3x 3x 3x 3x 3x 3x 2x 2x 2x 1x 1x 3x | import { SERVER_URL } from '@config/base'; import { BaseApiResponse, DynamicFilterResponseProps, InternalServerErrorResp } from '@props/RecordProps'; import { requestUrlAndGetPromise } from '@utils/FetchUtils'; interface Organization { id: number; } interface Owner { id: string | null; } export interface SaveFilterProps { id?: number; label: string; isDefault: boolean; conditions: string; } export interface CreateFilterProps extends SaveFilterProps { name: string; label: string; isSystem: boolean; organization: Organization; owner: Owner; enableRoles: string; } export interface UpdateFilterProps extends SaveFilterProps { id: number; label: string; isDefault: boolean; } export const saveFilter = async (saveFilterProps: { value: SaveFilterProps; domainName: string; successCallback: () => void; failCallback: (error: unknown) => void; finallyCallback: () => void; }): Promise<void> => { const { value, domainName, failCallback, successCallback, finallyCallback } = saveFilterProps; const mode = (value.id === undefined) ? "create" : "edit"; const isCreate = (mode === "create"); const baseUrl = `${SERVER_URL}/filter`; const url = isCreate ? `${baseUrl}/${domainName}` : `${baseUrl}/${value.id}`; const method = isCreate ? "POST" : "PUT"; try { const response: BaseApiResponse<DynamicFilterResponseProps> = await requestUrlAndGetPromise(url, { method, body: JSON.stringify(value), }); Iif (!response.success) { throw new Error(response.message); } console.log('Filter saved successfully:', response.data); successCallback(); } catch (error: unknown) { console.error('Error while saving filter:', error); failCallback(error as InternalServerErrorResp); } finally { finallyCallback(); } }; |