@ -5,6 +5,7 @@ import {
|
||||
} from '@/ui/board/components/EntityBoard';
|
||||
import { EntityBoardActionBar } from '@/ui/board/components/EntityBoardActionBar';
|
||||
import { EntityBoardContextMenu } from '@/ui/board/components/EntityBoardContextMenu';
|
||||
import { ViewBarContext } from '@/ui/view-bar/contexts/ViewBarContext';
|
||||
import { useBoardViews } from '@/views/hooks/useBoardViews';
|
||||
import { opportunitiesBoardOptions } from '~/pages/opportunities/opportunitiesBoardOptions';
|
||||
|
||||
@ -16,25 +17,38 @@ type CompanyBoardProps = Pick<
|
||||
'onColumnAdd' | 'onColumnDelete' | 'onEditColumnTitle'
|
||||
>;
|
||||
|
||||
export const CompanyBoard = ({ ...props }: CompanyBoardProps) => {
|
||||
const { handleViewsChange, handleViewSubmit } = useBoardViews({
|
||||
objectId: 'company',
|
||||
scopeContext: CompanyBoardRecoilScopeContext,
|
||||
fieldDefinitions: pipelineAvailableFieldDefinitions,
|
||||
});
|
||||
export const CompanyBoard = ({
|
||||
onColumnAdd,
|
||||
onColumnDelete,
|
||||
onEditColumnTitle,
|
||||
}: CompanyBoardProps) => {
|
||||
const { createView, deleteView, submitCurrentView, updateView } =
|
||||
useBoardViews({
|
||||
objectId: 'company',
|
||||
scopeContext: CompanyBoardRecoilScopeContext,
|
||||
fieldDefinitions: pipelineAvailableFieldDefinitions,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<HooksCompanyBoard />
|
||||
<EntityBoard
|
||||
boardOptions={opportunitiesBoardOptions}
|
||||
defaultViewName="All opportunities"
|
||||
onViewsChange={handleViewsChange}
|
||||
onViewSubmit={handleViewSubmit}
|
||||
onColumnAdd={props.onColumnAdd}
|
||||
scopeContext={CompanyBoardRecoilScopeContext}
|
||||
onEditColumnTitle={props.onEditColumnTitle}
|
||||
/>
|
||||
<ViewBarContext.Provider
|
||||
value={{
|
||||
defaultViewName: 'All Opportunities',
|
||||
onCurrentViewSubmit: submitCurrentView,
|
||||
onViewCreate: createView,
|
||||
onViewEdit: updateView,
|
||||
onViewRemove: deleteView,
|
||||
}}
|
||||
>
|
||||
<EntityBoard
|
||||
boardOptions={opportunitiesBoardOptions}
|
||||
onColumnAdd={onColumnAdd}
|
||||
onColumnDelete={onColumnDelete}
|
||||
onEditColumnTitle={onEditColumnTitle}
|
||||
scopeContext={CompanyBoardRecoilScopeContext}
|
||||
/>
|
||||
</ViewBarContext.Provider>
|
||||
<EntityBoardActionBar />
|
||||
<EntityBoardContextMenu />
|
||||
</>
|
||||
|
||||
@ -8,6 +8,7 @@ import { EntityTableEffect } from '@/ui/table/components/EntityTableEffect';
|
||||
import { useUpsertEntityTableItem } from '@/ui/table/hooks/useUpsertEntityTableItem';
|
||||
import { TableRecoilScopeContext } from '@/ui/table/states/recoil-scope-contexts/TableRecoilScopeContext';
|
||||
import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
|
||||
import { ViewBarContext } from '@/ui/view-bar/contexts/ViewBarContext';
|
||||
import { filtersWhereScopedSelector } from '@/ui/view-bar/states/selectors/filtersWhereScopedSelector';
|
||||
import { sortsOrderByScopedSelector } from '@/ui/view-bar/states/selectors/sortsOrderByScopedSelector';
|
||||
import { useTableViews } from '@/views/hooks/useTableViews';
|
||||
@ -32,10 +33,11 @@ export function CompanyTable() {
|
||||
const [updateEntityMutation] = useUpdateOneCompanyMutation();
|
||||
const upsertEntityTableItem = useUpsertEntityTableItem();
|
||||
|
||||
const { handleViewsChange, handleViewSubmit } = useTableViews({
|
||||
objectId: 'company',
|
||||
columnDefinitions: companiesAvailableColumnDefinitions,
|
||||
});
|
||||
const { createView, deleteView, submitCurrentView, updateView } =
|
||||
useTableViews({
|
||||
objectId: 'company',
|
||||
columnDefinitions: companiesAvailableColumnDefinitions,
|
||||
});
|
||||
|
||||
const { openCompanySpreadsheetImport } = useSpreadsheetCompanyImport();
|
||||
|
||||
@ -61,27 +63,34 @@ export function CompanyTable() {
|
||||
setContextMenuEntries={setContextMenuEntries}
|
||||
setActionBarEntries={setActionBarEntries}
|
||||
/>
|
||||
<EntityTable
|
||||
defaultViewName="All Companies"
|
||||
onViewsChange={handleViewsChange}
|
||||
onViewSubmit={handleViewSubmit}
|
||||
onImport={handleImport}
|
||||
updateEntityMutation={({
|
||||
variables,
|
||||
}: {
|
||||
variables: UpdateOneCompanyMutationVariables;
|
||||
}) =>
|
||||
updateEntityMutation({
|
||||
<ViewBarContext.Provider
|
||||
value={{
|
||||
defaultViewName: 'All Companies',
|
||||
onCurrentViewSubmit: submitCurrentView,
|
||||
onViewCreate: createView,
|
||||
onViewEdit: updateView,
|
||||
onViewRemove: deleteView,
|
||||
}}
|
||||
>
|
||||
<EntityTable
|
||||
onImport={handleImport}
|
||||
updateEntityMutation={({
|
||||
variables,
|
||||
onCompleted: (data) => {
|
||||
if (!data.updateOneCompany) {
|
||||
return;
|
||||
}
|
||||
upsertEntityTableItem(data.updateOneCompany);
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
}: {
|
||||
variables: UpdateOneCompanyMutationVariables;
|
||||
}) =>
|
||||
updateEntityMutation({
|
||||
variables,
|
||||
onCompleted: (data) => {
|
||||
if (!data.updateOneCompany) {
|
||||
return;
|
||||
}
|
||||
upsertEntityTableItem(data.updateOneCompany);
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</ViewBarContext.Provider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { EntityTable } from '@/ui/table/components/EntityTable';
|
||||
import { ViewBarContext } from '@/ui/view-bar/contexts/ViewBarContext';
|
||||
import { useUpdateOneCompanyMutation } from '~/generated/graphql';
|
||||
|
||||
import { CompanyTableMockData } from './CompanyTableMockData';
|
||||
@ -7,10 +8,9 @@ export function CompanyTableMockMode() {
|
||||
return (
|
||||
<>
|
||||
<CompanyTableMockData />
|
||||
<EntityTable
|
||||
defaultViewName="All Companies"
|
||||
updateEntityMutation={[useUpdateOneCompanyMutation()]}
|
||||
/>
|
||||
<ViewBarContext.Provider value={{ defaultViewName: 'All Companies' }}>
|
||||
<EntityTable updateEntityMutation={[useUpdateOneCompanyMutation()]} />
|
||||
</ViewBarContext.Provider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user