@kadconsulting/dry
Version:
KAD Reusable Component Library
294 lines • 8.47 kB
JavaScript
const mockPosFiltersData = [
{
name: 'Locations',
label: 'Locations',
type: 'checkbox',
options: [
{
LabelContent: 'Location 1',
value: 'location1',
color: 'light-contrast',
},
{
LabelContent: 'Location 2',
value: 'location2',
color: 'light-contrast',
},
{
LabelContent: 'Location 3',
value: 'location3',
color: 'light-contrast',
},
{
LabelContent: 'Location 4',
value: 'location4',
color: 'light-contrast',
},
{
LabelContent: 'Location 5',
value: 'location5',
color: 'light-contrast',
},
],
},
{
name: 'Coaches',
label: 'Coaches',
type: 'checkbox',
options: [
{
LabelContent: 'Coach 1',
value: 'coach1',
color: 'light-contrast',
},
{
LabelContent: 'Coach 2',
value: 'coach2',
color: 'light-contrast',
},
{
LabelContent: 'Coach 3',
value: 'coach3',
color: 'light-contrast',
},
{
LabelContent: 'Coach 4',
value: 'coach4',
color: 'light-contrast',
},
{
LabelContent: 'Coach 5',
value: 'coach5',
color: 'light-contrast',
},
],
},
{
name: 'Categories',
label: 'Categories',
type: 'checkbox',
options: [
{
LabelContent: 'Category 1',
value: 'category1',
color: 'light-contrast',
},
{
LabelContent: 'Category 2',
value: 'category2',
color: 'light-contrast',
},
{
LabelContent: 'Category 3',
value: 'category3',
color: 'light-contrast',
},
{
LabelContent: 'Category 4',
value: 'category4',
color: 'light-contrast',
},
{
LabelContent: 'Category 5',
value: 'category5',
color: 'light-contrast',
},
],
},
{
name: 'Simbays',
label: 'Simbays',
type: 'radio',
options: [
{
LabelContent: 'Simbay 1',
value: 'simbay1',
color: 'light-contrast',
},
{
LabelContent: 'Simbay 2',
value: 'simbay2',
color: 'light-contrast',
},
{
LabelContent: 'Simbay 3',
value: 'simbay3',
color: 'light-contrast',
},
{
LabelContent: 'Simbay 4',
value: 'simbay4',
color: 'light-contrast',
},
{
LabelContent: 'Simbay 5',
value: 'simbay5',
color: 'light-contrast',
},
],
},
{
name: 'Services',
label: 'Services',
type: 'checkbox',
options: [
{
LabelContent: 'Service 1',
value: 'service1',
color: 'light-contrast',
},
{
LabelContent: 'Service 2',
value: 'service2',
color: 'light-contrast',
},
{
LabelContent: 'Service 3',
value: 'service3',
color: 'light-contrast',
},
{
LabelContent: 'Service 4',
value: 'service4',
color: 'light-contrast',
},
{
LabelContent: 'Service 5',
value: 'service5',
color: 'light-contrast',
},
],
},
{
name: 'Classgroup',
label: 'Classgroup',
type: 'checkbox',
options: [
{
LabelContent: 'Classgroup 1',
value: 'classgroup1',
color: 'light-contrast',
},
{
LabelContent: 'Classgroup 2',
value: 'classgroup2',
color: 'light-contrast',
},
{
LabelContent: 'Classgroup 3',
value: 'classgroup3',
color: 'light-contrast',
},
{
LabelContent: 'Classgroup 4',
value: 'classgroup4',
color: 'light-contrast',
},
{
LabelContent: 'Classgroup 5',
value: 'classgroup5',
color: 'light-contrast',
},
],
},
{
name: 'Events',
label: 'Events',
type: 'checkbox',
options: [
{
LabelContent: 'Event 1',
value: 'event1',
color: 'light-contrast',
},
{
LabelContent: 'Event 2',
value: 'event2',
color: 'light-contrast',
},
{
LabelContent: 'Event 3',
value: 'event3',
color: 'light-contrast',
},
{
LabelContent: 'Event 4',
value: 'event4',
color: 'light-contrast',
},
{
LabelContent: 'Event 5',
value: 'event5',
color: 'light-contrast',
},
],
},
];
export const defaultFilters = {
Locations: ['location1', 'location2'],
Coaches: ['coach1', 'coach2'],
Categories: ['category1'],
Simbays: ['simbay1'],
Services: ['service1', 'service2'],
Classgroup: ['classgroup1'],
Events: ['event1', 'event2'],
};
export const filterPresets = {
preset1: {
Locations: ['location1', 'location3'],
Coaches: ['coach2', 'coach3'],
Categories: ['category2', 'category3'],
Simbays: ['simbay2'],
Services: ['service3'],
Classgroup: ['classgroup2', 'classgroup3'],
Events: ['event3', 'event4'],
},
preset2: {
Locations: ['location2', 'location4'],
Coaches: ['coach1', 'coach4'],
Categories: ['category1', 'category4'],
Simbays: ['simbay3'],
Services: ['service2', 'service4'],
Classgroup: ['classgroup1', 'classgroup4'],
Events: ['event2', 'event5'],
},
};
export const createCustomOption = (category, option) => {
const categoryIndex = mockPosFiltersData.findIndex((cat) => cat.name === category);
if (categoryIndex !== -1) {
mockPosFiltersData[categoryIndex].options.push(option);
}
};
export const selectAllOptions = (category) => {
const categoryIndex = mockPosFiltersData.findIndex((cat) => cat.name === category);
if (categoryIndex !== -1) {
mockPosFiltersData[categoryIndex].options.forEach((option) => {
option.checked = true;
});
}
};
export const deselectAllOptions = (category) => {
const categoryIndex = mockPosFiltersData.findIndex((cat) => cat.name === category);
if (categoryIndex !== -1) {
mockPosFiltersData[categoryIndex].options.forEach((option) => {
option.checked = false;
});
}
};
export const resetFiltersToDefault = () => {
mockPosFiltersData.forEach((category) => {
category.options.forEach((option) => {
option.checked = defaultFilters[category.name]?.includes(option.value);
});
});
};
export const applyFilterPreset = (preset) => {
const selectedPreset = filterPresets[preset];
mockPosFiltersData.forEach((category) => {
category.options.forEach((option) => {
option.checked = selectedPreset[category.name]?.includes(option.value);
});
});
};
export default mockPosFiltersData;
//# sourceMappingURL=mockFiltersData.js.map