Pass object name plural in props + remove unused state (#3401)
* Pass object name plural in props + remove unused state * Fix test --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -5,18 +5,15 @@ import { renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useObjectRecordTable } from '@/object-record/hooks/useObjectRecordTable';
|
||||
import { useRecordTable } from '@/object-record/record-table/hooks/useRecordTable';
|
||||
import { RecordTableScope } from '@/object-record/record-table/scopes/RecordTableScope';
|
||||
import { SnackBarProviderScope } from '@/ui/feedback/snack-bar-manager/scopes/SnackBarProviderScope';
|
||||
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
|
||||
|
||||
const recordTableId = 'people';
|
||||
const objectNamePlural = 'people';
|
||||
const onColumnsChange = jest.fn();
|
||||
|
||||
const ObjectNamePluralSetter = ({ children }: { children: ReactNode }) => {
|
||||
const { setObjectNamePlural } = useRecordTable({ recordTableId });
|
||||
setObjectNamePlural('people');
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
@ -39,9 +36,12 @@ const Wrapper = ({ children }: { children: ReactNode }) => {
|
||||
|
||||
describe('useObjectRecordTable', () => {
|
||||
it('should skip fetch if currentWorkspace is undefined', async () => {
|
||||
const { result } = renderHook(() => useObjectRecordTable(), {
|
||||
wrapper: Wrapper,
|
||||
});
|
||||
const { result } = renderHook(
|
||||
() => useObjectRecordTable(objectNamePlural),
|
||||
{
|
||||
wrapper: Wrapper,
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.current.loading).toBe(false);
|
||||
expect(Array.isArray(result.current.records)).toBe(true);
|
||||
|
||||
@ -11,12 +11,9 @@ import { signInBackgroundMockCompanies } from '@/sign-in-background-mock/constan
|
||||
|
||||
import { useFindManyRecords } from './useFindManyRecords';
|
||||
|
||||
export const useObjectRecordTable = () => {
|
||||
const {
|
||||
objectNamePlural,
|
||||
setRecordTableData,
|
||||
setIsRecordTableInitialLoading,
|
||||
} = useRecordTable();
|
||||
export const useObjectRecordTable = (objectNamePlural: string) => {
|
||||
const { setRecordTableData, setIsRecordTableInitialLoading } =
|
||||
useRecordTable();
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||
|
||||
const { objectNameSingular } = useObjectNameSingularFromPlural({
|
||||
|
||||
Reference in New Issue
Block a user