* Removed view field duplicate types * wip * wip 2 * wip 3 * Unified state for fields * Renaming * Wip * Post merge * Post post merge * wip * Delete unused file * Boolean and Probability * Finished InlineCell * Renamed EditableCell to TableCell * Finished double texts * Finished MoneyField * Fixed bug inline cell click outside * Fixed hotkey scope * Final fixes * Phone * Fix url and number input validation * Fix * Fix position * wip refactor activity editor * Fixed activity editor --------- Co-authored-by: Charles Bochet <charles@twenty.com>
28 lines
899 B
TypeScript
28 lines
899 B
TypeScript
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
|
import { ViewFieldForVisibility } from '@/ui/view-bar/types/ViewFieldForVisibility';
|
|
|
|
import { boardCardFieldsScopedState } from '../states/boardCardFieldsScopedState';
|
|
|
|
import { useBoardContext } from './useBoardContext';
|
|
|
|
export const useBoardCardFields = () => {
|
|
const { BoardRecoilScopeContext } = useBoardContext();
|
|
|
|
const [, setBoardCardFields] = useRecoilScopedState(
|
|
boardCardFieldsScopedState,
|
|
BoardRecoilScopeContext,
|
|
);
|
|
|
|
const handleFieldVisibilityChange = (field: ViewFieldForVisibility) => {
|
|
setBoardCardFields((previousFields) =>
|
|
previousFields.map((previousField) =>
|
|
previousField.key === field.key
|
|
? { ...previousField, isVisible: !field.isVisible }
|
|
: previousField,
|
|
),
|
|
);
|
|
};
|
|
|
|
return { handleFieldVisibilityChange };
|
|
};
|