REFACTOR(repo): simplify project structure
- Move services/nextjs to nextjs/ - Move deploy/docker/Dockerfile.prod to Dockerfile - Add GitHub Actions workflows (ci.yml, build.yml) - Remove deploy/, services/, scripts/ folders
This commit is contained in:
12
nextjs/app/home/layout.tsx
Normal file
12
nextjs/app/home/layout.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Navbar } from "@/widgets/landing";
|
||||
|
||||
const MarketingLayout = ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<div className="h-full bg-white dark:bg-[#1F1F1F] space-y-20">
|
||||
<Navbar />
|
||||
<main className="h-full">{children}</main>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MarketingLayout;
|
||||
17
nextjs/app/home/page.tsx
Normal file
17
nextjs/app/home/page.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Heading } from "@/widgets/landing";
|
||||
import { Heroes } from "@/widgets/landing";
|
||||
import { Footer } from "@/widgets/landing";
|
||||
|
||||
const MarketingPage = () => {
|
||||
return (
|
||||
<div className="mt-40 dark:bg-[#1F1F1F] bg-white min-h-full flex flex-col">
|
||||
<div className="flex flex-col items-center justify-center md:justify-start text-center gap-y-8 flex-1 px-6 pb-10">
|
||||
<Heading />
|
||||
<Heroes />
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MarketingPage;
|
||||
161
nextjs/app/home/share/[id]/page.tsx
Normal file
161
nextjs/app/home/share/[id]/page.tsx
Normal file
@@ -0,0 +1,161 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { DocumentSidebar } from '@/widgets/editor/sidebar/document-sidebar';
|
||||
import { RichTextEditor } from '@/widgets/editor/editor/core/rich-text-editor';
|
||||
import { Button } from '@/shared/ui/button';
|
||||
import { ArrowLeft, Copy, Check, Share2, User, Calendar } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import type { Document } from '@/shared/types/document';
|
||||
import { SharedDocumentSkeleton } from '@/shared/ui/skeleton';
|
||||
|
||||
interface SharedDocument extends Document {
|
||||
user: {
|
||||
name: string;
|
||||
email: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function ShareDocumentPage() {
|
||||
const params = useParams();
|
||||
const documentId = params.id as string;
|
||||
|
||||
const [document, setDocument] = useState<SharedDocument | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchDocument = async () => {
|
||||
try {
|
||||
const response = await fetch(`/api/documents/${documentId}/public`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Document not found or not published');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
setDocument(data);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load document');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (documentId) {
|
||||
fetchDocument();
|
||||
}
|
||||
}, [documentId]);
|
||||
|
||||
const getWordCount = (content: any): number => {
|
||||
if (!content) return 0;
|
||||
|
||||
const extractText = (node: any): string => {
|
||||
if (typeof node === 'string') return node;
|
||||
if (node.text) return node.text;
|
||||
if (node.content) {
|
||||
return node.content.map(extractText).join(' ');
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const text = extractText(content);
|
||||
return text.trim().split(/\s+/).filter(word => word.length > 0).length;
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return <SharedDocumentSkeleton />;
|
||||
}
|
||||
|
||||
if (error || !document) {
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 dark:bg-[#1F1F1F] flex items-center justify-center">
|
||||
<div className="text-center max-w-md mx-auto p-6">
|
||||
<div className="text-red-500 dark:text-red-400 text-6xl mb-4">📄</div>
|
||||
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-2">Document Not Found</h1>
|
||||
<p className="text-gray-600 dark:text-gray-400 mb-6">
|
||||
{error || 'This document may not exist or may not be publicly shared.'}
|
||||
</p>
|
||||
<Link href="/">
|
||||
<Button className="bg-blue-600 dark:bg-blue-700 text-white hover:bg-blue-700 dark:hover:bg-blue-800">
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
Go Home
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const wordCount = getWordCount(document.content);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 dark:bg-[#1F1F1F]">
|
||||
{/* Main Content */}
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-4 gap-8">
|
||||
{/* Document Content */}
|
||||
<div className="lg:col-span-3">
|
||||
<div className="bg-white dark:bg-secondary rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 p-8">
|
||||
<div className="prose prose-lg max-w-none dark:prose-invert">
|
||||
<RichTextEditor
|
||||
content={document.content}
|
||||
editable={false}
|
||||
readOnly={true}
|
||||
placeholder=""
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Sidebar */}
|
||||
<div className="lg:col-span-1">
|
||||
<div className="sticky top-24">
|
||||
<DocumentSidebar
|
||||
content={document.content}
|
||||
title={document.title}
|
||||
lastSaved={new Date(document.updatedAt)}
|
||||
wordCount={wordCount}
|
||||
documentId={document.id}
|
||||
/>
|
||||
|
||||
{/* Document Info */}
|
||||
<div className="mt-6 bg-white dark:bg-secondary rounded-lg border border-gray-200 dark:border-gray-700 p-4">
|
||||
<h3 className="font-semibold text-gray-900 dark:text-white mb-3 flex items-center">
|
||||
<User className="h-4 w-4 mr-2" />
|
||||
Document Info
|
||||
</h3>
|
||||
<div className="space-y-2 text-sm text-gray-600 dark:text-gray-400">
|
||||
<div className="flex items-center">
|
||||
<User className="h-4 w-4 mr-2" />
|
||||
<span>Author: {document.user.name}</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<Calendar className="h-4 w-4 mr-2" />
|
||||
<span>Created: {new Date(document.createdAt).toLocaleDateString()}</span>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<Calendar className="h-4 w-4 mr-2" />
|
||||
<span>Updated: {new Date(document.updatedAt).toLocaleDateString()}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="bg-white dark:bg-secondary border-t border-gray-200 dark:border-gray-700 mt-16">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div className="text-center text-gray-500 dark:text-gray-400 text-sm">
|
||||
<p>This document was shared from Jotion</p>
|
||||
<p className="mt-1">
|
||||
Last updated: {new Date(document.updatedAt).toLocaleDateString()}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
116
nextjs/app/home/signIn/page.tsx
Normal file
116
nextjs/app/home/signIn/page.tsx
Normal file
@@ -0,0 +1,116 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { Button } from "@/shared/ui/button"
|
||||
import { Logo } from "@/widgets/landing"
|
||||
import Link from "next/link"
|
||||
import { useAuth } from "@/src/app/providers/auth-provider"
|
||||
|
||||
export default function LoginPage() {
|
||||
const [email, setEmail] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [error, setError] = useState("")
|
||||
const router = useRouter()
|
||||
const { login } = useAuth()
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
setIsLoading(true)
|
||||
setError("")
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/auth/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ email, password }),
|
||||
})
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (response.ok) {
|
||||
// Update auth context with user data
|
||||
login(data.token, data.user)
|
||||
|
||||
// Redirect to documents page
|
||||
router.push("/documents")
|
||||
} else {
|
||||
setError(data.error || "Login failed")
|
||||
}
|
||||
} catch (error) {
|
||||
setError("An error occurred. Please try again.")
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-background">
|
||||
<div className="max-w-md w-full space-y-8 p-8">
|
||||
<div className="text-center">
|
||||
<Logo />
|
||||
<h2 className="mt-6 text-3xl font-bold">Sign in to your account</h2>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
Or{" "}
|
||||
<Link href="/signUp" className="font-medium text-primary hover:underline">
|
||||
create a new account
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form className="mt-8 space-y-6" onSubmit={handleSubmit}>
|
||||
{error && (
|
||||
<div className="bg-destructive/15 text-destructive text-sm p-3 rounded-md">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label htmlFor="email" className="block text-sm font-medium">
|
||||
Email address
|
||||
</label>
|
||||
<input
|
||||
id="email"
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
className="mt-1 block w-full px-3 py-2 border border-input rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
placeholder="Enter your email"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="password" className="block text-sm font-medium">
|
||||
Password
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
className="mt-1 block w-full px-3 py-2 border border-input rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
placeholder="Enter your password"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full"
|
||||
disabled={isLoading}
|
||||
>
|
||||
{isLoading ? "Signing in..." : "Sign in"}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
167
nextjs/app/home/signUp/page.tsx
Normal file
167
nextjs/app/home/signUp/page.tsx
Normal file
@@ -0,0 +1,167 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { Button } from "@/shared/ui/button"
|
||||
import { Logo } from "@/widgets/landing"
|
||||
import Link from "next/link"
|
||||
import { useAuth } from "@/src/app/providers/auth-provider"
|
||||
|
||||
export default function SignupPage() {
|
||||
const [name, setName] = useState("")
|
||||
const [email, setEmail] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [confirmPassword, setConfirmPassword] = useState("")
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [error, setError] = useState("")
|
||||
const router = useRouter()
|
||||
const { login } = useAuth()
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
setIsLoading(true)
|
||||
setError("")
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
setError("Passwords do not match")
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/auth/register", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ name, email, password }),
|
||||
})
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (response.ok) {
|
||||
// Auto login after successful registration
|
||||
const loginResponse = await fetch("/api/auth/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ email, password }),
|
||||
})
|
||||
|
||||
const loginData = await loginResponse.json()
|
||||
|
||||
if (loginResponse.ok) {
|
||||
login(loginData.token, loginData.user)
|
||||
router.push("/documents")
|
||||
} else {
|
||||
router.push("/signIn")
|
||||
}
|
||||
} else {
|
||||
setError(data.error || "Registration failed")
|
||||
}
|
||||
} catch (error) {
|
||||
setError("An error occurred. Please try again.")
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-background">
|
||||
<div className="max-w-md w-full space-y-8 p-8">
|
||||
<div className="text-center">
|
||||
<Logo />
|
||||
<h2 className="mt-6 text-3xl font-bold">Create your account</h2>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
Or{" "}
|
||||
<Link href="/signIn" className="font-medium text-primary hover:underline">
|
||||
sign in to your existing account
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form className="mt-8 space-y-6" onSubmit={handleSubmit}>
|
||||
{error && (
|
||||
<div className="bg-destructive/15 text-destructive text-sm p-3 rounded-md">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label htmlFor="name" className="block text-sm font-medium">
|
||||
Full name
|
||||
</label>
|
||||
<input
|
||||
id="name"
|
||||
name="name"
|
||||
type="text"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
className="mt-1 block w-full px-3 py-2 border border-input rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
placeholder="Enter your full name"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="email" className="block text-sm font-medium">
|
||||
Email address
|
||||
</label>
|
||||
<input
|
||||
id="email"
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
className="mt-1 block w-full px-3 py-2 border border-input rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
placeholder="Enter your email"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="password" className="block text-sm font-medium">
|
||||
Password
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
name="password"
|
||||
type="password"
|
||||
required
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
className="mt-1 block w-full px-3 py-2 border border-input rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
placeholder="Enter your password"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="confirmPassword" className="block text-sm font-medium">
|
||||
Confirm password
|
||||
</label>
|
||||
<input
|
||||
id="confirmPassword"
|
||||
name="confirmPassword"
|
||||
type="password"
|
||||
required
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
className="mt-1 block w-full px-3 py-2 border border-input rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
|
||||
placeholder="Confirm your password"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full"
|
||||
disabled={isLoading}
|
||||
>
|
||||
{isLoading ? "Creating account..." : "Create account"}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user