diff --git a/ee/client/omnichannel/cannedResponses/CannedResponseEdit.tsx b/ee/client/omnichannel/cannedResponses/CannedResponseEdit.tsx
index 4e8fcefde95..f6e21bf135e 100644
--- a/ee/client/omnichannel/cannedResponses/CannedResponseEdit.tsx
+++ b/ee/client/omnichannel/cannedResponses/CannedResponseEdit.tsx
@@ -16,9 +16,10 @@ import CannedResponseForm from './components/cannedResponseForm';
const CannedResponseEdit: FC<{
data?: CannedResponseEndpointGetReturn;
reload: () => void;
+ totalDataReload: () => void;
isNew?: boolean;
departmentData?: LivechatDepartmentSingleGetReturn;
-}> = ({ data, reload, isNew = false, departmentData = {} }) => {
+}> = ({ data, reload, totalDataReload, isNew = false, departmentData = {} }) => {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();
const Route = useRoute('omnichannel-canned-responses');
@@ -116,10 +117,11 @@ const CannedResponseEdit: FC<{
context: '',
});
reload();
+ totalDataReload();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
- }, [values, saveCannedResponse, dispatchToastMessage, t, Route, reload]);
+ }, [values, saveCannedResponse, dispatchToastMessage, t, Route, reload, totalDataReload]);
const onPreview = (): void => {
setPreview(!preview);
diff --git a/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx b/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx
index 50462f5c056..74805c94164 100644
--- a/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx
+++ b/ee/client/omnichannel/cannedResponses/CannedResponseEditWithData.tsx
@@ -11,7 +11,8 @@ import CannedResponseEditWithDepartmentData from './CannedResponseEditWithDepart
const CannedResponseEditWithData: FC<{
cannedResponseId: string;
reload: () => void;
-}> = ({ cannedResponseId, reload }) => {
+ totalDataReload: () => void;
+}> = ({ cannedResponseId, reload, totalDataReload }) => {
const {
value: data,
phase: state,
@@ -33,10 +34,16 @@ const CannedResponseEditWithData: FC<{
}
if (data?.cannedResponse?.scope === 'department') {
- return ;
+ return (
+
+ );
}
- return ;
+ return ;
};
export default CannedResponseEditWithData;
diff --git a/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx b/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx
index 1fb9daa7aaf..9ac4e2b20fc 100644
--- a/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx
+++ b/ee/client/omnichannel/cannedResponses/CannedResponseEditWithDepartmentData.tsx
@@ -11,7 +11,8 @@ import CannedResponseEdit from './CannedResponseEdit';
const CannedResponseEditWithData: FC<{
data: CannedResponseEndpointGetReturn | undefined;
reload: () => void;
-}> = ({ data, reload }) => {
+ totalDataReload: () => void;
+}> = ({ data, reload, totalDataReload }) => {
const departmentId = useMemo(() => data?.cannedResponse?.departmentId, [data]) as string;
const {
value: departmentData,
@@ -33,7 +34,14 @@ const CannedResponseEditWithData: FC<{
);
}
- return ;
+ return (
+
+ );
};
export default CannedResponseEditWithData;
diff --git a/ee/client/omnichannel/cannedResponses/CannedResponseNew.tsx b/ee/client/omnichannel/cannedResponses/CannedResponseNew.tsx
index bee08724d0f..57ef83d7426 100644
--- a/ee/client/omnichannel/cannedResponses/CannedResponseNew.tsx
+++ b/ee/client/omnichannel/cannedResponses/CannedResponseNew.tsx
@@ -2,8 +2,11 @@ import React, { FC } from 'react';
import CannedResponseEdit from './CannedResponseEdit';
-const CannedResponseNew: FC<{ reload: () => void }> = ({ reload }) => (
-
+const CannedResponseNew: FC<{
+ reload: () => void;
+ totalDataReload: () => void;
+}> = ({ reload, totalDataReload }) => (
+
);
export default CannedResponseNew;
diff --git a/ee/client/omnichannel/cannedResponses/CannedResponsesPage.tsx b/ee/client/omnichannel/cannedResponses/CannedResponsesPage.tsx
index fac93cb9aab..bffe03b0de9 100644
--- a/ee/client/omnichannel/cannedResponses/CannedResponsesPage.tsx
+++ b/ee/client/omnichannel/cannedResponses/CannedResponsesPage.tsx
@@ -16,6 +16,7 @@ export type CannedResponsesPageProps = {
title: string;
renderRow: ReactNode | null;
renderFilter: FC;
+ totalCannedResponses: number;
};
const CannedResponsesPage: FC = ({
@@ -26,6 +27,7 @@ const CannedResponsesPage: FC = ({
title,
renderRow,
renderFilter,
+ totalCannedResponses,
}) => {
const t = useTranslation();
@@ -47,7 +49,7 @@ const CannedResponsesPage: FC = ({
- {data && data.total < 1 ? (
+ {totalCannedResponses < 1 ? (
{
);
const { value: data, reload } = useEndpointData('canned-responses', query);
+ const {
+ value: totalData,
+ phase: totalDataPhase,
+ reload: totalDataReload,
+ } = useEndpointData('canned-responses');
const getTime = useFormatDateAndTime();
@@ -166,24 +173,34 @@ const CannedResponsesRoute: FC = () => {
{getTime(createdAt)}
{tags.join(', ')}
-
+
),
- [getTime, onRowClick, reload],
+ [getTime, onRowClick, reload, totalDataReload],
);
if (context === 'edit' && id) {
- return ;
+ return (
+
+ );
}
if (context === 'new') {
- return ;
+ return ;
}
if (!canViewCannedResponses) {
return ;
}
+ if (totalDataPhase === AsyncStatePhase.LOADING) {
+ return ;
+ }
+
return (
{
header={header}
renderRow={renderRow}
title={t('Canned_Responses')}
+ totalCannedResponses={totalData?.total || 0}
>
);
};
diff --git a/ee/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx b/ee/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx
index f128845cd8b..9dd40091f01 100644
--- a/ee/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx
+++ b/ee/client/omnichannel/cannedResponses/RemoveCannedResponseButton.tsx
@@ -12,9 +12,14 @@ import { useTranslation } from '../../../../client/contexts/TranslationContext';
export type RemoveCannedResponseButtonProps = {
_id: string;
reload: () => void;
+ totalDataReload: () => void;
};
-const RemoveCannedResponseButton: FC = ({ _id, reload }) => {
+const RemoveCannedResponseButton: FC = ({
+ _id,
+ reload,
+ totalDataReload,
+}) => {
const cannedResponsesRoute = useRoute('omnichannel-canned-responses');
const removeCannedResponse = useMethod('removeCannedResponse');
const setModal = useSetModal();
@@ -36,6 +41,7 @@ const RemoveCannedResponseButton: FC = ({ _id,
try {
await handleRemoveClick();
reload();
+ totalDataReload();
dispatchToastMessage({ type: 'success', message: t('Canned_Response_Removed') });
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });