-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Show loading indicators and failure indicators for soil id (#1688)
Commits: * feat: Location dashboard displays "Loading..." or "No matches" or soil id results * feat: Add loading spinner for matches section in Soil ID screen * feat: error and alert boxes appear for soil id screen's top soil matches section * feat: temporary location callout displays each datum section with loading spinner, error, no matches, or the top match * refactor: Move message box components to separate files * refactor: Consolidate no matches and error strings * refactor: get soil match and ecological site similarly between TemporaryLocationCallout and LocationPrediction on dashboard * fix: use consistent apostrophe characters in strings * fix: minor styling and refactoring * fix: Remove unused import after rebase * refactor: Consolidate some duplicate logic with SoilIdStatusDisplay * fix: Update test snapshot to accomodate soil id tile existing regardless of status
- Loading branch information
Showing
13 changed files
with
751 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright © 2024 Technology Matters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
|
||
import {ReactNode} from 'react'; | ||
|
||
import {SoilIdStatus} from 'terraso-client-shared/soilId/soilIdTypes'; | ||
|
||
export type SoilIdStatusDisplayProps = { | ||
status: SoilIdStatus; | ||
|
||
loading: ReactNode; | ||
error: ReactNode; | ||
noData: ReactNode; | ||
data: ReactNode; | ||
}; | ||
export const SoilIdStatusDisplay = ({ | ||
status, | ||
loading, | ||
error, | ||
noData, | ||
data, | ||
}: SoilIdStatusDisplayProps) => { | ||
if (status === 'loading') { | ||
return loading; | ||
} else if (status === 'error') { | ||
return error; | ||
} else if (status === 'DATA_UNAVAILABLE') { | ||
return noData; | ||
} else { | ||
return data; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright © 2024 Technology Matters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
|
||
import {Icon} from 'terraso-mobile-client/components/icons/Icon'; | ||
import { | ||
Box, | ||
Column, | ||
Row, | ||
Text, | ||
} from 'terraso-mobile-client/components/NativeBaseAdapters'; | ||
|
||
type MessageBoxProps = React.PropsWithChildren<{ | ||
title?: string; | ||
}>; | ||
|
||
export const AlertMessageBox = ({title, children}: MessageBoxProps) => { | ||
return ( | ||
<Box | ||
backgroundColor="primary.contrast" | ||
borderColor="warning.main" | ||
borderWidth="2px" | ||
borderRadius="4px" | ||
padding="md"> | ||
<Row> | ||
<Icon name="warning-amber" color="warning.main" mr="md" /> | ||
<Column flex={1}> | ||
<Text variant="body1-strong" color="warning.content" mb="sm"> | ||
{title} | ||
</Text> | ||
{children} | ||
</Column> | ||
</Row> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright © 2024 Technology Matters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
|
||
import {Icon} from 'terraso-mobile-client/components/icons/Icon'; | ||
import { | ||
Box, | ||
Column, | ||
Row, | ||
Text, | ||
} from 'terraso-mobile-client/components/NativeBaseAdapters'; | ||
|
||
type MessageBoxProps = React.PropsWithChildren<{ | ||
title?: string; | ||
}>; | ||
|
||
export const ErrorMessageBox = ({title, children}: MessageBoxProps) => { | ||
return ( | ||
<Box | ||
backgroundColor="error.background" | ||
borderColor="error.main" | ||
borderWidth="2px" | ||
borderRadius="4px" | ||
padding="md"> | ||
<Row> | ||
<Icon name="error-outline" color="error.main" mr="md" /> | ||
<Column flex={1}> | ||
<Text variant="body1-strong" color="error.content" mb="sm"> | ||
{title} | ||
</Text> | ||
{children} | ||
</Column> | ||
</Row> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright © 2024 Technology Matters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
|
||
import { | ||
SoilIdResults, | ||
SoilIdStatus, | ||
} from 'terraso-client-shared/soilId/soilIdSlice'; | ||
|
||
// TODO: This could be moved to client-shared | ||
export type SoilIdData = SoilIdResults & {status: SoilIdStatus}; |
Oops, something went wrong.