Skip to content

Commit

Permalink
[TM-1531] transifex and fix selector
Browse files Browse the repository at this point in the history
  • Loading branch information
egrojMonroy committed Dec 24, 2024
1 parent 3ec5111 commit 107d1fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
14 changes: 8 additions & 6 deletions src/components/elements/Notification/FloatNotification.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LinearProgress } from "@mui/material";
import { useT } from "@transifex/react";
import classNames from "classnames";
import { useEffect, useState } from "react";
import { When } from "react-if";
Expand All @@ -22,6 +23,7 @@ export interface FloatNotificationProps {
}

const FloatNotification = () => {
const t = useT();
const [openModalNotification, setOpenModalNotification] = useState(false);
const [isLoaded, { delayedJobs }] = useDelayedJobs();
const [notAcknowledgedJobs, setNotAcknowledgedJobs] = useState<DelayedJobDto[]>([]);
Expand Down Expand Up @@ -76,15 +78,15 @@ const FloatNotification = () => {
)}
>
<Text variant="text-20-bold" className="border-b border-grey-350 p-6 text-blueCustom-900">
Notifications
{t("Notifications")}
</Text>
<div className="flex flex-col overflow-hidden px-6 pb-8 pt-6">
<div className="mb-2 flex items-center justify-between">
<Text variant="text-14-light" className="text-neutral-400">
Actions Taken
{t("Actions Taken")}
</Text>
<Text variant="text-12-semibold" className="text-primary" onClick={clearJobs}>
Clear completed
{t("Clear completed")}
</Text>
</div>
<div className="-mr-2 flex flex-1 flex-col gap-3 overflow-auto pr-2">
Expand All @@ -104,7 +106,7 @@ const FloatNotification = () => {
<div className="mt-2">
{item.status === "failed" ? (
<Text variant="text-12-semibold" className="text-error-600">
{item.payload ? getErrorMessageFromPayload(item.payload) : "Failed to complete"}
{item.payload ? t(getErrorMessageFromPayload(item.payload)) : t("Failed to complete")}
</Text>
) : (
<div className="flex items-center gap-2">
Expand Down Expand Up @@ -135,10 +137,10 @@ const FloatNotification = () => {
<Text variant="text-12-semibold" className="text-black">
{item.name === "Polygon Upload"
? item.status === "succeeded"
? "Done!"
? t("Done!")
: ""
: item.status === "succeeded"
? "Done!"
? t("Done!")
: `${Math.round(((item.processedContent ?? 0) / (item.totalContent ?? 1)) * 100)}%`}
</Text>
</div>
Expand Down
23 changes: 8 additions & 15 deletions src/connections/DelayedJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,17 @@ type DelayedJobCombinedConnection = {
updatedJobsResponse?: DelayedJobDto[];
};

const delayedJobsSelector = (store: ApiDataStore) =>
Object.values(store.delayedJobs ?? {}).map(resource => resource.attributes);

const bulkUpdateJobsSelector = (store: ApiDataStore) => ({
bulkUpdateJobsIsLoading: bulkUpdateJobsIsFetching(store),
bulkUpdateJobsHasFailed: bulkUpdateJobsFetchFailed(store) != null,
updatedJobsResponse: Object.values(store.delayedJobs ?? {}).map(resource => resource.attributes as DelayedJobDto)
});
const delayedJobsSelector = (store: ApiDataStore) => store.delayedJobs;

const combinedSelector = createSelector(
[delayedJobsSelector, bulkUpdateJobsSelector],
(delayedJobs, { bulkUpdateJobsIsLoading, bulkUpdateJobsHasFailed, updatedJobsResponse }) => ({
delayedJobs,
delayedJobsIsLoading: delayedJobs == null && !bulkUpdateJobsHasFailed,
delayedJobsHasFailed: bulkUpdateJobsHasFailed,
[delayedJobsSelector, bulkUpdateJobsIsFetching, bulkUpdateJobsFetchFailed],
(delayedJobs, bulkUpdateJobsIsLoading, bulkUpdateJobsFailure) => ({
delayedJobs: Object.values(delayedJobs ?? {}).map(resource => resource.attributes),
delayedJobsIsLoading: delayedJobs == null && !bulkUpdateJobsFailure,
delayedJobsHasFailed: Boolean(bulkUpdateJobsFailure),
bulkUpdateJobsIsLoading,
bulkUpdateJobsHasFailed,
updatedJobsResponse
bulkUpdateJobsHasFailed: bulkUpdateJobsFailure != null,
updatedJobsResponse: Object.values(delayedJobs ?? {}).map(resource => resource.attributes as DelayedJobDto)
})
);

Expand Down

0 comments on commit 107d1fb

Please sign in to comment.