Enable filtering by creation date with datepicker (#131)
Enable to filter by date with datepicker
This commit is contained in:
@ -1,11 +1,18 @@
|
||||
import { Company } from '../../interfaces/entities/company.interface';
|
||||
import { FaLink, FaBuilding, FaMapPin, FaUsers } from 'react-icons/fa';
|
||||
import {
|
||||
FaLink,
|
||||
FaBuilding,
|
||||
FaMapPin,
|
||||
FaUsers,
|
||||
FaCalendar,
|
||||
} from 'react-icons/fa';
|
||||
import { FilterConfigType } from '../../interfaces/filters/interface';
|
||||
|
||||
export const nameFilter = {
|
||||
key: 'company_name',
|
||||
label: 'Company',
|
||||
icon: <FaBuilding />,
|
||||
type: 'text',
|
||||
operands: [
|
||||
{
|
||||
label: 'Contains',
|
||||
@ -28,6 +35,7 @@ export const urlFilter = {
|
||||
key: 'company_domain_name',
|
||||
label: 'Url',
|
||||
icon: <FaLink />,
|
||||
type: 'text',
|
||||
operands: [
|
||||
{
|
||||
label: 'Contains',
|
||||
@ -50,6 +58,7 @@ export const addressFilter = {
|
||||
key: 'company_address',
|
||||
label: 'Address',
|
||||
icon: <FaMapPin />,
|
||||
type: 'text',
|
||||
operands: [
|
||||
{
|
||||
label: 'Contains',
|
||||
@ -72,6 +81,7 @@ export const employeesFilter = {
|
||||
key: 'company_employees',
|
||||
label: 'Employees',
|
||||
icon: <FaUsers />,
|
||||
type: 'text',
|
||||
operands: [
|
||||
{
|
||||
label: 'Greater than',
|
||||
@ -94,9 +104,37 @@ export const employeesFilter = {
|
||||
],
|
||||
} satisfies FilterConfigType<Company, string>;
|
||||
|
||||
export const creationDateFilter = {
|
||||
key: 'company_created_at',
|
||||
label: 'Created At',
|
||||
icon: <FaCalendar />,
|
||||
type: 'date',
|
||||
operands: [
|
||||
{
|
||||
label: 'Greater than',
|
||||
id: 'greater_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
created_at: {
|
||||
_gte: searchString,
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Less than',
|
||||
id: 'less_than',
|
||||
whereTemplate: (searchString) => ({
|
||||
created_at: {
|
||||
_lte: searchString,
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
} satisfies FilterConfigType<Company, string>;
|
||||
|
||||
export const availableFilters = [
|
||||
nameFilter,
|
||||
urlFilter,
|
||||
addressFilter,
|
||||
employeesFilter,
|
||||
creationDateFilter,
|
||||
];
|
||||
|
||||
@ -11,6 +11,7 @@ export const fullnameFilter = {
|
||||
key: 'fullname',
|
||||
label: 'People',
|
||||
icon: <FaUser />,
|
||||
type: 'text',
|
||||
operands: [
|
||||
{
|
||||
label: 'Contains',
|
||||
@ -41,6 +42,7 @@ export const companyFilter = {
|
||||
key: 'company_name',
|
||||
label: 'Company',
|
||||
icon: <FaBuilding />,
|
||||
type: 'relation',
|
||||
searchConfig: {
|
||||
query: SEARCH_COMPANY_QUERY,
|
||||
template: (searchString: string) => ({
|
||||
@ -74,6 +76,7 @@ export const emailFilter = {
|
||||
key: 'email',
|
||||
label: 'Email',
|
||||
icon: <FaEnvelope />,
|
||||
type: 'text',
|
||||
operands: [
|
||||
{
|
||||
label: 'Contains',
|
||||
@ -96,6 +99,7 @@ export const cityFilter = {
|
||||
key: 'city',
|
||||
label: 'City',
|
||||
icon: <FaMapPin />,
|
||||
type: 'text',
|
||||
operands: [
|
||||
{
|
||||
label: 'Contains',
|
||||
|
||||
Reference in New Issue
Block a user