9 Commits

Author SHA1 Message Date
447ea1c761 fix: use serve temporarily to regenerate dist based on user's .env
All checks were successful
Build and push Docker image / build (push) Successful in 33s
Release new version / release (push) Successful in 27s
Update changelog / changelog (push) Successful in 25s
2026-01-21 00:50:28 +01:00
89b332f620 fix: typo in Dockerfile
All checks were successful
Update changelog / changelog (push) Successful in 26s
2026-01-20 22:19:43 +01:00
f2948eeebe fix: workaround npm multi-platform build bug
Some checks failed
Build and push Docker image / build (push) Failing after 1m26s
Update changelog / changelog (push) Has been cancelled
Release new version / release (push) Has been cancelled
rolls back build CI/CD to ARM64-only
2026-01-20 22:14:03 +01:00
Pc
0afbdaf7f8 feat: duration time based expiry date for links
All checks were successful
Update changelog / changelog (push) Successful in 27s
2026-01-19 17:22:31 +01:00
Pc
efc2861ab4 fix: subdomain support, expiry date fix
All checks were successful
Update changelog / changelog (push) Successful in 26s
2026-01-09 22:40:43 +01:00
18e7baa73c fix: introduce workaround for cross-platform docker image building
Some checks failed
Build and push Docker image / build (push) Failing after 3m59s
Release new version / release (push) Successful in 28s
Update changelog / changelog (push) Successful in 26s
2026-01-09 22:29:17 +01:00
c829cb2a6b fix: docker packages and IP parsing for 127.0.0.1
Some checks failed
Release new version / release (push) Successful in 27s
Update changelog / changelog (push) Successful in 26s
Build and push Docker image / build (push) Failing after 3m57s
2026-01-09 21:55:46 +01:00
Pc
9cba46e427 fix: optimized size of kitty photos
All checks were successful
Update changelog / changelog (push) Successful in 26s
2026-01-09 14:48:37 +01:00
7beb46606f Updated readme with the current state of app
All checks were successful
Update changelog / changelog (push) Successful in 25s
2026-01-07 23:52:13 +01:00
13 changed files with 308 additions and 148 deletions

View File

@@ -1 +1,3 @@
.env .env
kittyurl-frontend/node_modules
kittyurl-frontend/dist

View File

@@ -17,12 +17,6 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
- name: Login to registry - name: Login to registry
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
@@ -30,28 +24,22 @@ jobs:
username: ${{ secrets.REGISTRY_USER }} username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Set outputs - name: Build Docker image
id: vars
env: env:
BRANCH_NAME: ${{ github.ref_name }} REF_NAME: ${{ github.ref_name }}
run: | run: |
#echo branch_name="$BRANCH_NAME" | tee -a $GITHUB_OUTPUT # Build the image with the commit hash tag
#echo short_hash=$(git rev-parse --short HEAD) | tee -a $GITHUB_OUTPUT docker build --build-arg BUILD_IDENTIFIER=${REF_NAME} -t gitea.7o7.cx/kittyteam/kittyfe:master-${REF_NAME} .
echo current_tag=$GITHUB_REF_NAME | tee -a $GITHUB_OUTPUT
- name: Build and push # Tag the same image as "latest"
uses: docker/build-push-action@v6 docker tag gitea.7o7.cx/kittyteam/kittyfe:master-${REF_NAME} gitea.7o7.cx/kittyteam/kittyfe:latest
with:
context: . - name: Push Docker images
platforms: | env:
linux/amd64 REF_NAME: ${{ github.ref_name }}
linux/arm64 run: |
pull: true docker push gitea.7o7.cx/kittyteam/kittyfe:master-${REF_NAME}
push: true docker push gitea.7o7.cx/kittyteam/kittyfe:latest
# Change when working on a different branch!
tags: |
gitea.7o7.cx/kittyteam/kittyfe:${{ steps.vars.outputs.current_tag }}
gitea.7o7.cx/kittyteam/kittyfe:latest
- name: Log out from registry - name: Log out from registry
if: always() if: always()

View File

@@ -1,11 +1,17 @@
# Credit: https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker # Credit:
# https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker
# https://stackoverflow.com/a/56941391
#
# Includes workaround for:
# https://github.com/expo/expo/issues/33340
# https://github.com/npm/cli/issues/4828
FROM node:24-trixie-slim AS builder FROM node:24-trixie-slim AS builder
WORKDIR /app WORKDIR /app
COPY ./kittyurl-frontend/package*.json ./ COPY ./kittyurl-frontend/package*.json ./
RUN npm ci && npm cache clean --force RUN npm ci && npm i --force && npm cache clean --force
COPY ./kittyurl-frontend/ . COPY ./kittyurl-frontend/. ./
RUN npm run build RUN npm run build
FROM node:24-trixie-slim AS production FROM node:24-trixie-slim AS production
@@ -18,4 +24,7 @@ USER nodejs
EXPOSE 6568 EXPOSE 6568
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "6568"] # Since we don't know user's .env ahead of time, kittyFE needs to
# rebuild itself every launch so that the changes in .env get reflected.
# This is not ideal and we're looking into possible ways to improve this.
CMD ["npm", "run", "serve", "--", "--host", "0.0.0.0", "--port", "6568"]

View File

@@ -1,2 +1,73 @@
# kittyFE # kittyFE
*Front-end for the [KittyURL](https://gitea.7o7.cx/kittyteam/kittyurl) project — create short and memorable URLs with ease!*
## Goals
Provide a responsive and modern user interface for:
* Account management (login, register, history, settings)
* Link creation (public landing page)
* Dashboard link management (for logged-in users)
* User management (admin panel)
KittyFE is built with **Vite + React (TypeScript)** to integrate seamlessly with [kittyBE](https://gitea.7o7.cx/kittyteam/kittyBE) and is easily dockerizable.
## Running kittyFE
KittyFE has been verified to work on **Node v24.11.1**.
### On bare metal
Running the front-end is as simple as:
1. **Install dependencies**
* To download the required dependencies:
```sh
npm install
```
* To install an exact copy of all dependencies (recommended for CI):
```sh
npm ci
```
2. **Configure environment variables**
Copy the `.env.example` file to `.env` and customize it to your preferences.
**Example:** Tell the frontend where the backend API is located. Your `.env` file should look like this:
```properties
VITE_API_TARGET=http://localhost:6567
```
> **Important:** All environment variables exposed to Vite must start with `VITE_`. Make sure the URL matches your running instance of `kittyBE`.
3. **Launch the development server**
```sh
npm run dev
```
4. **Open the app**
Visit:
```text
http://localhost:6568
```
(or the port shown in your terminal output).
### Building for production
To create an optimized static production build:
```sh
npm run build
```

View File

@@ -2,18 +2,18 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/kitty.png" /> <link rel="icon" type="image/svg+xml" href="/src/assets/kitty.jpg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>kittyurl - shorten URLs with ease</title> <title>kittyurl - shorten URLs with ease</title>
<meta property="og:title" content="kittyurl shortener" /> <meta property="og:title" content="kittyurl shortener" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:description" content="Your go-to place for short and memorable URLs." /> <meta property="og:description" content="Your go-to place for short and memorable URLs." />
<meta property="og:image" content="/src/assets/Ket.png" /> <meta property="og:image" content="/src/assets/Ket.jpg" />
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="kittyurl shortener" /> <meta name="twitter:title" content="kittyurl shortener" />
<meta name="twitter:description" content="Your go-to place for short and memorable URLs." /> <meta name="twitter:description" content="Your go-to place for short and memorable URLs." />
<meta name="twitter:image" content="/src/assets/Ket.png" /> <meta name="twitter:image" content="/src/assets/Ket.jpg" />
</head> </head>

View File

@@ -29,6 +29,7 @@
"eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24", "eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0", "globals": "^16.5.0",
"lightningcss": "^1.30.2",
"postcss": "^8.5.6", "postcss": "^8.5.6",
"tailwindcss": "^4.1.18", "tailwindcss": "^4.1.18",
"typescript": "~5.9.3", "typescript": "~5.9.3",
@@ -67,7 +68,6 @@
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.27.1", "@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.5", "@babel/generator": "^7.28.5",
@@ -1610,7 +1610,6 @@
"integrity": "sha512-vnDVpYPMzs4wunl27jHrfmwojOGKya0xyM3sH+UE5iv5uPS6vX7UIoh6m+vQc5LGBq52HBKPIn/zcSZVzeDEZg==", "integrity": "sha512-vnDVpYPMzs4wunl27jHrfmwojOGKya0xyM3sH+UE5iv5uPS6vX7UIoh6m+vQc5LGBq52HBKPIn/zcSZVzeDEZg==",
"devOptional": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"undici-types": "~7.16.0" "undici-types": "~7.16.0"
} }
@@ -1621,7 +1620,6 @@
"integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==", "integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"csstype": "^3.2.2" "csstype": "^3.2.2"
} }
@@ -1681,7 +1679,6 @@
"integrity": "sha512-hM5faZwg7aVNa819m/5r7D0h0c9yC4DUlWAOvHAtISdFTc8xB86VmX5Xqabrama3wIPJ/q9RbGS1worb6JfnMg==", "integrity": "sha512-hM5faZwg7aVNa819m/5r7D0h0c9yC4DUlWAOvHAtISdFTc8xB86VmX5Xqabrama3wIPJ/q9RbGS1worb6JfnMg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "8.50.1", "@typescript-eslint/scope-manager": "8.50.1",
"@typescript-eslint/types": "8.50.1", "@typescript-eslint/types": "8.50.1",
@@ -1933,7 +1930,6 @@
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
}, },
@@ -2093,7 +2089,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"baseline-browser-mapping": "^2.9.0", "baseline-browser-mapping": "^2.9.0",
"caniuse-lite": "^1.0.30001759", "caniuse-lite": "^1.0.30001759",
@@ -2442,7 +2437,6 @@
"integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.1", "@eslint-community/regexpp": "^4.12.1",
@@ -3598,7 +3592,6 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@@ -3625,7 +3618,6 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"nanoid": "^3.3.11", "nanoid": "^3.3.11",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
@@ -3673,7 +3665,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz",
"integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==",
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
@@ -3683,7 +3674,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz",
"integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"scheduler": "^0.27.0" "scheduler": "^0.27.0"
}, },
@@ -3702,9 +3692,9 @@
} }
}, },
"node_modules/react-router": { "node_modules/react-router": {
"version": "7.11.0", "version": "7.12.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.11.0.tgz", "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.12.0.tgz",
"integrity": "sha512-uI4JkMmjbWCZc01WVP2cH7ZfSzH91JAZUDd7/nIprDgWxBV1TkkmLToFh7EbMTcMak8URFRa2YoBL/W8GWnCTQ==", "integrity": "sha512-kTPDYPFzDVGIIGNLS5VJykK0HfHLY5MF3b+xj0/tTyNYL1gF1qs7u67Z9jEhQk2sQ98SUaHxlG31g1JtF7IfVw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"cookie": "^1.0.1", "cookie": "^1.0.1",
@@ -3724,12 +3714,12 @@
} }
}, },
"node_modules/react-router-dom": { "node_modules/react-router-dom": {
"version": "7.11.0", "version": "7.12.0",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.11.0.tgz", "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.12.0.tgz",
"integrity": "sha512-e49Ir/kMGRzFOOrYQBdoitq3ULigw4lKbAyKusnvtDu2t4dBX4AGYPrzNvorXmVuOyeakai6FUPW5MmibvVG8g==", "integrity": "sha512-pfO9fiBcpEfX4Tx+iTYKDtPbrSLLCbwJ5EqP+SPYQu1VYCXdy79GSj0wttR0U4cikVdlImZuEZ/9ZNCgoaxwBA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"react-router": "7.11.0" "react-router": "7.12.0"
}, },
"engines": { "engines": {
"node": ">=20.0.0" "node": ">=20.0.0"
@@ -3937,7 +3927,6 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@@ -4023,7 +4012,6 @@
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz",
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==", "integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.27.0", "esbuild": "^0.27.0",
"fdir": "^6.5.0", "fdir": "^6.5.0",
@@ -4145,7 +4133,6 @@
"integrity": "sha512-0wZ1IRqGGhMP76gLqz8EyfBXKk0J2qo2+H3fi4mcUP/KtTocoX08nmIAHl1Z2kJIZbZee8KOpBCSNPRgauucjw==", "integrity": "sha512-0wZ1IRqGGhMP76gLqz8EyfBXKk0J2qo2+H3fi4mcUP/KtTocoX08nmIAHl1Z2kJIZbZee8KOpBCSNPRgauucjw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"funding": { "funding": {
"url": "https://github.com/sponsors/colinhacks" "url": "https://github.com/sponsors/colinhacks"
} }

View File

@@ -32,6 +32,7 @@
"eslint-plugin-react-hooks": "^7.0.1", "eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24", "eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0", "globals": "^16.5.0",
"lightningcss": "^1.30.2",
"postcss": "^8.5.6", "postcss": "^8.5.6",
"tailwindcss": "^4.1.18", "tailwindcss": "^4.1.18",
"typescript": "~5.9.3", "typescript": "~5.9.3",

View File

@@ -11,6 +11,13 @@ export type View = 'home' | 'login' | 'history' | 'jump-game' | 'flappy-game';
const getSubdomain = () => { const getSubdomain = () => {
const hostname = window.location.hostname; const hostname = window.location.hostname;
// Handle localhost and 127.0.0.1 cases.
// For more advanced cases (like bare IP hosting)
// a regex may be necessary.
if (hostname === 'localhost' || hostname === '127.0.0.1') {
return null;
}
const parts = hostname.split('.'); const parts = hostname.split('.');
if (parts.length <= 2) return null; if (parts.length <= 2) return null;
return parts[0]; return parts[0];

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 MiB

View File

@@ -1,19 +1,25 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { import {
PawPrint, Heart, Sparkles, Cat, Hash, PawPrint, Heart, Sparkles, Cat, Hash,
Globe, BookOpen, Shield, Calendar, Globe, BookOpen, Shield, Clock,
Settings2, AlertCircle, X, Save, RefreshCw, Copy, Check, ExternalLink, User as UserIcon Settings2, AlertCircle, X, Save, RefreshCw, Copy, Check, ExternalLink,
User as UserIcon, Calendar, Hourglass
} from 'lucide-react'; } from 'lucide-react';
// Pobieramy adres API
const API_BASE = import.meta.env.VITE_API_TARGET; const API_BASE = import.meta.env.VITE_API_TARGET;
// Nazwa klucza w localStorage
const TOKEN_KEY = 'jwt_token'; const TOKEN_KEY = 'jwt_token';
type CaseType = 'upper' | 'lower' | 'mixed'; type CaseType = 'upper' | 'lower' | 'mixed';
// 1. Definicja propsów, które przychodzą z App.tsx // Mnożniki czasu w milisekundach
const TIME_MULTIPLIERS: Record<string, number> = {
minutes: 60 * 1000,
hours: 60 * 60 * 1000,
days: 24 * 60 * 60 * 1000,
weeks: 7 * 24 * 60 * 60 * 1000,
months: 30 * 24 * 60 * 60 * 1000, // Przybliżenie
};
interface GeneratorProps { interface GeneratorProps {
url: string; url: string;
setUrl: (url: string) => void; setUrl: (url: string) => void;
@@ -27,7 +33,6 @@ interface GeneratorSettings {
withSubdomain: boolean; withSubdomain: boolean;
} }
// Usunęliśmy 'remoteUrl' stąd, bo teraz przychodzi z propsów (url)
interface LinkFormData { interface LinkFormData {
uri: string; uri: string;
subdomain: string; subdomain: string;
@@ -40,7 +45,7 @@ interface LinkPayload {
uri: string; uri: string;
subdomain?: string; subdomain?: string;
privacy: boolean; privacy: boolean;
expiryDate: number; expiryDate?: number;
userId?: string; userId?: string;
} }
@@ -50,16 +55,14 @@ interface User {
email?: string; email?: string;
} }
// 2. Dodajemy propsy do argumentów funkcji
export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate }) => { export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate }) => {
const [user, setUser] = useState<User | null>(null); const [user, setUser] = useState<User | null>(null);
// Stan formularza (bez remoteUrl, bo to jest teraz w 'url')
const [formData, setFormData] = useState<LinkFormData>({ const [formData, setFormData] = useState<LinkFormData>({
uri: '', uri: '',
subdomain: '', subdomain: '',
privacy: true, privacy: true,
expiryDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0] expiryDate: ''
}); });
const [genSettings, setGenSettings] = useState<GeneratorSettings>({ const [genSettings, setGenSettings] = useState<GeneratorSettings>({
@@ -69,12 +72,22 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
withSubdomain: false withSubdomain: false
}); });
// --- NOWE STANY DLA CZASU TRWANIA ---
const [expiryMode, setExpiryMode] = useState<'date' | 'duration'>('date');
const [durationValue, setDurationValue] = useState<string>(''); // Pusty string na start
const [durationUnit, setDurationUnit] = useState<string>('minutes');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [generatingUri, setGeneratingUri] = useState(false); const [generatingUri, setGeneratingUri] = useState(false);
const [errorMsg, setErrorMsg] = useState<string | null>(null); const [errorMsg, setErrorMsg] = useState<string | null>(null);
const [result, setResult] = useState<string | null>(null); const [result, setResult] = useState<string | null>(null);
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
const baseDomain = API_BASE.replace('api.', '').replace(/^https?:\/\//, '').split('/')[0];
const displayPrefix = genSettings.withSubdomain && formData.subdomain
? `${formData.subdomain}.${baseDomain}`
: baseDomain;
const getAuthHeaders = () => { const getAuthHeaders = () => {
const token = localStorage.getItem(TOKEN_KEY); const token = localStorage.getItem(TOKEN_KEY);
return { return {
@@ -83,17 +96,14 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
}; };
}; };
// Sprawdzenie sesji użytkownika
useEffect(() => { useEffect(() => {
const checkUser = async () => { const checkUser = async () => {
const token = localStorage.getItem(TOKEN_KEY); const token = localStorage.getItem(TOKEN_KEY);
if (!token) return; if (!token) return;
try { try {
const res = await fetch(`${API_BASE}/api/v1/user/account`, { const res = await fetch(`${API_BASE}/api/v1/user/account`, {
headers: getAuthHeaders() headers: getAuthHeaders()
}); });
if (res.ok) { if (res.ok) {
const data = await res.json(); const data = await res.json();
setUser({ setUser({
@@ -101,10 +111,6 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
username: data.username || data.name || data.email || "User", username: data.username || data.name || data.email || "User",
email: data.email email: data.email
}); });
} else {
console.log("Session expired. Logging out.");
localStorage.removeItem(TOKEN_KEY);
setUser(null);
} }
} catch { } catch {
console.log("API unreachable"); console.log("API unreachable");
@@ -113,35 +119,51 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
checkUser(); checkUser();
}, []); }, []);
// --- NOWY EFEKT: Przeliczanie czasu trwania na datę ---
// Uruchamia się automatycznie, gdy zmienisz liczbę, jednostkę lub tryb
useEffect(() => {
if (expiryMode === 'duration') {
const val = parseInt(durationValue);
if (!durationValue || isNaN(val) || val <= 0) {
// Jeśli pole jest puste lub 0, czyścimy datę wygaśnięcia
setFormData(prev => ({ ...prev, expiryDate: '' }));
return;
}
const multiplier = TIME_MULTIPLIERS[durationUnit] || TIME_MULTIPLIERS.minutes;
const msToAdd = val * multiplier;
const futureDate = new Date(Date.now() + msToAdd);
// Formatowanie do datetime-local z uwzględnieniem strefy czasowej
const offset = futureDate.getTimezoneOffset() * 60000;
const localISOTime = new Date(futureDate.getTime() - offset).toISOString().slice(0, 16);
setFormData(prev => ({ ...prev, expiryDate: localISOTime }));
}
}, [durationValue, durationUnit, expiryMode]);
const handleGenerateUri = async (type: 'random' | 'wordlist') => { const handleGenerateUri = async (type: 'random' | 'wordlist') => {
setGeneratingUri(true); setGeneratingUri(true);
setErrorMsg(null); setErrorMsg(null);
try { try {
let endpoint = ''; let endpoint = '';
const params = new URLSearchParams(); const params = new URLSearchParams();
params.append('withSubdomain', genSettings.withSubdomain.toString()); params.append('withSubdomain', genSettings.withSubdomain.toString());
if (type === 'random') { if (type === 'random') {
endpoint = '/api/v1/link/short'; endpoint = '/api/v1/link/short';
params.append('length', genSettings.length.toString()); params.append('length', genSettings.length.toString());
params.append('alphanum', genSettings.alphanum.toString()); params.append('alphanum', genSettings.alphanum.toString());
if (genSettings.case !== 'mixed') params.append('case', genSettings.case);
if (genSettings.case !== 'mixed') {
params.append('case', genSettings.case);
}
} else { } else {
endpoint = '/api/v1/link/fromWordlist'; endpoint = '/api/v1/link/fromWordlist';
} }
const response = await fetch(`${API_BASE}${endpoint}?${params.toString()}`); const response = await fetch(`${API_BASE}${endpoint}?${params.toString()}`);
const data = await response.json(); const data = await response.json();
if (!response.ok) throw new Error(data.error || 'Generation failed'); if (!response.ok) throw new Error(data.error || 'Generation failed');
setFormData(prev => ({ ...prev, uri: data.uri || data.shortUrl || "" }));
const generatedUri = data.uri || data.shortUrl || data.link || "";
setFormData(prev => ({ ...prev, uri: generatedUri }));
} catch (err: unknown) { } catch (err: unknown) {
if (err instanceof Error) setErrorMsg(err.message); if (err instanceof Error) setErrorMsg(err.message);
} finally { } finally {
@@ -150,7 +172,6 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
}; };
const handleSubmitToDb = async () => { const handleSubmitToDb = async () => {
// Używamy propsa 'url' zamiast formData.remoteUrl
if (!url) { if (!url) {
setErrorMsg("Meow! I need a destination URL first! 🐾"); setErrorMsg("Meow! I need a destination URL first! 🐾");
return; return;
@@ -166,17 +187,21 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
try { try {
const payload: LinkPayload = { const payload: LinkPayload = {
remoteUrl: url, // <-- Tutaj wstawiamy wartość z propsa remoteUrl: url,
uri: formData.uri, uri: formData.uri,
subdomain: formData.subdomain || undefined,
privacy: formData.privacy, privacy: formData.privacy,
expiryDate: new Date(formData.expiryDate).getTime()
}; };
if (user && user.id) { if (genSettings.withSubdomain && formData.subdomain) {
payload.userId = user.id; payload.subdomain = formData.subdomain;
} }
if (formData.expiryDate) {
payload.expiryDate = new Date(formData.expiryDate).getTime();
}
if (user?.id) payload.userId = user.id;
const response = await fetch(`${API_BASE}/api/v1/link/new`, { const response = await fetch(`${API_BASE}/api/v1/link/new`, {
method: 'POST', method: 'POST',
headers: getAuthHeaders(), headers: getAuthHeaders(),
@@ -184,20 +209,19 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
}); });
const data = await response.json(); const data = await response.json();
if (!response.ok) throw new Error(data.error || `Error ${response.status}`);
if (!response.ok) { let finalLink = data.url;
throw new Error(data.error || `Database error ${response.status}`); if (!finalLink) {
const protocol = API_BASE.startsWith('https') ? 'https://' : 'http://';
finalLink = `${protocol}${displayPrefix}/${formData.uri}`;
} }
const finalLink = data.url || `${API_BASE.replace('api.', '')}/${formData.uri}`;
setResult(finalLink); setResult(finalLink);
// Wywołujemy callback z App.tsx (np. żeby pokazać powiadomienie)
onGenerate(); onGenerate();
} catch (err: unknown) { } catch (err: unknown) {
if (err instanceof Error) setErrorMsg(err.message); if (err instanceof Error) setErrorMsg(err.message);
else setErrorMsg("Something went wrong saving to DB!"); else setErrorMsg("Something went wrong!");
} finally { } finally {
setLoading(false); setLoading(false);
} }
@@ -210,14 +234,13 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
}; };
return ( return (
<div className="max-w-[800px] mx-auto pt-10 px-4 flex flex-col items-center pb-20"> <div className="max-w-[800px] mx-auto pt-10 px-4 flex flex-col items-center pb-20 font-sans">
{/* Header */} {/* Header */}
<header className="text-center mb-8 relative w-full flex flex-col items-center"> <header className="text-center mb-8 relative w-full flex flex-col items-center">
<div className={`mb-4 px-4 py-2 rounded-full text-xs font-bold flex items-center gap-2 transition-colors ${user ? 'bg-pink-100 text-pink-600' : 'bg-gray-100 text-gray-400'}`}> <div className={`mb-4 px-4 py-2 rounded-full text-xs font-bold flex items-center gap-2 transition-colors ${user ? 'bg-pink-100 text-pink-600' : 'bg-gray-100 text-gray-400'}`}>
<UserIcon size={14} /> <UserIcon size={14} />
{user ? `Logged in as ${user.username}` : 'Guest Mode (Anonymous)'} {user ? `Logged in as ${user.username}` : 'Guest Mode (Anonymous)'}
</div> </div>
<h1 className="text-4xl sm:text-6xl font-black text-pink-500 mb-2 tracking-tighter flex items-center justify-center gap-2"> <h1 className="text-4xl sm:text-6xl font-black text-pink-500 mb-2 tracking-tighter flex items-center justify-center gap-2">
KittyURL <PawPrint className="w-8 h-8 sm:w-10 sm:h-10" fill="currentColor" /> KittyURL <PawPrint className="w-8 h-8 sm:w-10 sm:h-10" fill="currentColor" />
</h1> </h1>
@@ -230,7 +253,7 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
<div className="bg-red-50 border-2 border-red-200 p-4 rounded-2xl flex items-center gap-3 text-red-600 shadow-lg"> <div className="bg-red-50 border-2 border-red-200 p-4 rounded-2xl flex items-center gap-3 text-red-600 shadow-lg">
<AlertCircle size={20} /> <AlertCircle size={20} />
<span className="font-bold text-sm flex-1">{errorMsg}</span> <span className="font-bold text-sm flex-1">{errorMsg}</span>
<button onClick={() => setErrorMsg(null)}><X size={20} className="hover:scale-110 transition-transform" /></button> <button onClick={() => setErrorMsg(null)}><X size={20} /></button>
</div> </div>
</div> </div>
)} )}
@@ -258,7 +281,6 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
</div> </div>
)} )}
{/* Main Form */}
<div className="w-full bg-white rounded-[2.5rem] shadow-2xl shadow-pink-200/50 p-6 sm:p-8 border-4 border-white"> <div className="w-full bg-white rounded-[2.5rem] shadow-2xl shadow-pink-200/50 p-6 sm:p-8 border-4 border-white">
{/* 1. Destination URL */} {/* 1. Destination URL */}
@@ -271,8 +293,8 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
type="url" type="url"
placeholder="https://very-long-link.com/..." placeholder="https://very-long-link.com/..."
className="w-full p-4 bg-pink-50/30 border-2 border-pink-100 rounded-2xl outline-none focus:border-pink-400 focus:bg-white transition-all text-pink-600 font-medium pr-12" className="w-full p-4 bg-pink-50/30 border-2 border-pink-100 rounded-2xl outline-none focus:border-pink-400 focus:bg-white transition-all text-pink-600 font-medium pr-12"
value={url} // Używamy propsa value={url}
onChange={(e) => setUrl(e.target.value)} // Używamy propsa onChange={(e) => setUrl(e.target.value)}
/> />
<Heart className="absolute right-4 top-1/2 -translate-y-1/2 text-pink-200 w-5 h-5 group-focus-within:text-pink-400 transition-colors" /> <Heart className="absolute right-4 top-1/2 -translate-y-1/2 text-pink-200 w-5 h-5 group-focus-within:text-pink-400 transition-colors" />
</div> </div>
@@ -283,7 +305,6 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
<label className="flex items-center gap-2 text-[11px] font-black uppercase tracking-widest text-pink-400 mb-3 ml-1"> <label className="flex items-center gap-2 text-[11px] font-black uppercase tracking-widest text-pink-400 mb-3 ml-1">
<Sparkles size={12} /> 2. Generate Short Code (URI) <Sparkles size={12} /> 2. Generate Short Code (URI)
</label> </label>
<div className="grid grid-cols-2 sm:grid-cols-4 gap-2 mb-4"> <div className="grid grid-cols-2 sm:grid-cols-4 gap-2 mb-4">
<div className="bg-white p-2 rounded-xl border border-pink-100"> <div className="bg-white p-2 rounded-xl border border-pink-100">
<label className="text-[9px] font-bold text-gray-400 uppercase block mb-1">Length</label> <label className="text-[9px] font-bold text-gray-400 uppercase block mb-1">Length</label>
@@ -292,43 +313,34 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
</div> </div>
<div className="bg-white p-2 rounded-xl border border-pink-100"> <div className="bg-white p-2 rounded-xl border border-pink-100">
<label className="text-[9px] font-bold text-gray-400 uppercase block mb-1">Case</label> <label className="text-[9px] font-bold text-gray-400 uppercase block mb-1">Case</label>
<select <select className="w-full font-bold text-pink-500 outline-none text-sm bg-transparent"
className="w-full font-bold text-pink-500 outline-none text-sm bg-transparent" value={genSettings.case} onChange={e => setGenSettings({ ...genSettings, case: e.target.value as CaseType })}>
value={genSettings.case}
onChange={e => setGenSettings({ ...genSettings, case: e.target.value as CaseType })}
>
<option value="mixed">Mixed</option> <option value="mixed">Mixed</option>
<option value="lower">Lower</option> <option value="lower">Lower</option>
<option value="upper">Upper</option> <option value="upper">Upper</option>
</select> </select>
</div> </div>
<button <button onClick={() => handleGenerateUri('random')} className="col-span-2 sm:col-span-1 bg-white hover:bg-pink-100 border-2 border-pink-200 text-pink-500 rounded-xl font-bold text-xs py-2 transition-all active:scale-95 flex flex-col items-center justify-center gap-1">
onClick={() => handleGenerateUri('random')} <Hash size={16} /> {generatingUri ? '...' : 'Random'}
disabled={generatingUri}
className="col-span-2 sm:col-span-1 bg-white hover:bg-pink-100 border-2 border-pink-200 text-pink-500 rounded-xl font-bold text-xs flex flex-col items-center justify-center gap-1 transition-all active:scale-95 py-2"
>
<Hash size={16} />
{generatingUri ? '...' : 'Random'}
</button> </button>
<button <button onClick={() => handleGenerateUri('wordlist')} className="col-span-2 sm:col-span-1 bg-white hover:bg-pink-100 border-2 border-pink-200 text-pink-500 rounded-xl font-bold text-xs py-2 transition-all active:scale-95 flex flex-col items-center justify-center gap-1">
onClick={() => handleGenerateUri('wordlist')} <BookOpen size={16} /> {generatingUri ? '...' : 'Sentence'}
disabled={generatingUri}
className="col-span-2 sm:col-span-1 bg-white hover:bg-pink-100 border-2 border-pink-200 text-pink-500 rounded-xl font-bold text-xs flex flex-col items-center justify-center gap-1 transition-all active:scale-95 py-2"
>
<BookOpen size={16} />
{generatingUri ? '...' : 'Sentence'}
</button> </button>
</div> </div>
<div className="relative"> <div className="relative flex items-center">
<div className="absolute left-4 flex items-center pointer-events-none z-10">
<span className="text-pink-300 font-bold text-sm sm:text-lg">{displayPrefix}</span>
<span className="text-pink-400 font-black text-lg mx-1">/</span>
</div>
<input <input
type="text" type="text"
placeholder="my-custom-uri" placeholder="my-custom-uri"
className="w-full p-4 pl-12 bg-white border-2 border-pink-200 rounded-2xl outline-none focus:border-pink-500 transition-all text-pink-600 font-black text-lg shadow-inner" style={{ paddingLeft: `${displayPrefix.length * 9.5 + 40}px` }}
className="w-full p-4 bg-white border-2 border-pink-200 rounded-2xl outline-none focus:border-pink-500 transition-all text-pink-600 font-black text-lg shadow-inner"
value={formData.uri} value={formData.uri}
onChange={(e) => setFormData({ ...formData, uri: e.target.value })} onChange={(e) => setFormData({ ...formData, uri: e.target.value })}
/> />
<div className="absolute left-4 top-1/2 -translate-y-1/2 text-pink-300 font-bold select-none">/</div>
{formData.uri && ( {formData.uri && (
<div className="absolute right-4 top-1/2 -translate-y-1/2"> <div className="absolute right-4 top-1/2 -translate-y-1/2">
<Check size={18} className="text-green-500" /> <Check size={18} className="text-green-500" />
@@ -338,12 +350,75 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
</div> </div>
{/* 3. Database Settings */} {/* 3. Database Settings */}
<div className="mb-8 grid grid-cols-1 sm:grid-cols-2 gap-4"> <div className="mb-8 flex flex-col gap-4">
<div className="bg-gray-50 p-4 rounded-2xl border border-gray-100"> <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<label className="flex items-center gap-2 text-[10px] font-black uppercase text-gray-400 mb-2"><Calendar size={14} /> Expiry Date</label>
<input type="date" className="w-full bg-white border border-gray-200 rounded-lg px-3 py-2 text-xs font-bold text-gray-600 outline-none focus:border-pink-400" {/* ZMODYFIKOWANA SEKCJA: Expiry Date / Custom Duration */}
<div className="bg-gray-50 p-4 rounded-2xl border border-gray-100 flex flex-col">
<div className="flex items-center justify-between mb-2">
<label className="flex items-center gap-2 text-[10px] font-black uppercase text-gray-400">
<Clock size={14} /> Expiry Time
</label>
{/* Przełącznik trybu */}
<div className="flex bg-gray-200 rounded-lg p-0.5">
<button
onClick={() => setExpiryMode('date')}
className={`p-1.5 rounded-md transition-all ${expiryMode === 'date' ? 'bg-white text-pink-500 shadow-sm' : 'text-gray-400 hover:text-gray-600'}`}
>
<Calendar size={14} />
</button>
<button
onClick={() => setExpiryMode('duration')}
className={`p-1.5 rounded-md transition-all ${expiryMode === 'duration' ? 'bg-white text-pink-500 shadow-sm' : 'text-gray-400 hover:text-gray-600'}`}
>
<Hourglass size={14} />
</button>
</div>
</div>
{expiryMode === 'date' ? (
<>
<input
type="datetime-local"
className="w-full bg-white border border-gray-200 rounded-lg px-3 py-3 text-xs font-bold text-gray-600 outline-none focus:border-pink-400 mb-1"
value={formData.expiryDate} value={formData.expiryDate}
onChange={e => setFormData({ ...formData, expiryDate: e.target.value })} /> onChange={e => setFormData({ ...formData, expiryDate: e.target.value })}
/>
<p className="text-[8px] text-gray-400 uppercase pl-1">Pick specific date</p>
</>
) : (
<>
{/* NOWE: Custom Duration Inputs dla Mobile */}
<div className="flex gap-2 mb-1">
<input
type="number"
inputMode="numeric"
pattern="[0-9]*"
placeholder="45"
min="1"
className="w-1/2 bg-white border border-gray-200 rounded-lg px-3 py-3 text-sm font-bold text-pink-500 outline-none focus:border-pink-400 placeholder:text-gray-300 text-center"
value={durationValue}
onChange={(e) => setDurationValue(e.target.value)}
/>
<select
className="w-1/2 bg-white border border-gray-200 rounded-lg px-2 py-3 text-xs font-bold text-gray-600 outline-none focus:border-pink-400"
value={durationUnit}
onChange={(e) => setDurationUnit(e.target.value)}
>
<option value="minutes">Minutes</option>
<option value="hours">Hours</option>
<option value="days">Days</option>
<option value="weeks">Weeks</option>
<option value="months">Months</option>
</select>
</div>
<p className="text-[8px] text-gray-400 uppercase truncate pl-1">
{formData.expiryDate
? `Expires: ${new Date(formData.expiryDate).toLocaleString()}`
: 'Enter duration (e.g. 45 min)'}
</p>
</>
)}
</div> </div>
<label className="flex items-center justify-between bg-gray-50 p-4 rounded-2xl border border-gray-100 cursor-pointer hover:bg-pink-50 transition-colors"> <label className="flex items-center justify-between bg-gray-50 p-4 rounded-2xl border border-gray-100 cursor-pointer hover:bg-pink-50 transition-colors">
@@ -351,22 +426,45 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
<input type="checkbox" className="accent-pink-500 w-5 h-5" checked={formData.privacy} <input type="checkbox" className="accent-pink-500 w-5 h-5" checked={formData.privacy}
onChange={e => setFormData({ ...formData, privacy: e.target.checked })} /> onChange={e => setFormData({ ...formData, privacy: e.target.checked })} />
</label> </label>
</div>
<label className="flex items-center justify-between bg-gray-50 p-4 rounded-2xl border border-gray-100 cursor-pointer hover:bg-pink-50 transition-colors sm:col-span-2"> {/* Subdomain Support Box */}
<div className="bg-gray-50 p-4 rounded-2xl border border-gray-100">
<label className="flex items-center justify-between cursor-pointer mb-2">
<span className="flex items-center gap-2 text-[10px] font-black uppercase text-gray-400"><Globe size={14} /> Subdomain Support</span> <span className="flex items-center gap-2 text-[10px] font-black uppercase text-gray-400"><Globe size={14} /> Subdomain Support</span>
<input type="checkbox" className="accent-pink-500 w-5 h-5" checked={genSettings.withSubdomain} <input
type="checkbox"
className="accent-pink-500 w-5 h-5"
checked={genSettings.withSubdomain}
onChange={e => { onChange={e => {
setGenSettings({ ...genSettings, withSubdomain: e.target.checked }); setGenSettings({ ...genSettings, withSubdomain: e.target.checked });
setFormData({ ...formData, subdomain: e.target.checked ? 'true' : '' }); if (!e.target.checked) setFormData(prev => ({ ...prev, subdomain: '' }));
}} /> }}
/>
</label> </label>
{genSettings.withSubdomain && (
<div className="animate-in slide-in-from-top-2 duration-300 mt-3">
<div className="relative">
<input
type="text"
placeholder="your-subdomain"
className="w-full p-3 bg-white border-2 border-pink-100 rounded-xl outline-none focus:border-pink-400 text-sm font-bold text-pink-600 pr-20"
value={formData.subdomain}
onChange={(e) => setFormData({ ...formData, subdomain: e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, '') })}
/>
<span className="absolute right-3 top-1/2 -translate-y-1/2 text-[10px] font-black text-pink-200">.{baseDomain}</span>
</div>
</div>
)}
</div>
</div> </div>
{/* 4. Submit Button */} {/* 4. Submit Button */}
<button <button
onClick={handleSubmitToDb} onClick={handleSubmitToDb}
disabled={loading} disabled={loading}
className="w-full bg-pink-500 hover:bg-pink-600 text-white font-black py-5 rounded-[1.8rem] transition-all shadow-xl shadow-pink-200 active:scale-[0.98] text-xl flex items-center justify-center gap-3 disabled:opacity-50 disabled:grayscale" className="w-full bg-pink-500 hover:bg-pink-600 text-white font-black py-5 rounded-[1.8rem] transition-all shadow-xl shadow-pink-200 active:scale-[0.98] text-xl flex items-center justify-center gap-3 disabled:opacity-50"
> >
{loading ? ( {loading ? (
<>Saving... <RefreshCw className="animate-spin" /></> <>Saving... <RefreshCw className="animate-spin" /></>
@@ -374,14 +472,11 @@ export const Generator: React.FC<GeneratorProps> = ({ url, setUrl, onGenerate })
<>Save to Database <Save className="w-6 h-6" /></> <>Save to Database <Save className="w-6 h-6" /></>
)} )}
</button> </button>
</div> </div>
<footer className="mt-12 text-center opacity-40"> <footer className="mt-12 text-center opacity-40">
<Cat className="mx-auto text-pink-300 mb-2 w-10 h-10" /> <Cat className="mx-auto text-pink-300 mb-2 w-10 h-10" />
<p className="text-pink-300 font-black text-[10px] uppercase tracking-[0.2em]"> <p className="text-pink-300 font-black text-[10px] uppercase tracking-[0.2em]">KittyURL Generator v2.2</p>
KittyURL Generator v2.0
</p>
</footer> </footer>
</div> </div>
); );