Skip to content

Commit

Permalink
feat: Redirect the user to the search page if there is no active city
Browse files Browse the repository at this point in the history
  • Loading branch information
FleetAdmiralJakob committed Jan 22, 2024
1 parent da04dac commit 31a0556
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/web/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from "react";
import React, { useLayoutEffect, useState } from "react";
import { router } from "next/client";
import dynamic from "next/dynamic";
import Link from "next/link";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -288,6 +289,12 @@ const InternalHome = observer(() => {
activeCity$.coord.lon.get(),
];

useLayoutEffect(() => {
if (activeCity$.id.get() === 0 && activeCity$.name.get() === "") {
void router.push("/search");
}
});

return (
<Layout classNameShareButton="mt-44" page="home">
<div className="mt-24 flex flex-col items-center">
Expand Down

0 comments on commit 31a0556

Please sign in to comment.