Skip to content

The open alternative to Salesforce, designed for AI.

Remove the remaining placeholders from the call recorder widgets (#28410)

nitin4bb75698158e
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallParticipantsWidget.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallParticipantsWidget.tsx
index 631c3b43d9c..fd6021a2845 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallParticipantsWidget.tsx
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallParticipantsWidget.tsx
@@ -11,7 +11,6 @@ import { themeCssVariables } from 'twenty-ui/theme-constants';
import { CallParticipantChip } from 'src/front-components/components/CallParticipantChip';
import { FrontComponentThemeProvider } from 'src/front-components/components/FrontComponentThemeProvider';
import { StyledWidgetContainer } from 'src/front-components/components/StyledWidgetContainer';
-import { WidgetEmptyState } from 'src/front-components/components/WidgetEmptyState';
import { useCallParticipants } from 'src/front-components/hooks/use-call-participants';
import { buildCallParticipantDisplayItems } from 'src/front-components/utils/build-call-participant-display-items.util';
import { isShowUnmatchedAttendeesEnabled } from 'src/front-components/utils/is-show-unmatched-attendees-enabled.util';
@@ -29,43 +28,27 @@ type CallParticipantListProps = {
const CallParticipantList = ({ callRecordingId }: CallParticipantListProps) => {
const callParticipantsState = useCallParticipants(callRecordingId);
- switch (callParticipantsState.status) {
- case 'loading':
- return null;
- case 'error':
- return (
- <WidgetEmptyState
- title="Could Not Load Participants"
- description="Something went wrong while loading this call's participants."
- />
- );
- case 'notLinkedToMeeting':
- return (
- <WidgetEmptyState
- title="No Meeting"
- description="This recording is not linked to a calendar event."
- />
- );
- case 'loaded': {
- const { items } = buildCallParticipantDisplayItems({
- participants: callParticipantsState.participants,
- areRelationsLoaded: callParticipantsState.areRelationsLoaded,
- showUnmatchedAttendees: isShowUnmatchedAttendeesEnabled(),
- });
+ if (callParticipantsState.status !== 'loaded') {
+ return null;
+ }
- if (items.length === 0) {
- return null;
- }
+ const { items } = buildCallParticipantDisplayItems({
+ participants: callParticipantsState.participants,
+ areRelationsLoaded: callParticipantsState.areRelationsLoaded,
+ showUnmatchedAttendees: isShowUnmatchedAttendeesEnabled(),
+ });
- return (
- <StyledChipList>
- {items.map((item) => (
- <CallParticipantChip key={item.key} participant={item} />
- ))}
- </StyledChipList>
- );
- }
+ if (items.length === 0) {
+ return null;
}
+
+ return (
+ <StyledChipList>
+ {items.map((item) => (
+ <CallParticipantChip key={item.key} participant={item} />
+ ))}
+ </StyledChipList>
+ );
};
export const CallParticipantsWidget = () => {
@@ -76,17 +59,11 @@ export const CallParticipantsWidget = () => {
selectedRecordIds.length === 1 ? selectedRecordIds[0] : undefined;
const renderContent = () => {
- if (selectedObjectMetadata?.nameSingular !== 'callRecording') {
- return (
- <WidgetEmptyState
- title="Not Available Here"
- description="Add this widget to a call recording page."
- />
- );
- }
-
- if (isUndefined(callRecordingId)) {
- return <WidgetEmptyState title="No Call Recording Selected" />;
+ if (
+ selectedObjectMetadata?.nameSingular !== 'callRecording' ||
+ isUndefined(callRecordingId)
+ ) {
+ return null;
}
return <CallParticipantList callRecordingId={callRecordingId} />;
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingsWidget.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingsWidget.tsx
index ccdbe4796fc..10315529311 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingsWidget.tsx
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/components/CallRecordingsWidget.tsx
@@ -11,7 +11,6 @@ import { CallRecordingRow } from 'src/front-components/components/CallRecordingR
import { CallRecordingRowSkeleton } from 'src/front-components/components/CallRecordingRowSkeleton';
import { FrontComponentThemeProvider } from 'src/front-components/components/FrontComponentThemeProvider';
import { StyledCallRecordingCard } from 'src/front-components/components/StyledCallRecordingCard';
-import { WidgetEmptyState } from 'src/front-components/components/WidgetEmptyState';
import { useCallRecordingsForRecord } from 'src/front-components/hooks/use-call-recordings-for-record';
import { type CalendarEventTargetFieldName } from 'src/front-components/types/calendar-event-target-field-name.type';
import { getCallRecordingDisplayDate } from 'src/front-components/utils/get-call-recording-display-date.util';
@@ -51,12 +50,7 @@ const CallRecordingList = ({
</StyledCallRecordingCard>
);
case 'error':
- return (
- <WidgetEmptyState
- title="Could Not Load Recordings"
- description="Something went wrong while loading call recordings."
- />
- );
+ return null;
case 'loaded':
if (callRecordingsState.callRecordings.length === 0) {
return null;
@@ -101,17 +95,8 @@ export const CallRecordingsWidget = () => {
);
const renderContent = () => {
- if (isUndefined(calendarEventTargetFieldName)) {
- return (
- <WidgetEmptyState
- title="Not Available Here"
- description="Add this widget to a person, company or opportunity page."
- />
- );
- }
-
- if (isUndefined(recordId)) {
- return <WidgetEmptyState title="No Record Selected" />;
+ if (isUndefined(calendarEventTargetFieldName) || isUndefined(recordId)) {
+ return null;
}
return (
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/components/WidgetEmptyState.tsx b/packages/twenty-apps/public/call-recorder/src/front-components/components/WidgetEmptyState.tsx
deleted file mode 100644
index ef58e0bb0d9..00000000000
--- a/packages/twenty-apps/public/call-recorder/src/front-components/components/WidgetEmptyState.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import styled from '@emotion/styled';
-import { isUndefined } from '@sniptt/guards';
-import { themeCssVariables } from 'twenty-ui/theme-constants';
-
-const StyledRoot = styled.div`
- align-items: center;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- font-family: ${() => themeCssVariables.font.family};
- gap: ${() => themeCssVariables.spacing[2]};
- justify-content: center;
- padding: ${() => themeCssVariables.spacing[6]}
- ${() => themeCssVariables.spacing[4]};
- text-align: center;
- width: 100%;
-`;
-
-const StyledTitle = styled.div`
- color: ${() => themeCssVariables.font.color.primary};
- font-size: ${() => themeCssVariables.font.size.lg};
- font-weight: ${() => themeCssVariables.font.weight.semiBold};
-`;
-
-const StyledDescription = styled.div`
- color: ${() => themeCssVariables.font.color.tertiary};
- font-size: ${() => themeCssVariables.font.size.sm};
- line-height: ${() => themeCssVariables.text.lineHeight.lg};
-`;
-
-type WidgetEmptyStateProps = {
- title: string;
- description?: string;
-};
-
-export const WidgetEmptyState = ({
- title,
- description,
-}: WidgetEmptyStateProps) => (
- <StyledRoot>
- <StyledTitle>{title}</StyledTitle>
- {!isUndefined(description) && (
- <StyledDescription>{description}</StyledDescription>
- )}
- </StyledRoot>
-);
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-participants.ts b/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-participants.ts
index 1e7c353f869..4148eb40b48 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-participants.ts
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-participants.ts
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import { CoreApiClient } from 'twenty-client-sdk/core';
+import { enqueueSnackbar, useTranslate } from 'twenty-sdk/front-component';
import { type CallParticipantNode } from 'src/front-components/types/call-participant-node.type';
import { fetchCallParticipants } from 'src/front-components/utils/fetch-call-participants.util';
@@ -7,7 +8,6 @@ import { fetchCallParticipants } from 'src/front-components/utils/fetch-call-par
type CallParticipantsState =
| { status: 'loading' }
| { status: 'error' }
- | { status: 'notLinkedToMeeting' }
| {
status: 'loaded';
participants: CallParticipantNode[];
@@ -17,6 +17,7 @@ type CallParticipantsState =
export const useCallParticipants = (
callRecordingId: string,
): CallParticipantsState => {
+ const { t } = useTranslate();
const [state, setState] = useState<CallParticipantsState>({
status: 'loading',
});
@@ -24,6 +25,14 @@ export const useCallParticipants = (
useEffect(() => {
let isCancelled = false;
+ const failLoading = () => {
+ setState({ status: 'error' });
+ enqueueSnackbar({
+ message: t('Could not load call participants.'),
+ variant: 'error',
+ });
+ };
+
setState({ status: 'loading' });
fetchCallParticipants({ client: new CoreApiClient(), callRecordingId })
@@ -41,23 +50,27 @@ export const useCallParticipants = (
});
return;
case 'notLinkedToMeeting':
- setState({ status: 'notLinkedToMeeting' });
+ setState({
+ status: 'loaded',
+ participants: [],
+ areRelationsLoaded: true,
+ });
return;
case 'callRecordingNotFound':
- setState({ status: 'error' });
+ failLoading();
return;
}
})
.catch(() => {
if (!isCancelled) {
- setState({ status: 'error' });
+ failLoading();
}
});
return () => {
isCancelled = true;
};
- }, [callRecordingId]);
+ }, [callRecordingId, t]);
return state;
};
diff --git a/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-recordings-for-record.ts b/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-recordings-for-record.ts
index f98355ffce3..cbadc2d4540 100644
--- a/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-recordings-for-record.ts
+++ b/packages/twenty-apps/public/call-recorder/src/front-components/hooks/use-call-recordings-for-record.ts
@@ -1,6 +1,7 @@
import { isUndefined } from '@sniptt/guards';
import { useEffect, useState } from 'react';
import { CoreApiClient } from 'twenty-client-sdk/core';
+import { enqueueSnackbar, useTranslate } from 'twenty-sdk/front-component';
import { CALL_RECORDINGS_WIDGET_MAX_COUNT } from 'src/front-components/constants/call-recordings-widget-max-count.constant';
import { CALL_RECORDINGS_WIDGET_REFRESH_INTERVAL_MILLISECONDS } from 'src/front-components/constants/call-recordings-widget-refresh-interval-milliseconds.constant';
@@ -21,6 +22,7 @@ export const useCallRecordingsForRecord = ({
calendarEventTargetFieldName: CalendarEventTargetFieldName;
recordId: string;
}): CallRecordingsForRecordState => {
+ const { t } = useTranslate();
const [state, setState] = useState<CallRecordingsForRecordState>({
status: 'loading',
});
@@ -65,6 +67,10 @@ export const useCallRecordingsForRecord = ({
scheduleRefresh();
} else {
setState({ status: 'error' });
+ enqueueSnackbar({
+ message: t('Could not load call recordings.'),
+ variant: 'error',
+ });
}
});
};
@@ -79,7 +85,7 @@ export const useCallRecordingsForRecord = ({
clearTimeout(refreshTimeout);
}
};
- }, [calendarEventTargetFieldName, recordId]);
+ }, [calendarEventTargetFieldName, recordId, t]);
return state;
};