Use twentyORM in Timeline messaging (#6595)

- Remove raw queries and replace them by using `twentyORM`
- Refactor into services and utils

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Raphaël Bosi
2024-08-15 10:15:32 +02:00
committed by GitHub
parent 6927f46e1c
commit 08c7947b3b
19 changed files with 513 additions and 559 deletions

View File

@ -45,7 +45,7 @@ export const MessageThreadSubscribersChip = ({
? `+${numberOfMessageThreadSubscribers - MAX_NUMBER_OF_AVATARS}`
: null;
const label = isPrivateThread ? privateLabel : (moreAvatarsLabel ?? '');
const label = isPrivateThread ? privateLabel : moreAvatarsLabel ?? '';
return (
<Chip

View File

@ -4,7 +4,7 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
export const generateDefaultRecordChipData = (record: ObjectRecord) => {
const name = isFieldFullNameValue(record.name)
? record.name.firstName + ' ' + record.name.lastName
: (record.name ?? '');
: record.name ?? '';
return {
name,

View File

@ -42,8 +42,8 @@ export const MultiSelectFieldInput = ({
const [searchFilter, setSearchFilter] = useState('');
const containerRef = useRef<HTMLDivElement>(null);
const selectedOptions = fieldDefinition.metadata.options.filter((option) =>
fieldValues?.includes(option.value),
const selectedOptions = fieldDefinition.metadata.options.filter(
(option) => fieldValues?.includes(option.value),
);
const optionsInDropDown = fieldDefinition.metadata.options;

View File

@ -69,7 +69,7 @@ export const RecordDetailRelationSection = ({
const relationRecords: ObjectRecord[] =
fieldValue && isToOneObject
? [fieldValue as ObjectRecord]
: ((fieldValue as ObjectRecord[]) ?? []);
: (fieldValue as ObjectRecord[]) ?? [];
const relationRecordIds = relationRecords.map(({ id }) => id);

View File

@ -6,10 +6,11 @@ export const findUnmatchedRequiredFields = <T extends string>(
columns: Columns<T>,
) =>
fields
.filter((field) =>
field.fieldValidationDefinitions?.some(
(validation) => validation.rule === 'required',
),
.filter(
(field) =>
field.fieldValidationDefinitions?.some(
(validation) => validation.rule === 'required',
),
)
.filter(
(field) =>

View File

@ -16,7 +16,7 @@ type ContainerProps = {
const StyledContainer = styled.div<ContainerProps>`
align-items: center;
background-color: ${({ theme, isOn, color }) =>
isOn ? (color ?? theme.color.blue) : theme.background.quaternary};
isOn ? color ?? theme.color.blue : theme.background.quaternary};
border-radius: 10px;
cursor: pointer;
display: flex;