Skip to content

Commit

Permalink
feat: fixed errors for i18n related commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
saleem-latif committed Apr 19, 2024
1 parent 83b8906 commit 81cebff
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ dist/
# edx
.env.private
temp/
src/i18n/transifex_input.json
src/i18n/messages

69 changes: 42 additions & 27 deletions src/components/Admin/AIAnalyticsSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import {
Button, Card, Stack, Badge, useToggle,
} from '@edx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { FormattedMessage, defineMessages } from '@edx/frontend-platform/i18n';
import { AutoFixHigh, Groups } from '@edx/paragon/icons';
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
import useAIAnalyticsSummary from '../AIAnalyticsSummary/data/hooks';
Expand All @@ -15,33 +15,48 @@ const AnalyticsDetailCard = ({
isLoading,
error,
data,
}) => (
<Card className="mt-3 mb-4" isLoading={isLoading}>
<Card.Section>
<Badge variant="light" className="mb-3 font-weight-semibold">
<FormattedMessage id="adminPortal.analyticsCardBetaButton" defaultMessage="Beta" />
</Badge>
<Stack gap={1} direction="horizontal">
<p className="card-text text-justify small">
<FormattedMessage
id="adminPortal.analyticsCardText"
defaultMessage={
error
? `An error occurred: ${error.message}`
: data || 'Analytics not found.'
}) => {
const messages = defineMessages({
errorMessage: {
id: 'adminPortal.analyticsCardText.errorMessage',
defaultMessage: 'An error occurred: {error_message}',
description: 'Message shown to the user in case of error returned byt analytics API.',
values: { error_message: error?.message },
},
noContentErrorMessage: {
id: 'adminPortal.analyticsCardText.noContentErrorMessage',
defaultMessage: 'Analytics not found.',
description: 'Message shown to the user in case of empty response returned byt analytics API.',
},
});

return (
<Card className="mt-3 mb-4" isLoading={isLoading}>
<Card.Section>
<Badge variant="light" className="mb-3 font-weight-semibold">
<FormattedMessage id="adminPortal.analyticsCardBetaButton" defaultMessage="Beta" />
</Badge>
<Stack gap={1} direction="horizontal">
<p className="card-text text-justify small">
${
error ? (
<FormattedMessage {...messages.errorMessage} />
) : (
data || <FormattedMessage {...messages.noContentErrorMessage} />
)
}
/>
</p>
<Button variant="link" className="mb-4 ml-3" onClick={onClose}>
<span className="small font-weight-bold text-gray-800">Dismiss</span>
</Button>
</Stack>
<label className="x-small" htmlFor="poweredBylabel">
<FormattedMessage id="adminPortal.analyticsCardPoweredBylabel" defaultMessage="Powered by OpenAI" />
</label>
</Card.Section>
</Card>
);
</p>
<Button variant="link" className="mb-4 ml-3" onClick={onClose}>
<span className="small font-weight-bold text-gray-800">Dismiss</span>
</Button>
</Stack>
<label className="x-small" htmlFor="poweredBylabel">
<FormattedMessage id="adminPortal.analyticsCardPoweredBylabel" defaultMessage="Powered by OpenAI" />
</label>
</Card.Section>
</Card>
);
};

AnalyticsDetailCard.propTypes = {
onClose: PropTypes.func.isRequired,
Expand Down
25 changes: 18 additions & 7 deletions src/components/learner-credit-management/search/CatalogSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,27 @@ const CatalogSearch = () => {
data: subsidyAccessPolicy,
} = useSubsidyAccessPolicy(subsidyAccessPolicyId);
const searchFilters = `enterprise_catalog_uuids:${ENABLE_TESTING(subsidyAccessPolicy.catalogUuid)} AND content_type:course`;
const displayName = subsidyAccessPolicy.displayName ? `${subsidyAccessPolicy.displayName} catalog` : 'Overview';

return (
<section>
<FormattedMessage
id="catalogs.enterpriseCatalogs.header"
defaultMessage={displayName}
description="Search dialogue."
tagName="h3"
/>
{(
subsidyAccessPolicy.displayName ? (
<FormattedMessage
id="catalogs.enterpriseCatalogs.header.subsidyAccessPolicyName"
defaultMessage="{subsidyAccessPolicyName} catalog"
description="Search dialogue message with subsidy access policy name."
tagName="h3"
values={{ subsidyAccessPolicyName: subsidyAccessPolicy.displayName }}
/>
) : (
<FormattedMessage
id="catalogs.enterpriseCatalogs.header"
defaultMessage="Overview"
description="Search dialogue."
tagName="h3"
/>
)
)}
<InstantSearch indexName={configuration.ALGOLIA.INDEX_NAME} searchClient={searchClient}>
<div className="enterprise-catalogs-header">
<Configure
Expand Down

0 comments on commit 81cebff

Please sign in to comment.