@pagamio/frontend-commons-lib 0.8.194 → 0.8.195

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Grid } from '@mantine/core';
3
3
  import { Card } from 'flowbite-react';
4
- import { useCallback, useEffect, useState } from 'react';
4
+ import { useCallback, useEffect, useMemo, useState } from 'react';
5
5
  import { useApi } from '../api';
6
6
  import { FilterComponent, Tab } from '../components';
7
7
  import { useMediaQueries } from '../shared';
@@ -32,10 +32,19 @@ const renderFilterComponent = ({ isLoading, error, filters, filterOptions, selec
32
32
  if (error) {
33
33
  return (_jsx(Card, { className: "mb-5", children: _jsx(ErrorState, { error: error, onRetry: handleRetry }) }));
34
34
  }
35
+ const resolveFilterType = (filter) => {
36
+ if (filter.type === 'date')
37
+ return 'date';
38
+ if (filter.type === 'multi-select')
39
+ return 'multi-select';
40
+ if (filter.type === 'select')
41
+ return 'select';
42
+ return filter.multi ? 'multi-select' : 'select';
43
+ };
35
44
  return (_jsx(FilterComponent, { filters: filters.map((filter) => ({
36
45
  name: filter.name,
37
46
  placeholder: filter.placeholder ?? `Select ${filter.name}`,
38
- type: filter.multi ? 'multi-select' : 'select',
47
+ type: resolveFilterType(filter),
39
48
  options: filterOptions[filter.name] || filter.options,
40
49
  })), showClearFilters: true, selectedFilters: selectedFilters, handleFilterChange: handleFilterChange, handleApplyFilters: handleApplyFilters, resetFilters: resetFilters, isNarrow: isNarrow }));
41
50
  };
@@ -114,11 +123,33 @@ const DashboardWrapper = ({ data, showVisualHeader = true, showEventsTabbedLayou
114
123
  isNarrow: isSm,
115
124
  });
116
125
  };
126
+ const dashboardFilters = useMemo(() => {
127
+ const baseFilters = [...config.filters];
128
+ const dateRangeValue = typeof selectedFilters?.dateRange === 'string' ? selectedFilters.dateRange.toUpperCase() : '';
129
+ if (dateRangeValue === 'CUSTOM_RANGE') {
130
+ baseFilters.push({
131
+ name: 'startDate',
132
+ label: 'Start Date',
133
+ placeholder: 'Select start date',
134
+ type: 'date',
135
+ options: [],
136
+ multi: false,
137
+ }, {
138
+ name: 'endDate',
139
+ label: 'End Date',
140
+ placeholder: 'Select end date',
141
+ type: 'date',
142
+ options: [],
143
+ multi: false,
144
+ });
145
+ }
146
+ return baseFilters;
147
+ }, [config.filters, selectedFilters?.dateRange]);
117
148
  const renderContent = () => {
118
149
  return renderFilterComponent({
119
150
  isLoading: loading,
120
151
  error,
121
- filters: config.filters,
152
+ filters: dashboardFilters,
122
153
  filterOptions,
123
154
  selectedFilters,
124
155
  handleFilterChange,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagamio/frontend-commons-lib",
3
3
  "description": "Pagamio library for Frontend reusable components like the form engine and table container",
4
- "version": "0.8.194",
4
+ "version": "0.8.195",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": false