feat: create default views on workspace creation + add views seed (#1313)

Closes #1311
This commit is contained in:
Thaïs
2023-08-25 21:17:28 +02:00
committed by GitHub
parent 8a3a176571
commit 209e8b64d9
11 changed files with 356 additions and 16 deletions

View File

@ -2,6 +2,7 @@ import { useCallback } from 'react';
import { TableRecoilScopeContext } from '@/ui/table/states/recoil-scope-contexts/TableRecoilScopeContext';
import {
currentTableViewIdState,
type TableView,
tableViewsByIdState,
tableViewsState,
@ -24,6 +25,10 @@ export const useViews = ({
objectId: 'company' | 'person';
onViewCreate: (viewId: string) => Promise<void>;
}) => {
const [currentViewId, setCurrentViewId] = useRecoilScopedState(
currentTableViewIdState,
TableRecoilScopeContext,
);
const [views, setViews] = useRecoilScopedState(
tableViewsState,
TableRecoilScopeContext,
@ -102,6 +107,8 @@ export const useViews = ({
}));
if (!isDeeplyEqual(views, nextViews)) setViews(nextViews);
if (nextViews.length && !currentViewId) setCurrentViewId(nextViews[0].id);
},
});