feat: not-found url error

This commit is contained in:
2025-06-09 12:52:49 +03:00
parent 3d1898f849
commit 6141d7bf9e
3 changed files with 17 additions and 4 deletions

View File

@@ -9,3 +9,5 @@ DB_PORT=
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
BOT_TOKEN=
REDIS_URL=redis://localhost:6379

View File

@@ -2,8 +2,6 @@ services:
redis:
image: redis:8-alpine
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis-data:/data
command: ["redis-server", "--appendonly", "yes"]
@@ -15,7 +13,7 @@ services:
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
POSTGRES_DB: ${DB_NAME:-postgres}
ports:
- "${DB_PORT:-5432}:5432"
- "127.0.0.1:${DB_PORT:-5432}:5432"
volumes:
- db_data:/var/lib/postgresql/data
app:

View File

@@ -13,6 +13,7 @@ export default function Home() {
const [url, setUrl] = useState("");
const [expiryTime, setExpiryTime] = useState(0);
const [isLoading, setIsLoading] = useState(true);
const [notFound, setNotFound] = useState(false);
const initData = useRawInitData();
const onCopyClick = async () => {
if (!url.length) return;
@@ -32,12 +33,24 @@ export default function Home() {
setIsLoading(false);
} catch (e) {
console.error(e);
setNotFound(true);
setIsLoading(false);
}
};
fetchData();
}, [initData]);
if (isLoading) return <Loader />;
if (notFound) {
return (
<Page back={false}>
<main className="absolute bottom-0 left-0 flex w-full flex-col items-center gap-3 px-2.5 py-3.5 text-[var(--tg-theme-text-color)]">
<Block name="Ссылка">Ссылка не найдена</Block>
</main>
</Page>
);
}
return (
<Page back={false}>
<header className="flex h-12 w-full flex-col items-center justify-center bg-[var(--tg-theme-header-bg-color)]">