Skip to content

Commit

Permalink
chore: Removed unnecessary code from the /home page and handled an ed…
Browse files Browse the repository at this point in the history
…ge case in the /locationsettings & /search page
  • Loading branch information
FleetAdmiralJakob committed Jan 3, 2024
1 parent 55e9d81 commit 7f66715
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions public/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"meters per second": "Meter pro Sekunde",
"beaufort": "Beaufort",

"my city": "Meine Stadt",

"share text": "Checke doch mal diese Seite aus: ",

"title 404 page": "404: Seite nicht gefunden",
Expand Down
2 changes: 0 additions & 2 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
"meters per second": "Meters per second",
"beaufort": "Beaufort",

"my city": "My city",

"share text": "Check out this page: ",

"title 404 page": "404: This page could not be found",
Expand Down
7 changes: 1 addition & 6 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,7 @@ const InternalHome = observer(() => {
<Layout classNameShareButton="mt-44">
<div className="mt-24 flex flex-col items-center">
<h1 className="text-center text-4xl sm:text-5xl md:text-7xl">
{activeCity$.name.get() === "My city" ||
activeCity$.name.get() === "Meine Stadt" ? (
<>{translationCommon("my city")}</>
) : (
<>{activeCity$.name.get()}</>
)}
{activeCity$.name.get()}
</h1>
<h1 className="mt-3 text-6xl text-gray-500 md:text-7xl">
{temperature ? temperature : <Skeleton className="h-20 w-36" />}
Expand Down
6 changes: 6 additions & 0 deletions src/pages/locationsettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ const LocationSettings = observer(() => {
}

if (city) {
const existingCity = addedCities$
.get()
.find((value: ICity) => value.name === city!.name);
if (addedCities$.get().find((value: ICity) => value.id === city!.id)) {
activeCity$.set(city);
toast.success(translationLocationSettings("switched to city toast"));
} else if (existingCity) {
activeCity$.set(existingCity);
toast.success(translationLocationSettings("switched to city toast"));
} else {
addedCities$.push(city);
activeCity$.set(city);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,15 @@ const Search = () => {
}

if (city) {
const existingCity = addedCities$
.get()
.find((value: ICity) => value.name === city!.name);
if (addedCities$.get().find((value: ICity) => value.id === city!.id)) {
activeCity$.set(city);
void router.push("/home");
} else if (existingCity) {
activeCity$.set(existingCity);
void router.push("/home");
} else {
addedCities$.push(city);
activeCity$.set(city);
Expand Down

1 comment on commit 7f66715

@vercel
Copy link

@vercel vercel bot commented on 7f66715 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.