All files / src/services/filtering filtering.constants.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

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 111 112544x 544x   544x                                   544x                                                                                                                                                                                    
export const AND_OPERATOR = ";";
export const OR_OPERATOR = ",";
 
export const resources = {
  products: new Set(["created"]),
  transactions: new Set([
    "created",
    "amount",
    "conversion",
    "purchases",
    "visitors",
    "entries sold",
    "status",
    "transactions",
    "blocked",
    "quarantine",
    "isPending",
  ]),
  customers: new Set(["joined", "recurrence"]),
};
 
export const filteringConst = {
  created: {
    key: "createdAt",
    "in the last": ">=d{$1}",
    "is between": `>=d{$1}${AND_OPERATOR}<=d{$2}`,
    "is on or before": "<=d{$1}",
    "is on or after": ">=d{$1}",
    operator: AND_OPERATOR,
  },
  amount: {
    key: "amount",
    "is between": ">{$1};<{$2}",
    "is equal to or greater than": ">{$1}",
    "is equal to or less than": "<{$1}",
    operator: AND_OPERATOR,
  },
  "entries sold": {
    key: "entries_sold", //TODO: check the name of the attribute in DB
    "is between": `>{$1}${AND_OPERATOR}<{$2}`,
    "is equal to or greater than": ">={$1}",
    "is equal to or less than": "<={$1}",
  },
  conversion: {
    key: "conversion",
    template: `>={$1}${AND_OPERATOR}<={$2}`,
    operator: AND_OPERATOR,
  },
  purchases: {
    key: "purchases",
    "is between": `>{$1}${AND_OPERATOR}<{$2}`,
    "is equal to or greater than": ">={$1}",
    "is equal to or less than": "<={$1}",
    operator: AND_OPERATOR,
  },
  visitors: {
    key: "visitors",
    "is between": `>{$1}${AND_OPERATOR}<{$2}`,
    "is equal to or greater than": ">={$1}",
    "is equal to or less than": "<={$1}",
    operator: AND_OPERATOR,
  },
  transactions: {
    key: "transactions",
    "is between": `>{$1}${AND_OPERATOR}<{$2}`,
    "is equal to or greater than": ">={$1}",
    "is equal to or less than": "<={$1}",
    operator: AND_OPERATOR,
  },
  type: {
    key: "typeID",
    default: [],
    operator: OR_OPERATOR,
  },
  status: {
    key: "statusID",
    default: [],
    operator: OR_OPERATOR,
  },
  recurrence: {
    key: "recurringCustomer",
    default: "{$1}",
    operator: AND_OPERATOR,
  },
  joined: {
    key: "createdAt",
    "in the last": ">=d{$1}",
    "is between": `>=d{$1}${AND_OPERATOR}<=d{$2}`,
    "is on or before": "<=d{$1}",
    "is on or after": ">=d{$1}",
    operator: AND_OPERATOR,
  },
  blocked: {
    key: "isBlocked",
    default: "{$1}",
    operator: AND_OPERATOR,
  },
  quarantine: {
    key: "isQuarantined",
    default: "{$1}",
    operator: AND_OPERATOR,
  },
  totalProcessed: {
    key: "totalProcessed",
    "is between": ">{$1};<{$2}",
    "greater than": ">{$1}",
    "is equal to or greater than": ">={$1}",
    "is equal to or less than": "<={$1}",
    operator: AND_OPERATOR,
  },
} as const;