Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/1168-creation-and-update-times-and…
Browse files Browse the repository at this point in the history
…-ids-of-elements
  • Loading branch information
markus2330 authored Mar 9, 2024
2 parents 46001b2 + 3ee7fe1 commit 17d98c2
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Syntax: `- short text describing the change _(Your Name)_`
- CI: unstash schemas in release pipeline in build-backend _(4ydan)_
- _()_
- _()_
- _()_
- Added missing error toast messages _(Daniel Steinkogler)_
- _()_
- _()_
- E2E: fix planting cursor tests _(4ydan & absurd-turtle)_
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/config/i18n/de/guidedTour.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"confirmation_resume": "Fortsetzen",
"confirmation_pause": "Pausieren",
"confirmation_quit": "Beenden",
"fetch_status_error": "Sorry, ich habe Schwierigkeiten den Status deiner Einführung in den Map Editor zu empfangen. Bitte lade die Seite neu, damit ich es noch einmal versuchen kann.",
"fetch_status_error": "Entschuldigung, ich habe Schwierigkeiten den Status deiner Einführung in den Map Editor zu empfangen. Bitte lade die Seite neu, damit ich es noch einmal versuchen kann.",
"update_tour_status_error": "Entschuldigung, ich habe Schwierigkeiten den Status deiner Einführung zu aktualisieren.",
"complete_tour_error": "Entschuldigung, ich habe Schwierigkeiten die Einführungstour abzuschließen.",
"mapEditor": {
"welcome_title": "Willkommen im Map Editor",
"toolbox_intro_title": "Toolbox",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/config/i18n/de/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import maps from './maps.json';
import nextcloudIntegration from './nextcloudIntegration.json';
import overview from './overview.json';
import plantAndSeedSearch from './plantAndSeedSearch.json';
import plantRelations from './plantRelations.json';
import plantSearch from './plantSearch.json';
import plantingSuggestions from './plantingSuggestions.json';
import plantings from './plantings.json';
Expand Down Expand Up @@ -70,4 +71,5 @@ export default {
readOnly,
toolboxTooltips,
polygon,
plantRelations,
};
1 change: 1 addition & 0 deletions frontend/src/config/i18n/de/maps.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"error_fetch_map_data": "Entschuldigung, ich habe Schwierigkeiten die Karten von meinem Server zu erhalten. Bitte versuche es später erneut.",
"overview": {
"page_title": "Meine Karten",
"create_button": "Neue Karte",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/config/i18n/de/plantRelations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"error_fetching_relations": "Entschuldigung, ich habe Schwierigkeiten die Beziehungen zwischen den Pflanzen zu laden. Bitte versuche es später noch einmal."
}
2 changes: 2 additions & 0 deletions frontend/src/config/i18n/en/guidedTour.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"confirmation_pause": "Pause",
"confirmation_quit": "End",
"fetch_status_error": "Sorry, I'm experiencing trouble fetching the status of your introduction to the Map Editor. Please reload the page so that I can try again.",
"update_tour_status_error": "Sorry, I'm experiencing trouble updating the status of your introduction tour.",
"complete_tour_error": "Sorry, I'm experiencing trouble completing the introduction tour.",
"mapEditor": {
"welcome_title": "Welcome to the Map Editor",
"toolbox_intro_title": "Toolbox",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/config/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import maps from './maps.json';
import nextcloudIntegration from './nextcloudIntegration.json';
import overview from './overview.json';
import plantAndSeedSearch from './plantAndSeedSearch.json';
import plantRelations from './plantRelations.json';
import plantSearch from './plantSearch.json';
import plantingSuggestions from './plantingSuggestions.json';
import plantings from './plantings.json';
Expand Down Expand Up @@ -70,4 +71,5 @@ export default {
readOnly,
toolboxTooltips,
polygon,
plantRelations,
};
3 changes: 2 additions & 1 deletion frontend/src/config/i18n/en/maps.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"overview": {
"error_fetch_map_data": "Sorry, I'm experiencing trouble fetching maps from my server. Please try again later.",
"overview": {
"page_title": "My Maps",
"create_button": "New Map",
"create_button_title": "Create new map",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/config/i18n/en/plantRelations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"error_fetching_relations": "Sorry, I'm experiencing trouble fetching plant relations from my server. Please try again later."
}
8 changes: 5 additions & 3 deletions frontend/src/features/map_planning/hooks/mapEditorHookApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export function useGetLayers(mapId: number) {
staleTime: TEN_MINUTES,
refetchOnWindowFocus: false,
meta: {
autoClose: false,
errorMessage: t('layers:error_fetching_layers'),
},
});
Expand All @@ -57,11 +56,15 @@ function getLayersQueryFn({
* Get map data for the given map id.
*/
export function useMap(mapId: number) {
const { t } = useTranslation(['maps']);

return useQuery({
queryKey: MAP_EDITOR_KEYS.map(mapId),
queryFn: getMapQueryFn,
refetchOnWindowFocus: false,
// TODO: add error message
meta: {
errorMessage: t('maps:error_fetch_map_data'),
},
});
}

Expand Down Expand Up @@ -99,7 +102,6 @@ export function usePlantLayer({ mapId, layerId, enabled }: UseLayerArgs) {
cacheTime: 0,
enabled,
meta: {
autoClose: false,
errorMessage: t('plantSearch:error_initializing_layer'),
},
});
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/features/map_planning/hooks/tourHookApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next';
import { errorToastGrouped } from '@/features/toasts/groupedToast';
import { getTourStatus } from '../api/getTourStatus';
import { updateTourStatus } from '../api/updateTourStatus';

Expand All @@ -23,7 +24,6 @@ export function useTourStatus() {
refetchOnWindowFocus: false,
meta: {
errorMessage: t('guidedTour:fetch_status_error'),
autoClose: false,
},
});
}
Expand All @@ -33,12 +33,12 @@ export function useTourStatus() {
*/
export function useReenableTour() {
const queryClient = useQueryClient();
const { t } = useTranslation(['guidedTour']);

return useMutation({
mutationFn: () => updateTourStatus({ editor_tour_completed: false }),
onError: () => {
// TODO toast
console.error('Failed to re-enable guided tour');
errorToastGrouped(t('guidedTour:update_tour_status_error'));
},
onSuccess: () => queryClient.invalidateQueries(TOUR_KEYS.status()),
});
Expand All @@ -49,12 +49,12 @@ export function useReenableTour() {
*/
export function useCompleteTour() {
const queryClient = useQueryClient();
const { t } = useTranslation(['guidedTour']);

return useMutation({
mutationFn: () => updateTourStatus({ editor_tour_completed: true }),
onError: () => {
// TODO toast
console.error('Failed to complete guided tour');
errorToastGrouped(t('guidedTour:complete_tour_error'));
},
onSuccess: () => queryClient.invalidateQueries(TOUR_KEYS.status()),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export function useFindPlantById({ plantId, enabled = true }: FindPlantByIdArgs)
queryKey: PLANT_KEYS.detail(plantId),
queryFn: findPlantByIdQueryFn,
meta: {
autoClose: false,
errorMessage: t('plantings:error_fetching_plant'),
},
enabled,
Expand Down Expand Up @@ -79,7 +78,6 @@ export function usePlantSearch() {
queryFn: searchPlantsQueryFn,
select: mapPageToList,
meta: {
autoClose: false,
errorMessage: t('plantSearch:error_searching_plants'),
},
// prevent the query from being fetched again for the
Expand Down Expand Up @@ -125,7 +123,6 @@ export function useSeasonalAvailablePlants(mapId: number, date: Date) {
queryFn: seasonalAvailablePlantsQueryFn,
select: mapPageToList,
meta: {
autoClose: false,
errorMessage: t('plantingSuggestions:available_seeds.error_fetching_seasonal_suggestions'),
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { QueryFunctionContext, useQuery } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next';
import { RelationDto, RelationsDto } from '@/api_types/definitions';
import { getRelations } from '../api/getRelations';

Expand All @@ -12,12 +13,16 @@ const RELATION_KEYS = {
};

export function useRelations({ mapId, plantId, enabled = true }: UseRelationsArgs) {
const { t } = useTranslation(['plantRelations']);

return useQuery({
queryKey: RELATION_KEYS.detail(mapId, plantId),
queryFn: getRelationsQueryFn,
enabled,
select: mapRelationToMap,
// TODO: add error messages
meta: {
errorMessage: t('plantRelations:error_fetching_relations'),
},
});
}

Expand Down
6 changes: 2 additions & 4 deletions frontend/src/features/maps/hooks/mapHookApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export function useFindMapById(mapId: number) {
queryFn: findMapByIdQueryFn,
meta: {
errorMessage: t('maps:edit.error_map_single_fetch'),
autoClose: false,
toastId: 'fetchError',
},
});
Expand All @@ -65,7 +64,6 @@ export function useMapsSearch(searchParams: MapSearchParameters) {
queryFn: searchSeedsQueryFn,
getNextPageParam: (lastPage) => lastPage.page + 1,
meta: {
autoClose: false,
errorMessage: t('maps:overview.error_map_fetch'),
},
});
Expand Down Expand Up @@ -97,7 +95,7 @@ export function useCreateMap() {
queryClient.invalidateQueries(MAP_KEYS._helpers.all);
},
onError: () => {
errorToastGrouped(t('maps:create.error_map_create'), { autoClose: false });
errorToastGrouped(t('maps:create.error_map_create'));
},
});
}
Expand All @@ -115,7 +113,7 @@ export function useEditMap() {
queryClient.invalidateQueries(MAP_KEYS.detail(id));
},
onError: () => {
errorToastGrouped(t('maps:edit.error_map_edit'), { autoClose: false });
errorToastGrouped(t('maps:edit.error_map_edit'));
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function useImageFromBlob({
if (isError) {
if (showErrorMessage) {
errorToastGrouped(t('nextcloudIntegration:load_image_failed'), {
autoClose: false,
toastId: 'ncError',
});
}
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/features/seeds/hooks/seedHookApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function useFindSeedById({ seedId, enabled = true, quiet = false }: FindS
queryKey: SEED_KEYS.detail(seedId),
queryFn: findSeedByIdQueryFn,
meta: {
autoClose: false,
errorMessage: !quiet ? t('seeds:error_fetching_seed') : undefined,
},
enabled,
Expand Down Expand Up @@ -80,7 +79,6 @@ export function useSeedSearch() {
},
getPreviousPageParam: () => undefined,
meta: {
autoClose: false,
errorMessage: t('seeds:view_seeds.fetching_error'),
},
});
Expand Down

0 comments on commit 17d98c2

Please sign in to comment.