Change to using arrow functions (#1603)
* Change to using arrow functions Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Add lint rule --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -4,14 +4,14 @@ import { IconPlus } from '@/ui/icon';
|
||||
|
||||
import { FilterDropdownId } from '../constants/FilterDropdownId';
|
||||
|
||||
export function AddFilterFromDropdownButton() {
|
||||
export const AddFilterFromDropdownButton = () => {
|
||||
const { toggleDropdownButton } = useDropdownButton({
|
||||
dropdownId: FilterDropdownId,
|
||||
});
|
||||
|
||||
function handleClick() {
|
||||
const handleClick = () => {
|
||||
toggleDropdownButton();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<LightButton
|
||||
@ -21,4 +21,4 @@ export function AddFilterFromDropdownButton() {
|
||||
accent="tertiary"
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -11,9 +11,9 @@ type FilterDropdownButtonProps = {
|
||||
hotkeyScope: HotkeyScope;
|
||||
};
|
||||
|
||||
export function FilterDropdownButton({
|
||||
export const FilterDropdownButton = ({
|
||||
hotkeyScope,
|
||||
}: FilterDropdownButtonProps) {
|
||||
}: FilterDropdownButtonProps) => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [availableFilters] = useRecoilScopedState(
|
||||
@ -33,4 +33,4 @@ export function FilterDropdownButton({
|
||||
) : (
|
||||
<MultipleFiltersDropdownButton hotkeyScope={hotkeyScope} />
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -7,7 +7,7 @@ import { selectedOperandInDropdownScopedState } from '@/ui/view-bar/states/selec
|
||||
import { useViewBarContext } from '../hooks/useViewBarContext';
|
||||
import { isFilterDropdownUnfoldedScopedState } from '../states/isFilterDropdownUnfoldedScopedState';
|
||||
|
||||
export function FilterDropdownDateSearchInput() {
|
||||
export const FilterDropdownDateSearchInput = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filterDefinitionUsedInDropdown] = useRecoilScopedState(
|
||||
@ -27,7 +27,7 @@ export function FilterDropdownDateSearchInput() {
|
||||
|
||||
const upsertFilter = useUpsertFilter();
|
||||
|
||||
function handleChange(date: Date) {
|
||||
const handleChange = (date: Date) => {
|
||||
if (!filterDefinitionUsedInDropdown || !selectedOperandInDropdown) return;
|
||||
|
||||
upsertFilter({
|
||||
@ -39,7 +39,7 @@ export function FilterDropdownDateSearchInput() {
|
||||
});
|
||||
|
||||
setIsFilterDropdownUnfolded(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<DatePicker
|
||||
@ -48,4 +48,4 @@ export function FilterDropdownDateSearchInput() {
|
||||
onMouseSelect={handleChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -8,7 +8,7 @@ import { selectedOperandInDropdownScopedState } from '@/ui/view-bar/states/selec
|
||||
|
||||
import { useViewBarContext } from '../hooks/useViewBarContext';
|
||||
|
||||
export function FilterDropdownEntitySearchInput() {
|
||||
export const FilterDropdownEntitySearchInput = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filterDefinitionUsedInDropdown] = useRecoilScopedState(
|
||||
@ -40,4 +40,4 @@ export function FilterDropdownEntitySearchInput() {
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -13,11 +13,11 @@ import { selectedOperandInDropdownScopedState } from '@/ui/view-bar/states/selec
|
||||
|
||||
import { useViewBarContext } from '../hooks/useViewBarContext';
|
||||
|
||||
export function FilterDropdownEntitySearchSelect({
|
||||
export const FilterDropdownEntitySearchSelect = ({
|
||||
entitiesForSelect,
|
||||
}: {
|
||||
entitiesForSelect: EntitiesForMultipleEntitySelect<EntityForSelect>;
|
||||
}) {
|
||||
}) => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filterDropdownSelectedEntityId, setFilterDropdownSelectedEntityId] =
|
||||
@ -41,9 +41,9 @@ export function FilterDropdownEntitySearchSelect({
|
||||
|
||||
const filterCurrentlyEdited = useFilterCurrentlyEdited();
|
||||
|
||||
function handleUserSelected(
|
||||
const handleUserSelected = (
|
||||
selectedEntity: EntityForSelect | null | undefined,
|
||||
) {
|
||||
) => {
|
||||
if (
|
||||
!filterDefinitionUsedInDropdown ||
|
||||
!selectedOperandInDropdown ||
|
||||
@ -70,7 +70,7 @@ export function FilterDropdownEntitySearchSelect({
|
||||
displayAvatarUrl: selectedEntity.avatarUrl,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!filterCurrentlyEdited) {
|
||||
@ -88,4 +88,4 @@ export function FilterDropdownEntitySearchSelect({
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@ import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoi
|
||||
import { useViewBarContext } from '../hooks/useViewBarContext';
|
||||
import { filterDefinitionUsedInDropdownScopedState } from '../states/filterDefinitionUsedInDropdownScopedState';
|
||||
|
||||
export function FilterDropdownEntitySelect() {
|
||||
export const FilterDropdownEntitySelect = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filterDefinitionUsedInDropdown] = useRecoilScopedState(
|
||||
@ -25,4 +25,4 @@ export function FilterDropdownEntitySelect() {
|
||||
</RecoilScope>
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -12,7 +12,7 @@ import { filterDropdownSearchInputScopedState } from '../states/filterDropdownSe
|
||||
import { selectedOperandInDropdownScopedState } from '../states/selectedOperandInDropdownScopedState';
|
||||
import { getOperandsForFilterType } from '../utils/getOperandsForFilterType';
|
||||
|
||||
export function FilterDropdownFilterSelect() {
|
||||
export const FilterDropdownFilterSelect = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [, setFilterDefinitionUsedInDropdown] = useRecoilScopedState(
|
||||
@ -62,4 +62,4 @@ export function FilterDropdownFilterSelect() {
|
||||
))}
|
||||
</StyledDropdownMenuItemsContainer>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ import { useViewBarContext } from '../hooks/useViewBarContext';
|
||||
import { filterDefinitionUsedInDropdownScopedState } from '../states/filterDefinitionUsedInDropdownScopedState';
|
||||
import { selectedOperandInDropdownScopedState } from '../states/selectedOperandInDropdownScopedState';
|
||||
|
||||
export function FilterDropdownNumberSearchInput() {
|
||||
export const FilterDropdownNumberSearchInput = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filterDefinitionUsedInDropdown] = useRecoilScopedState(
|
||||
@ -47,4 +47,4 @@ export function FilterDropdownNumberSearchInput() {
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -7,7 +7,7 @@ import { isFilterDropdownOperandSelectUnfoldedScopedState } from '../states/isFi
|
||||
import { selectedOperandInDropdownScopedState } from '../states/selectedOperandInDropdownScopedState';
|
||||
import { getOperandLabel } from '../utils/getOperandLabel';
|
||||
|
||||
export function FilterDropdownOperandButton() {
|
||||
export const FilterDropdownOperandButton = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [selectedOperandInDropdown] = useRecoilScopedState(
|
||||
@ -36,4 +36,4 @@ export function FilterDropdownOperandButton() {
|
||||
{getOperandLabel(selectedOperandInDropdown)}
|
||||
</DropdownMenuHeader>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -12,7 +12,7 @@ import { FilterOperand } from '../types/FilterOperand';
|
||||
import { getOperandLabel } from '../utils/getOperandLabel';
|
||||
import { getOperandsForFilterType } from '../utils/getOperandsForFilterType';
|
||||
|
||||
export function FilterDropdownOperandSelect() {
|
||||
export const FilterDropdownOperandSelect = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filterDefinitionUsedInDropdown] = useRecoilScopedState(
|
||||
@ -41,7 +41,7 @@ export function FilterDropdownOperandSelect() {
|
||||
|
||||
const upsertFilter = useUpsertFilter();
|
||||
|
||||
function handleOperangeChange(newOperand: FilterOperand) {
|
||||
const handleOperangeChange = (newOperand: FilterOperand) => {
|
||||
setSelectedOperandInDropdown(newOperand);
|
||||
setIsFilterDropdownOperandSelectUnfolded(false);
|
||||
|
||||
@ -54,7 +54,7 @@ export function FilterDropdownOperandSelect() {
|
||||
value: filterCurrentlyEdited.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!isFilterDropdownOperandSelectUnfolded) {
|
||||
return <></>;
|
||||
@ -73,4 +73,4 @@ export function FilterDropdownOperandSelect() {
|
||||
))}
|
||||
</StyledDropdownMenuItemsContainer>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -11,7 +11,7 @@ import { filterDefinitionUsedInDropdownScopedState } from '../states/filterDefin
|
||||
import { filterDropdownSearchInputScopedState } from '../states/filterDropdownSearchInputScopedState';
|
||||
import { selectedOperandInDropdownScopedState } from '../states/selectedOperandInDropdownScopedState';
|
||||
|
||||
export function FilterDropdownTextSearchInput() {
|
||||
export const FilterDropdownTextSearchInput = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filterDefinitionUsedInDropdown] = useRecoilScopedState(
|
||||
@ -60,4 +60,4 @@ export function FilterDropdownTextSearchInput() {
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -6,13 +6,11 @@ type OwnProps = {
|
||||
filter: Filter;
|
||||
};
|
||||
|
||||
export function GenericEntityFilterChip({ filter }: OwnProps) {
|
||||
return (
|
||||
<EntityChip
|
||||
entityId={filter.value}
|
||||
name={filter.displayValue}
|
||||
avatarType="rounded"
|
||||
pictureUrl={filter.displayAvatarUrl}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export const GenericEntityFilterChip = ({ filter }: OwnProps) => (
|
||||
<EntityChip
|
||||
entityId={filter.value}
|
||||
name={filter.displayValue}
|
||||
avatarType="rounded"
|
||||
pictureUrl={filter.displayAvatarUrl}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -9,7 +9,7 @@ import { filterDropdownSearchInputScopedState } from '../states/filterDropdownSe
|
||||
import { isFilterDropdownOperandSelectUnfoldedScopedState } from '../states/isFilterDropdownOperandSelectUnfoldedScopedState';
|
||||
import { selectedOperandInDropdownScopedState } from '../states/selectedOperandInDropdownScopedState';
|
||||
|
||||
export function MultipleFiltersButton() {
|
||||
export const MultipleFiltersButton = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const { isDropdownButtonOpen, toggleDropdownButton } = useDropdownButton({
|
||||
@ -43,10 +43,10 @@ export function MultipleFiltersButton() {
|
||||
setFilterDropdownSearchInput('');
|
||||
};
|
||||
|
||||
function handleClick() {
|
||||
const handleClick = () => {
|
||||
toggleDropdownButton();
|
||||
resetState();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledHeaderDropdownButton
|
||||
@ -56,4 +56,4 @@ export function MultipleFiltersButton() {
|
||||
Filter
|
||||
</StyledHeaderDropdownButton>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -10,9 +10,9 @@ type MultipleFiltersDropdownButtonProps = {
|
||||
hotkeyScope: HotkeyScope;
|
||||
};
|
||||
|
||||
export function MultipleFiltersDropdownButton({
|
||||
export const MultipleFiltersDropdownButton = ({
|
||||
hotkeyScope,
|
||||
}: MultipleFiltersDropdownButtonProps) {
|
||||
}: MultipleFiltersDropdownButtonProps) => {
|
||||
return (
|
||||
<DropdownButton
|
||||
dropdownId={FilterDropdownId}
|
||||
@ -21,4 +21,4 @@ export function MultipleFiltersDropdownButton({
|
||||
dropdownHotkeyScope={hotkeyScope}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -16,7 +16,7 @@ import { FilterDropdownOperandButton } from './FilterDropdownOperandButton';
|
||||
import { FilterDropdownOperandSelect } from './FilterDropdownOperandSelect';
|
||||
import { FilterDropdownTextSearchInput } from './FilterDropdownTextSearchInput';
|
||||
|
||||
export function MultipleFiltersDropdownContent() {
|
||||
export const MultipleFiltersDropdownContent = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [isFilterDropdownOperandSelectUnfolded] = useRecoilScopedState(
|
||||
@ -67,4 +67,4 @@ export function MultipleFiltersDropdownContent() {
|
||||
</>
|
||||
</StyledDropdownMenu>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -29,11 +29,11 @@ const StyledDropdownButtonContainer = styled.div`
|
||||
position: relative;
|
||||
`;
|
||||
|
||||
export function SingleEntityFilterDropdownButton({
|
||||
export const SingleEntityFilterDropdownButton = ({
|
||||
hotkeyScope,
|
||||
}: {
|
||||
hotkeyScope: HotkeyScope;
|
||||
}) {
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
@ -82,7 +82,7 @@ export function SingleEntityFilterDropdownButton({
|
||||
|
||||
const setHotkeyScope = useSetHotkeyScope();
|
||||
|
||||
function handleIsUnfoldedChange(newIsUnfolded: boolean) {
|
||||
const handleIsUnfoldedChange = (newIsUnfolded: boolean) => {
|
||||
if (newIsUnfolded) {
|
||||
setHotkeyScope(hotkeyScope.scope, hotkeyScope.customScopes);
|
||||
setIsFilterDropdownUnfolded(true);
|
||||
@ -91,7 +91,7 @@ export function SingleEntityFilterDropdownButton({
|
||||
setIsFilterDropdownUnfolded(false);
|
||||
setFilterDropdownSearchInput('');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledDropdownButtonContainer>
|
||||
@ -114,4 +114,4 @@ export function SingleEntityFilterDropdownButton({
|
||||
)}
|
||||
</StyledDropdownButtonContainer>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -25,7 +25,9 @@ export type SortDropdownButtonProps = {
|
||||
isPrimaryButton?: boolean;
|
||||
};
|
||||
|
||||
export function SortDropdownButton({ hotkeyScope }: SortDropdownButtonProps) {
|
||||
export const SortDropdownButton = ({
|
||||
hotkeyScope,
|
||||
}: SortDropdownButtonProps) => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [isSortDirectionMenuUnfolded, setIsSortDirectionMenuUnfolded] =
|
||||
@ -55,12 +57,12 @@ export function SortDropdownButton({ hotkeyScope }: SortDropdownButtonProps) {
|
||||
dropdownId: SortDropdownId,
|
||||
});
|
||||
|
||||
function handleButtonClick() {
|
||||
const handleButtonClick = () => {
|
||||
toggleDropdownButton();
|
||||
resetState();
|
||||
}
|
||||
};
|
||||
|
||||
function handleAddSort(selectedSortDefinition: SortDefinition) {
|
||||
const handleAddSort = (selectedSortDefinition: SortDefinition) => {
|
||||
toggleDropdownButton();
|
||||
|
||||
setSorts(
|
||||
@ -81,7 +83,7 @@ export function SortDropdownButton({ hotkeyScope }: SortDropdownButtonProps) {
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<DropdownButton
|
||||
@ -135,4 +137,4 @@ export function SortDropdownButton({ hotkeyScope }: SortDropdownButtonProps) {
|
||||
}
|
||||
></DropdownButton>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -54,14 +54,14 @@ const StyledLabelKey = styled.div`
|
||||
font-weight: ${({ theme }) => theme.font.weight.medium};
|
||||
`;
|
||||
|
||||
function SortOrFilterChip({
|
||||
const SortOrFilterChip = ({
|
||||
labelKey,
|
||||
labelValue,
|
||||
Icon,
|
||||
onRemove,
|
||||
isSort,
|
||||
testId,
|
||||
}: OwnProps) {
|
||||
}: OwnProps) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<StyledChip isSort={isSort}>
|
||||
@ -77,6 +77,6 @@ function SortOrFilterChip({
|
||||
</StyledDelete>
|
||||
</StyledChip>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default SortOrFilterChip;
|
||||
|
||||
@ -96,10 +96,10 @@ const StyledAddFilterContainer = styled.div`
|
||||
z-index: 5;
|
||||
`;
|
||||
|
||||
export function ViewBarDetails({
|
||||
export const ViewBarDetails = ({
|
||||
hasFilterButton = false,
|
||||
rightComponent,
|
||||
}: ViewBarDetailsProps) {
|
||||
}: ViewBarDetailsProps) => {
|
||||
const { canPersistViewFields, onViewBarReset, ViewBarRecoilScopeContext } =
|
||||
useContext(ViewBarContext);
|
||||
|
||||
@ -165,11 +165,11 @@ export function ViewBarDetails({
|
||||
|
||||
const removeFilter = useRemoveFilter();
|
||||
|
||||
function handleCancelClick() {
|
||||
const handleCancelClick = () => {
|
||||
onViewBarReset?.();
|
||||
setFilters(savedFilters);
|
||||
setSorts(savedSorts);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSortRemove = (sortKey: string) =>
|
||||
setSorts((previousSorts) =>
|
||||
@ -243,4 +243,4 @@ export function ViewBarDetails({
|
||||
{rightComponent}
|
||||
</StyledBar>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -13,27 +13,29 @@ type OwnProps<Field> = {
|
||||
title: string;
|
||||
};
|
||||
|
||||
export function ViewFieldsVisibilityDropdownSection<
|
||||
export const ViewFieldsVisibilityDropdownSection = <
|
||||
Field extends ViewFieldDefinition<ViewFieldMetadata>,
|
||||
>({ fields, onVisibilityChange, title }: OwnProps<Field>) {
|
||||
return (
|
||||
<>
|
||||
<StyledDropdownMenuSubheader>{title}</StyledDropdownMenuSubheader>
|
||||
<StyledDropdownMenuItemsContainer>
|
||||
{fields.map((field) => (
|
||||
<MenuItem
|
||||
key={field.key}
|
||||
LeftIcon={field.Icon}
|
||||
iconButtons={[
|
||||
{
|
||||
Icon: field.isVisible ? IconMinus : IconPlus,
|
||||
onClick: () => onVisibilityChange(field),
|
||||
},
|
||||
]}
|
||||
text={field.name}
|
||||
/>
|
||||
))}
|
||||
</StyledDropdownMenuItemsContainer>
|
||||
</>
|
||||
);
|
||||
}
|
||||
>({
|
||||
fields,
|
||||
onVisibilityChange,
|
||||
title,
|
||||
}: OwnProps<Field>) => (
|
||||
<>
|
||||
<StyledDropdownMenuSubheader>{title}</StyledDropdownMenuSubheader>
|
||||
<StyledDropdownMenuItemsContainer>
|
||||
{fields.map((field) => (
|
||||
<MenuItem
|
||||
key={field.key}
|
||||
LeftIcon={field.Icon}
|
||||
iconButtons={[
|
||||
{
|
||||
Icon: field.isVisible ? IconMinus : IconPlus,
|
||||
onClick: () => onVisibilityChange(field),
|
||||
},
|
||||
]}
|
||||
text={field.name}
|
||||
/>
|
||||
))}
|
||||
</StyledDropdownMenuItemsContainer>
|
||||
</>
|
||||
);
|
||||
|
||||
@ -7,7 +7,7 @@ import { filtersScopedState } from '../states/filtersScopedState';
|
||||
|
||||
import { useViewBarContext } from './useViewBarContext';
|
||||
|
||||
export function useFilterCurrentlyEdited() {
|
||||
export const useFilterCurrentlyEdited = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [filters] = useRecoilScopedState(
|
||||
@ -25,4 +25,4 @@ export function useFilterCurrentlyEdited() {
|
||||
(filter) => filter.key === filterDefinitionUsedInDropdown?.key,
|
||||
);
|
||||
}, [filterDefinitionUsedInDropdown, filters]);
|
||||
}
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@ import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoi
|
||||
import { ViewBarContext } from '../contexts/ViewBarContext';
|
||||
import { filtersScopedState } from '../states/filtersScopedState';
|
||||
|
||||
export function useRemoveFilter() {
|
||||
export const useRemoveFilter = () => {
|
||||
const { ViewBarRecoilScopeContext } = useContext(ViewBarContext);
|
||||
|
||||
const [, setFilters] = useRecoilScopedState(
|
||||
@ -13,11 +13,13 @@ export function useRemoveFilter() {
|
||||
ViewBarRecoilScopeContext,
|
||||
);
|
||||
|
||||
return function removeFilter(filterKey: string) {
|
||||
const removeFilter = (filterKey: string) => {
|
||||
setFilters((filters) => {
|
||||
return filters.filter((filter) => {
|
||||
return filter.key !== filterKey;
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return removeFilter;
|
||||
};
|
||||
|
||||
@ -7,7 +7,7 @@ import { Filter } from '../types/Filter';
|
||||
|
||||
import { useViewBarContext } from './useViewBarContext';
|
||||
|
||||
export function useUpsertFilter() {
|
||||
export const useUpsertFilter = () => {
|
||||
const { ViewBarRecoilScopeContext } = useViewBarContext();
|
||||
|
||||
const [, setFilters] = useRecoilScopedState(
|
||||
@ -15,7 +15,7 @@ export function useUpsertFilter() {
|
||||
ViewBarRecoilScopeContext,
|
||||
);
|
||||
|
||||
return function upsertFilter(filterToUpsert: Filter) {
|
||||
const upsertFilter = (filterToUpsert: Filter) => {
|
||||
setFilters((filters) => {
|
||||
return produce(filters, (filtersDraft) => {
|
||||
const index = filtersDraft.findIndex(
|
||||
@ -30,4 +30,6 @@ export function useUpsertFilter() {
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return upsertFilter;
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { FilterOperand } from '../types/FilterOperand';
|
||||
|
||||
export function getOperandLabel(operand: FilterOperand | null | undefined) {
|
||||
export const getOperandLabel = (operand: FilterOperand | null | undefined) => {
|
||||
switch (operand) {
|
||||
case FilterOperand.Contains:
|
||||
return 'Contains';
|
||||
@ -17,10 +17,11 @@ export function getOperandLabel(operand: FilterOperand | null | undefined) {
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
export function getOperandLabelShort(
|
||||
};
|
||||
|
||||
export const getOperandLabelShort = (
|
||||
operand: FilterOperand | null | undefined,
|
||||
) {
|
||||
) => {
|
||||
switch (operand) {
|
||||
case FilterOperand.Is:
|
||||
case FilterOperand.Contains:
|
||||
@ -35,4 +36,4 @@ export function getOperandLabelShort(
|
||||
default:
|
||||
return ': ';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { FilterOperand } from '../types/FilterOperand';
|
||||
import { FilterType } from '../types/FilterType';
|
||||
|
||||
export function getOperandsForFilterType(
|
||||
export const getOperandsForFilterType = (
|
||||
filterType: FilterType | null | undefined,
|
||||
): FilterOperand[] {
|
||||
): FilterOperand[] => {
|
||||
switch (filterType) {
|
||||
case 'text':
|
||||
return [FilterOperand.Contains, FilterOperand.DoesNotContain];
|
||||
@ -15,4 +15,4 @@ export function getOperandsForFilterType(
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@ import { QueryMode } from '~/generated/graphql';
|
||||
import { Filter } from '../types/Filter';
|
||||
import { FilterOperand } from '../types/FilterOperand';
|
||||
|
||||
export function turnFilterIntoWhereClause(filter: Filter) {
|
||||
export const turnFilterIntoWhereClause = (filter: Filter) => {
|
||||
switch (filter.type) {
|
||||
case 'text':
|
||||
switch (filter.operand) {
|
||||
@ -88,4 +88,4 @@ export function turnFilterIntoWhereClause(filter: Filter) {
|
||||
default:
|
||||
throw new Error('Unknown filter type');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user