Fix/object record and metadata naming (#2763)
* Fixed object-record and object-metadata naming * Fix post merge --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { assertNotNull } from '~/utils/assert';
|
||||
|
||||
export const useFieldPreviewValue = ({
|
||||
@ -10,12 +10,12 @@ export const useFieldPreviewValue = ({
|
||||
objectNamePlural: string;
|
||||
skip?: boolean;
|
||||
}) => {
|
||||
const { objects } = useFindManyObjectRecords({
|
||||
const { records } = useFindManyRecords({
|
||||
objectNamePlural,
|
||||
skip,
|
||||
});
|
||||
|
||||
const firstRecordWithValue = objects.find(
|
||||
const firstRecordWithValue = records.find(
|
||||
(record) => assertNotNull(record[fieldName]) && record[fieldName] !== '',
|
||||
);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useObjectMetadataItemForSettings } from '@/object-metadata/hooks/useObjectMetadataItemForSettings';
|
||||
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
|
||||
export const useRelationFieldPreviewValue = ({
|
||||
relationObjectMetadataId,
|
||||
@ -14,7 +14,7 @@ export const useRelationFieldPreviewValue = ({
|
||||
? findObjectMetadataItemById(relationObjectMetadataId)
|
||||
: undefined;
|
||||
|
||||
const { objects: relationObjects } = useFindManyObjectRecords({
|
||||
const { records: relationObjects } = useFindManyRecords({
|
||||
objectNamePlural: relationObjectMetadataItem?.namePlural,
|
||||
skip: skip || !relationObjectMetadataItem,
|
||||
});
|
||||
|
||||
@ -3,7 +3,7 @@ import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { Tag } from '@/ui/display/tag/components/Tag';
|
||||
import { useLazyLoadIcon } from '@/ui/input/hooks/useLazyLoadIcon';
|
||||
import { TableCell } from '@/ui/layout/table/components/TableCell';
|
||||
@ -36,7 +36,7 @@ export const SettingsObjectItemTableRow = ({
|
||||
}: SettingsObjectItemTableRowProps) => {
|
||||
const theme = useTheme();
|
||||
|
||||
const { objects } = useFindManyObjectRecords({
|
||||
const { records } = useFindManyRecords({
|
||||
objectNamePlural: objectItem.namePlural,
|
||||
});
|
||||
|
||||
@ -58,7 +58,7 @@ export const SettingsObjectItemTableRow = ({
|
||||
<TableCell align="right">
|
||||
{objectItem.fields.filter((field) => !field.isSystem).length}
|
||||
</TableCell>
|
||||
<TableCell align="right">{objects.length}</TableCell>
|
||||
<TableCell align="right">{records.length}</TableCell>
|
||||
<StyledActionTableCell>{action}</StyledActionTableCell>
|
||||
</StyledObjectTableRow>
|
||||
);
|
||||
|
||||
@ -5,7 +5,7 @@ import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
|
||||
import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { useUpdateOneObjectRecord } from '@/object-record/hooks/useUpdateOneObjectRecord';
|
||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
import { TextInput } from '@/ui/input/components/TextInput';
|
||||
import { logError } from '~/utils/logError';
|
||||
|
||||
@ -40,10 +40,9 @@ export const NameFields = ({
|
||||
currentWorkspaceMember?.name?.lastName ?? '',
|
||||
);
|
||||
|
||||
const { updateOneObject, objectNotFoundInMetadata } =
|
||||
useUpdateOneObjectRecord({
|
||||
objectNameSingular: 'workspaceMember',
|
||||
});
|
||||
const { updateOneRecord, objectMetadataItemNotFound } = useUpdateOneRecord({
|
||||
objectNameSingular: 'workspaceMember',
|
||||
});
|
||||
|
||||
// TODO: Enhance this with react-web-hook-form (https://www.react-hook-form.com)
|
||||
const debouncedUpdate = debounce(async () => {
|
||||
@ -59,10 +58,10 @@ export const NameFields = ({
|
||||
}
|
||||
|
||||
if (autoSave) {
|
||||
if (!updateOneObject || objectNotFoundInMetadata) {
|
||||
if (!updateOneRecord || objectMetadataItemNotFound) {
|
||||
throw new Error('Object not found in metadata');
|
||||
}
|
||||
await updateOneObject({
|
||||
await updateOneRecord({
|
||||
idToUpdate: currentWorkspaceMember?.id,
|
||||
input: {
|
||||
name: {
|
||||
|
||||
@ -2,7 +2,7 @@ import { useState } from 'react';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { useUpdateOneObjectRecord } from '@/object-record/hooks/useUpdateOneObjectRecord';
|
||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
import { ImageInput } from '@/ui/input/components/ImageInput';
|
||||
import { getImageAbsoluteURIOrBase64 } from '@/users/utils/getProfilePictureAbsoluteURI';
|
||||
import { useUploadProfilePictureMutation } from '~/generated/graphql';
|
||||
@ -19,10 +19,9 @@ export const ProfilePictureUploader = () => {
|
||||
useState<AbortController | null>(null);
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
|
||||
const { updateOneObject, objectNotFoundInMetadata } =
|
||||
useUpdateOneObjectRecord({
|
||||
objectNameSingular: 'workspaceMember',
|
||||
});
|
||||
const { updateOneRecord, objectMetadataItemNotFound } = useUpdateOneRecord({
|
||||
objectNameSingular: 'workspaceMember',
|
||||
});
|
||||
|
||||
const handleUpload = async (file: File) => {
|
||||
if (!file) {
|
||||
@ -55,10 +54,10 @@ export const ProfilePictureUploader = () => {
|
||||
if (!avatarUrl) {
|
||||
throw new Error('Avatar URL not found');
|
||||
}
|
||||
if (!updateOneObject || objectNotFoundInMetadata) {
|
||||
if (!updateOneRecord || objectMetadataItemNotFound) {
|
||||
throw new Error('Object not found in metadata');
|
||||
}
|
||||
await updateOneObject({
|
||||
await updateOneRecord({
|
||||
idToUpdate: currentWorkspaceMember?.id,
|
||||
input: {
|
||||
avatarUrl,
|
||||
@ -81,13 +80,13 @@ export const ProfilePictureUploader = () => {
|
||||
};
|
||||
|
||||
const handleRemove = async () => {
|
||||
if (!updateOneObject || objectNotFoundInMetadata) {
|
||||
if (!updateOneRecord || objectMetadataItemNotFound) {
|
||||
throw new Error('Object not found in metadata');
|
||||
}
|
||||
if (!currentWorkspaceMember?.id) {
|
||||
throw new Error('User is not logged in');
|
||||
}
|
||||
await updateOneObject({
|
||||
await updateOneRecord({
|
||||
idToUpdate: currentWorkspaceMember?.id,
|
||||
input: {
|
||||
avatarUrl: null,
|
||||
|
||||
Reference in New Issue
Block a user