diff --git a/app/components/toast/component.tsx b/app/components/toast/component.tsx index 55bb4298aa..4faaf06a48 100644 --- a/app/components/toast/component.tsx +++ b/app/components/toast/component.tsx @@ -32,8 +32,8 @@ const THEME: ToastTheme = { }, error: { icon: ERROR_SVG, - bg: 'from-red-1000 to-red-800', - hoverBg: 'from-red-200 to-red-1000', + bg: 'from-red-500 to-red-800', + hoverBg: 'from-red-200 to-red-900', }, }; diff --git a/app/hooks/scenarios/index.ts b/app/hooks/scenarios/index.ts index 35d0940245..6f4d49effa 100644 --- a/app/hooks/scenarios/index.ts +++ b/app/hooks/scenarios/index.ts @@ -20,7 +20,6 @@ import { useMe } from 'hooks/me'; import { useProjectUsers } from 'hooks/project-users'; import { ItemProps } from 'components/scenarios/item/component'; -import { CostSurface } from 'types/api/cost-surface'; import { Job } from 'types/api/job'; import { Project } from 'types/api/project'; import { Scenario } from 'types/api/scenario'; diff --git a/app/layout/help/documentation/component.tsx b/app/layout/help/documentation/component.tsx index b63a5a316d..055f6ebc98 100644 --- a/app/layout/help/documentation/component.tsx +++ b/app/layout/help/documentation/component.tsx @@ -23,7 +23,7 @@ export const DocumentationLink = () => { /> {isHover && ( -
+

Marxan's documentation

)} diff --git a/app/layout/loading/component.tsx b/app/layout/loading/component.tsx index ef906817ba..2e475fddb6 100644 --- a/app/layout/loading/component.tsx +++ b/app/layout/loading/component.tsx @@ -22,7 +22,7 @@ export const Loading: React.FC = ({ loading }: LoadingProps) => { animate={{ opacity: 1 }} exit={{ opacity: 0 }} className={cn({ - 'z-60 fixed h-full w-full': true, + 'fixed z-50 h-full w-full': true, })} >
{ const queryClient = useQueryClient(); const { addToast } = useToasts(); const [modal, setModal] = useState(false); - const [deleteScenario, setDelete] = useState(null); + const [deleteScenario, setDelete] = useState(null); const [solutionsReportLoader, setSolutionsReportLoader] = useState(false); - const { search, filters, sort } = useSelector((state) => state['/projects/[id]']); + const { search, filters, sort } = useAppSelector((state) => state['/projects/[id]']); const { query } = useRouter(); const { pid } = query as { pid: string }; @@ -77,11 +82,13 @@ export const ScenariosList: React.FC = () => { const deleteMutation = useDeleteScenario({}); + const atLeastOneScenarioIsRun = scenariosData.some(({ ranAtLeastOnce }) => ranAtLeastOnce); + const onDelete = useCallback(() => { deleteMutation.mutate( { id: deleteScenario.id }, { - onSuccess: () => { + onSuccess: async () => { addToast( `success-scenario-delete-${deleteScenario.id}`, <> @@ -92,7 +99,7 @@ export const ScenariosList: React.FC = () => { level: 'success', } ); - queryClient.invalidateQueries(['scenarios', pid]); + await queryClient.invalidateQueries(['scenarios', pid]); setDelete(null); }, onError: () => { @@ -119,7 +126,7 @@ export const ScenariosList: React.FC = () => { }); const onDuplicate = useCallback( - (scenarioId, scenarioName) => { + (scenarioId: Scenario['id'], scenarioName: Scenario['name']) => { duplicateScenarioMutation.mutate( { sid: scenarioId }, { @@ -156,7 +163,7 @@ export const ScenariosList: React.FC = () => { const cancelRunMutation = useCancelRunScenario({}); const onCancelRun = useCallback( - (scenarioId, scenarioName) => { + (scenarioId: Scenario['id'], scenarioName: Scenario['name']) => { cancelRunMutation.mutate( { id: scenarioId }, { @@ -164,7 +171,7 @@ export const ScenariosList: React.FC = () => { addToast( 'success-cancel-scenario', <> -

Success!

+

Success

Scenario {scenarioName} canceled

, { @@ -176,7 +183,7 @@ export const ScenariosList: React.FC = () => { addToast( 'error-cancel-scenario', <> -

Error!

+

Error

Scenario {scenarioName} not canceled

, { @@ -195,6 +202,17 @@ export const ScenariosList: React.FC = () => { const onDownloadSolutionsSummary = useCallback(() => { setSolutionsReportLoader(true); + addToast( + 'download-info', + <> +

Download in progress

+
    Your report is being downloaded.
+ , + { + level: 'info', + } + ); + downloadSolutionsSummary.mutate( { id: pid }, { @@ -202,7 +220,7 @@ export const ScenariosList: React.FC = () => { addToast( 'download-error', <> -

Error!

+

Error

    Solutions report not downloaded
, { @@ -312,19 +330,13 @@ export const ScenariosList: React.FC = () => {
-
- Upload Protected Areas -
+
Upload Protected Areas
-
- Upload Cost Surface -
+
Upload Cost Surface
-
- Upload Features -
+
Upload Features
@@ -357,7 +369,7 @@ export const ScenariosList: React.FC = () => { theme="primary-alt" size="base" className="flex w-full overflow-hidden uppercase" - disabled={solutionsReportLoader} + disabled={solutionsReportLoader || !atLeastOneScenarioIsRun} onClick={onDownloadSolutionsSummary} > void }) iconClassName="w-10 h-10 text-white" /> - {(!targetedFeaturesData || !targetedFeaturesData.length) && } + {!targetedFeaturesData?.length && } - {!!targetedFeaturesData && !!targetedFeaturesData.length && ( + {!!targetedFeaturesData.length && (
@@ -346,7 +346,7 @@ export const ScenariosFeaturesTargets = ({ onGoBack }: { onGoBack: () => void })
)} - {!!targetedFeaturesData && !!targetedFeaturesData.length && ( + {!!targetedFeaturesData?.length && (