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

@@ -8,4 +8,6 @@ DB_NAME=
DB_PORT= DB_PORT=
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres" DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
BOT_TOKEN= BOT_TOKEN=
REDIS_URL=redis://localhost:6379

View File

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

View File

@@ -13,6 +13,7 @@ export default function Home() {
const [url, setUrl] = useState(""); const [url, setUrl] = useState("");
const [expiryTime, setExpiryTime] = useState(0); const [expiryTime, setExpiryTime] = useState(0);
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [notFound, setNotFound] = useState(false);
const initData = useRawInitData(); const initData = useRawInitData();
const onCopyClick = async () => { const onCopyClick = async () => {
if (!url.length) return; if (!url.length) return;
@@ -32,12 +33,24 @@ export default function Home() {
setIsLoading(false); setIsLoading(false);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
setNotFound(true);
setIsLoading(false);
} }
}; };
fetchData(); fetchData();
}, [initData]); }, [initData]);
if (isLoading) return <Loader />; 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 ( return (
<Page back={false}> <Page back={false}>
<header className="flex h-12 w-full flex-col items-center justify-center bg-[var(--tg-theme-header-bg-color)]"> <header className="flex h-12 w-full flex-col items-center justify-center bg-[var(--tg-theme-header-bg-color)]">