@fydemy/cms 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs));
6
+ }
@@ -0,0 +1,126 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import { useRouter } from "next/navigation";
5
+ import { Button } from "@/components/ui/button";
6
+ import { Input } from "@/components/ui/input";
7
+ import { Label } from "@/components/ui/label";
8
+ import {
9
+ Card,
10
+ CardContent,
11
+ CardDescription,
12
+ CardHeader,
13
+ CardTitle,
14
+ } from "@/components/ui/card";
15
+
16
+ export default function Login() {
17
+ const [username, setUsername] = useState("");
18
+ const [password, setPassword] = useState("");
19
+ const [error, setError] = useState("");
20
+ const [loading, setLoading] = useState(false);
21
+ const router = useRouter();
22
+
23
+ const handleSubmit = async (e: React.FormEvent) => {
24
+ e.preventDefault();
25
+ setError("");
26
+ setLoading(true);
27
+
28
+ try {
29
+ const response = await fetch("/api/cms/login", {
30
+ method: "POST",
31
+ headers: { "Content-Type": "application/json" },
32
+ body: JSON.stringify({ username, password }),
33
+ });
34
+
35
+ const data = await response.json();
36
+
37
+ if (response.ok) {
38
+ router.push("/admin");
39
+ router.refresh();
40
+ } else {
41
+ setError(data.error || "Login failed");
42
+ }
43
+ } catch (err) {
44
+ setError("An error occurred. Please try again.");
45
+ } finally {
46
+ setLoading(false);
47
+ }
48
+ };
49
+
50
+ return (
51
+ <div className="flex min-h-screen items-center justify-center bg-gray-50 px-4 py-12 sm:px-6 lg:px-8">
52
+ <Card className="w-full max-w-md">
53
+ <CardHeader className="space-y-1">
54
+ <CardTitle className="text-2xl text-center">Admin Login</CardTitle>
55
+ <CardDescription className="text-center">
56
+ Enter your credentials to access the CMS
57
+ </CardDescription>
58
+ </CardHeader>
59
+ <CardContent>
60
+ <form onSubmit={handleSubmit} className="space-y-4">
61
+ <div className="space-y-2">
62
+ <Label htmlFor="username">Username</Label>
63
+ <Input
64
+ id="username"
65
+ name="username"
66
+ type="text"
67
+ required
68
+ placeholder="Admin username"
69
+ value={username}
70
+ onChange={(e) => setUsername(e.target.value)}
71
+ />
72
+ </div>
73
+ <div className="space-y-2">
74
+ <Label htmlFor="password">Password</Label>
75
+ <Input
76
+ id="password"
77
+ name="password"
78
+ type="password"
79
+ required
80
+ placeholder="Password"
81
+ value={password}
82
+ onChange={(e) => setPassword(e.target.value)}
83
+ />
84
+ </div>
85
+
86
+ {error && (
87
+ <div className="rounded-md bg-red-50 p-4 text-sm text-red-700">
88
+ {error}
89
+ </div>
90
+ )}
91
+
92
+ <Button type="submit" disabled={loading} className="w-full">
93
+ {loading ? (
94
+ <span className="flex items-center gap-2">
95
+ <svg
96
+ className="animate-spin h-4 w-4"
97
+ xmlns="http://www.w3.org/2000/svg"
98
+ fill="none"
99
+ viewBox="0 0 24 24"
100
+ >
101
+ <circle
102
+ className="opacity-25"
103
+ cx="12"
104
+ cy="12"
105
+ r="10"
106
+ stroke="currentColor"
107
+ strokeWidth="4"
108
+ ></circle>
109
+ <path
110
+ className="opacity-75"
111
+ fill="currentColor"
112
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
113
+ ></path>
114
+ </svg>
115
+ Logging in...
116
+ </span>
117
+ ) : (
118
+ "Sign in to Dashboard"
119
+ )}
120
+ </Button>
121
+ </form>
122
+ </CardContent>
123
+ </Card>
124
+ </div>
125
+ );
126
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fydemy/cms",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Simple file-based CMS for Next.js without database - with GitHub integration for production",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -65,6 +65,9 @@
65
65
  "@types/react": "^18.3.27",
66
66
  "@types/react-dom": "^18.3.7",
67
67
  "@vitest/coverage-v8": "^1.6.1",
68
+ "autoprefixer": "^10.4.22",
69
+ "postcss": "^8.5.6",
70
+ "tailwindcss": "^4.1.17",
68
71
  "tsup": "^8.0.1",
69
72
  "typescript": "^5.3.3",
70
73
  "vitest": "^1.6.1"