Skip to content

Commit

Permalink
Merge pull request #1372 from openedx/maham/ENT-8817
Browse files Browse the repository at this point in the history
fix: validate insights before rendering analytics summary & improve error message
  • Loading branch information
mahamakifdar19 authored Jan 6, 2025
2 parents fdc0a9a + 01d5fda commit b0341f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/Admin/AIAnalyticsSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const AnalyticsDetailCard = ({
const messages = defineMessages({
errorMessage: {
id: 'adminPortal.analyticsCardText.errorMessage',
defaultMessage: 'An error occurred: {error_message}',
defaultMessage: 'We encountered an issue while fetching analytics data. Kindly try again later or contact support for assistance. (Error: {error_message})',
description: 'Message shown to the user in case of error returned byt analytics API.',
values: { error_message: error?.message },
},
Expand All @@ -38,7 +38,7 @@ const AnalyticsDetailCard = ({
</Badge>
<Stack gap={1} direction="horizontal">
<p className="card-text text-justify small">
${
{
error ? (
<FormattedMessage {...messages.errorMessage} />
) : (
Expand Down
4 changes: 3 additions & 1 deletion src/components/Admin/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ class Admin extends React.Component {
searchBudgetQuery: queryParams.get('budget_uuid') || '',
};

const hasCompleteInsights = insights?.learner_engagement && insights?.learner_progress;

return (
<main role="main" className="learner-progress-report">
{!loading && !error && !this.hasAnalyticsData() ? <EnterpriseAppSkeleton /> : (
Expand All @@ -445,7 +447,7 @@ class Admin extends React.Component {
<div className="row mt-4">
<div className="col">
{insightsLoading ? <AIAnalyticsSummarySkeleton /> : (
insights && <AIAnalyticsSummary enterpriseId={enterpriseId} />
hasCompleteInsights && <AIAnalyticsSummary enterpriseId={enterpriseId} />
)}
</div>
</div>
Expand Down

0 comments on commit b0341f4

Please sign in to comment.