Refactor/context and scopes (#1602)
* Put onImport in a context * Refactored RecoilScopeContexts * Refactored naming * Fix tests --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
import { type Context, type ReactNode, useContext } from 'react';
|
||||
import { type ReactNode, useContext } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { BoardCardIdContext } from '@/ui/board/contexts/BoardCardIdContext';
|
||||
import { useBoardContext } from '@/ui/board/hooks/useBoardContext';
|
||||
import { useCurrentCardSelected } from '@/ui/board/hooks/useCurrentCardSelected';
|
||||
import { visibleBoardCardFieldsScopedSelector } from '@/ui/board/states/selectors/visibleBoardCardFieldsScopedSelector';
|
||||
import { EntityChipVariant } from '@/ui/chip/components/EntityChip';
|
||||
@ -19,10 +20,6 @@ import { companyProgressesFamilyState } from '../states/companyProgressesFamilyS
|
||||
|
||||
import { CompanyChip } from './CompanyChip';
|
||||
|
||||
type OwnProps = {
|
||||
scopeContext: Context<string | null>;
|
||||
};
|
||||
|
||||
const StyledBoardCard = styled.div<{ selected: boolean }>`
|
||||
background-color: ${({ theme, selected }) =>
|
||||
selected ? theme.accent.quaternary : theme.background.secondary};
|
||||
@ -103,7 +100,9 @@ const StyledFieldContainer = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
export function CompanyBoardCard({ scopeContext }: OwnProps) {
|
||||
export function CompanyBoardCard() {
|
||||
const { BoardRecoilScopeContext } = useBoardContext();
|
||||
|
||||
const { currentCardSelected, setCurrentCardSelected } =
|
||||
useCurrentCardSelected();
|
||||
const boardCardId = useContext(BoardCardIdContext);
|
||||
@ -115,7 +114,7 @@ export function CompanyBoardCard({ scopeContext }: OwnProps) {
|
||||
|
||||
const visibleBoardCardFields = useRecoilScopedValue(
|
||||
visibleBoardCardFieldsScopedSelector,
|
||||
scopeContext,
|
||||
BoardRecoilScopeContext,
|
||||
);
|
||||
|
||||
// boardCardId check can be moved to a wrapper to avoid unnecessary logic above
|
||||
|
||||
Reference in New Issue
Block a user