09533e286b
* WIP * wip * update pipelineStepId * rename pipeline stage to pipeline step * rename pipelineProgress to Opportunity * fix UUID type not queried * fix boardColumnTotal * fix micros * fixing filters, sorts and fields * wip * wip * Fix opportunity board re-render --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com> Co-authored-by: bosiraphael <raphael.bosi@gmail.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { useObjectMainIdentifier } from '@/object-metadata/hooks/useObjectMainIdentifier';
|
|
import { useObjectMetadataItemForSettings } from '@/object-metadata/hooks/useObjectMetadataItemForSettings';
|
|
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
|
|
|
export const useRelationFieldPreview = ({
|
|
relationObjectMetadataId,
|
|
skipDefaultValue,
|
|
}: {
|
|
relationObjectMetadataId?: string;
|
|
skipDefaultValue: boolean;
|
|
}) => {
|
|
const { findObjectMetadataItemById } = useObjectMetadataItemForSettings();
|
|
|
|
const relationObjectMetadataItem = relationObjectMetadataId
|
|
? findObjectMetadataItemById(relationObjectMetadataId)
|
|
: undefined;
|
|
|
|
const { objects: relationObjects } = useFindManyObjectRecords({
|
|
objectNamePlural: relationObjectMetadataItem?.namePlural,
|
|
skip: skipDefaultValue || !relationObjectMetadataItem,
|
|
});
|
|
|
|
const {
|
|
labelIdentifierFieldPaths,
|
|
imageIdentifierUrlField,
|
|
imageIdentifierUrlPrefix,
|
|
imageIdentifierFormat,
|
|
} = useObjectMainIdentifier(relationObjectMetadataItem);
|
|
|
|
return {
|
|
defaultValue: relationObjects?.[0],
|
|
labelIdentifierFieldPaths,
|
|
imageIdentifierUrlField,
|
|
imageIdentifierUrlPrefix,
|
|
imageIdentifierFormat,
|
|
};
|
|
};
|