Skip to content

Commit

Permalink
add rest of translations, improve error flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianka committed Jun 7, 2024
1 parent cfbdca6 commit 86047bb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
14 changes: 10 additions & 4 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { sortBoxes } from "./components/Buttons/sortLogic";
import { getBoxes } from "./services/boxes";
import ErrorMessage from "./components/ErrorMessage";
import { searchBoxes } from "./misc";
import InfoMessage from "./components/InfoMessage";

const address = import.meta.env.VITE_BACKEND_URL;

Expand Down Expand Up @@ -79,10 +80,15 @@ function App() {
</div>
</div>
{error ? (
<ErrorMessage
title="Error!"
description="Backend URL not found. Please check your .env file."
/>
<div>
<ErrorMessage
title={t("error")}
description={t("couldntFetchBoxes")}
/>
<div className="mt-3">
<InfoMessage title={t("info")} description={t("infoTip")} />
</div>
</div>
) : (
<BoxList
pagination={pagination}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/ErrorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface props {
const ErrorMessage = ({ title, description }: props) => {
return (
<Alert color="failure" icon={HiInformationCircle}>
<span className="font-medium">{title} </span>
{description}
<span className="font-medium">{title}. </span>
{description}.
</Alert>
);
};
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/components/InfoMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Alert } from "flowbite-react";
import { HiInformationCircle } from "react-icons/hi";

interface props {
title: string;
description: string;
}

const InfoMessage = ({ title, description }: props) => {
return (
<Alert color="info" icon={HiInformationCircle}>
<span className="font-medium">{title}. </span>
{description}.
</Alert>
);
};

export default InfoMessage;
13 changes: 8 additions & 5 deletions frontend/src/i18n/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@
"undoChanges": "Undo changes",
"deleteBox": "Delete box",
"saveChanges": "Save changes",
"editBoxErrorTitle": "Error while modifying.",
"addBoxErrorTitle": "Error while adding.",
"BoxErrorDescription": " Make sure all values are numbers, greater than 0, and not empty.",
"editBoxErrorTitle": "Error while modifying",
"addBoxErrorTitle": "Error while adding",
"BoxErrorDescription": " Make sure all values are numbers, greater than 0, and not empty",
"notModified": "Not modified",
"noComment": "No comment",
"previous": "Previous",
"next": "Next",
"noBoxesFound": "No boxes found.",
"boxAdded": "Box added successfully.",
"boxDeleted": "Box deleted successfully.",
"language": "Language"

"language": "Language",
"error": "Error",
"tip": "Tip",
"info": "Info",
"infoTip": "Make sure backend and database are running, and you have set the .env values to backend and frontend. See GitHub readme for more information"

}
12 changes: 8 additions & 4 deletions frontend/src/i18n/fi/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@
"undoChanges": "Peru muutokset",
"deleteBox": "Poista laatikko",
"saveChanges": "Tallenna muutokset",
"editBoxErrorTitle": "Virhe muokatessa.",
"addBoxErrorTitle": "Virhe lisättäessä.",
"BoxErrorDescription": "Varmista että kaikki arvot ovat numeroita, suurempia kuin 0, ja eivät ole tyhjiä.",
"editBoxErrorTitle": "Virhe muokatessa",
"addBoxErrorTitle": "Virhe lisättäessä",
"BoxErrorDescription": "Varmista että kaikki arvot ovat numeroita, suurempia kuin 0, ja eivät ole tyhjiä",
"notModified": "Ei muutettu",
"noComment": "Ei kommenttia",
"previous": "Edellinen",
"next": "Seuraava",
"noBoxesFound": "Laatikoita ei löytynyt.",
"boxAdded": "Laatikko lisätty onnistuneesti.",
"boxDeleted": "Laatikko poistettu onnistuneesti.",
"language": "Kieli"
"language": "Kieli",
"error": "Virhe",
"tip": "Vinkki",
"info": "Info",
"infoTip": "Varmista että backend ja tietokanta ovat käynnissä, ja että olet asettanut .env arvot backendiin ja frontendiin. Katso GitHubin readme lisätietoja varten"

}

0 comments on commit 86047bb

Please sign in to comment.