Initial commit: MOPC platform with Docker deployment setup

Full Next.js 15 platform with tRPC, Prisma, PostgreSQL, NextAuth.
Includes production Dockerfile (multi-stage, port 7600), docker-compose
with registry-based image pull, Gitea Actions CI workflow, nginx config
for portal.monaco-opc.com, deployment scripts, and DEPLOYMENT.md guide.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-30 13:41:32 +01:00
commit a606292aaa
290 changed files with 70691 additions and 0 deletions

View File

@@ -0,0 +1,278 @@
'use client'
import { useEffect, useState } from 'react'
import { useRouter, useParams } from 'next/navigation'
import Link from 'next/link'
import { trpc } from '@/lib/trpc/client'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Textarea } from '@/components/ui/textarea'
import { Switch } from '@/components/ui/switch'
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import { Skeleton } from '@/components/ui/skeleton'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog'
import { ArrowLeft, Loader2, Trash2 } from 'lucide-react'
import { toast } from 'sonner'
export default function EditPartnerPage() {
const router = useRouter()
const params = useParams()
const id = params.id as string
const [isSubmitting, setIsSubmitting] = useState(false)
const [formData, setFormData] = useState({
name: '',
description: '',
website: '',
partnerType: 'PARTNER',
visibility: 'ADMIN_ONLY',
isActive: true,
})
const { data: partner, isLoading } = trpc.partner.get.useQuery({ id })
useEffect(() => {
if (partner) {
setFormData({
name: partner.name,
description: partner.description || '',
website: partner.website || '',
partnerType: partner.partnerType,
visibility: partner.visibility,
isActive: partner.isActive,
})
}
}, [partner])
const updatePartner = trpc.partner.update.useMutation({
onSuccess: () => {
toast.success('Partner updated successfully')
router.push('/admin/partners')
},
onError: (error) => {
toast.error(error.message || 'Failed to update partner')
setIsSubmitting(false)
},
})
const deletePartner = trpc.partner.delete.useMutation({
onSuccess: () => {
toast.success('Partner deleted successfully')
router.push('/admin/partners')
},
onError: (error) => {
toast.error(error.message || 'Failed to delete partner')
},
})
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setIsSubmitting(true)
updatePartner.mutate({
id,
name: formData.name,
description: formData.description || null,
website: formData.website || null,
partnerType: formData.partnerType as 'SPONSOR' | 'PARTNER' | 'SUPPORTER' | 'MEDIA' | 'OTHER',
visibility: formData.visibility as 'ADMIN_ONLY' | 'JURY_VISIBLE' | 'PUBLIC',
isActive: formData.isActive,
})
}
// Delete handled via AlertDialog in JSX
if (isLoading) {
return (
<div className="space-y-6">
<div className="flex items-center gap-4">
<Skeleton className="h-10 w-10" />
<div className="space-y-2">
<Skeleton className="h-8 w-48" />
<Skeleton className="h-4 w-32" />
</div>
</div>
<Card>
<CardContent className="space-y-4 pt-6">
<Skeleton className="h-10 w-full" />
<Skeleton className="h-10 w-full" />
<Skeleton className="h-24 w-full" />
</CardContent>
</Card>
</div>
)
}
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="flex items-center gap-4">
<Link href="/admin/partners">
<Button variant="ghost" size="icon">
<ArrowLeft className="h-4 w-4" />
</Button>
</Link>
<div>
<h1 className="text-2xl font-bold">Edit Partner</h1>
<p className="text-muted-foreground">
Update partner information
</p>
</div>
</div>
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive">
<Trash2 className="mr-2 h-4 w-4" />
Delete
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete Partner</AlertDialogTitle>
<AlertDialogDescription>
This will permanently delete this partner. This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={() => deletePartner.mutate({ id })}>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
<Card>
<CardHeader>
<CardTitle>Partner Details</CardTitle>
<CardDescription>
Basic information about the partner organization
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="grid gap-4 md:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="name">Organization Name *</Label>
<Input
id="name"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
required
/>
</div>
<div className="space-y-2">
<Label htmlFor="partnerType">Partner Type</Label>
<Select
value={formData.partnerType}
onValueChange={(value) => setFormData({ ...formData, partnerType: value })}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="SPONSOR">Sponsor</SelectItem>
<SelectItem value="PARTNER">Partner</SelectItem>
<SelectItem value="SUPPORTER">Supporter</SelectItem>
<SelectItem value="MEDIA">Media</SelectItem>
<SelectItem value="OTHER">Other</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea
id="description"
value={formData.description}
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
rows={3}
maxLength={500}
/>
</div>
<div className="grid gap-4 md:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="website">Website</Label>
<Input
id="website"
type="url"
value={formData.website}
onChange={(e) => setFormData({ ...formData, website: e.target.value })}
/>
</div>
</div>
<div className="grid gap-4 md:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="visibility">Visibility</Label>
<Select
value={formData.visibility}
onValueChange={(value) => setFormData({ ...formData, visibility: value })}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="ADMIN_ONLY">Admin Only</SelectItem>
<SelectItem value="JURY_VISIBLE">Visible to Jury</SelectItem>
<SelectItem value="PUBLIC">Public</SelectItem>
</SelectContent>
</Select>
</div>
<div className="flex items-center gap-2 pt-8">
<Switch
id="isActive"
checked={formData.isActive}
onCheckedChange={(checked) => setFormData({ ...formData, isActive: checked })}
/>
<Label htmlFor="isActive">Active</Label>
</div>
</div>
<div className="flex justify-end gap-2 pt-4">
<Link href="/admin/partners">
<Button type="button" variant="outline">
Cancel
</Button>
</Link>
<Button type="submit" disabled={isSubmitting}>
{isSubmitting && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
Save Changes
</Button>
</div>
</form>
</CardContent>
</Card>
</div>
)
}

View File

@@ -0,0 +1,168 @@
'use client'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
import Link from 'next/link'
import { trpc } from '@/lib/trpc/client'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Textarea } from '@/components/ui/textarea'
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import { ArrowLeft, Loader2 } from 'lucide-react'
import { toast } from 'sonner'
export default function NewPartnerPage() {
const router = useRouter()
const [isSubmitting, setIsSubmitting] = useState(false)
const [partnerType, setPartnerType] = useState('PARTNER')
const [visibility, setVisibility] = useState('ADMIN_ONLY')
const createPartner = trpc.partner.create.useMutation({
onSuccess: () => {
toast.success('Partner created successfully')
router.push('/admin/partners')
},
onError: (error) => {
toast.error(error.message || 'Failed to create partner')
setIsSubmitting(false)
},
})
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
setIsSubmitting(true)
const formData = new FormData(e.currentTarget)
const name = formData.get('name') as string
const description = formData.get('description') as string
const website = formData.get('website') as string
createPartner.mutate({
name,
programId: null,
description: description || undefined,
website: website || undefined,
partnerType: partnerType as 'SPONSOR' | 'PARTNER' | 'SUPPORTER' | 'MEDIA' | 'OTHER',
visibility: visibility as 'ADMIN_ONLY' | 'JURY_VISIBLE' | 'PUBLIC',
})
}
return (
<div className="space-y-6">
<div className="flex items-center gap-4">
<Link href="/admin/partners">
<Button variant="ghost" size="icon">
<ArrowLeft className="h-4 w-4" />
</Button>
</Link>
<div>
<h1 className="text-2xl font-bold">Add Partner</h1>
<p className="text-muted-foreground">
Add a new partner or sponsor organization
</p>
</div>
</div>
<Card>
<CardHeader>
<CardTitle>Partner Details</CardTitle>
<CardDescription>
Basic information about the partner organization
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="grid gap-4 md:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="name">Organization Name *</Label>
<Input
id="name"
name="name"
placeholder="e.g., Ocean Conservation Foundation"
required
/>
</div>
<div className="space-y-2">
<Label htmlFor="partnerType">Partner Type</Label>
<Select value={partnerType} onValueChange={setPartnerType}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="SPONSOR">Sponsor</SelectItem>
<SelectItem value="PARTNER">Partner</SelectItem>
<SelectItem value="SUPPORTER">Supporter</SelectItem>
<SelectItem value="MEDIA">Media</SelectItem>
<SelectItem value="OTHER">Other</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea
id="description"
name="description"
placeholder="Describe the organization and partnership..."
rows={3}
maxLength={500}
/>
</div>
<div className="space-y-2">
<Label htmlFor="website">Website</Label>
<Input
id="website"
name="website"
type="url"
placeholder="https://example.org"
/>
</div>
<div className="space-y-2">
<Label htmlFor="visibility">Visibility</Label>
<Select value={visibility} onValueChange={setVisibility}>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="ADMIN_ONLY">Admin Only</SelectItem>
<SelectItem value="JURY_VISIBLE">Visible to Jury</SelectItem>
<SelectItem value="PUBLIC">Public</SelectItem>
</SelectContent>
</Select>
</div>
<div className="flex justify-end gap-2 pt-4">
<Link href="/admin/partners">
<Button type="button" variant="outline">
Cancel
</Button>
</Link>
<Button type="submit" disabled={isSubmitting}>
{isSubmitting && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
Add Partner
</Button>
</div>
</form>
</CardContent>
</Card>
</div>
)
}

View File

@@ -0,0 +1,164 @@
import { Suspense } from 'react'
import Link from 'next/link'
import { api } from '@/lib/trpc/server'
import { Button } from '@/components/ui/button'
import {
Card,
CardContent,
} from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { Skeleton } from '@/components/ui/skeleton'
import {
Plus,
Pencil,
ExternalLink,
Building2,
Eye,
EyeOff,
Globe,
} from 'lucide-react'
const visibilityIcons = {
ADMIN_ONLY: EyeOff,
JURY_VISIBLE: Eye,
PUBLIC: Globe,
}
const partnerTypeColors = {
SPONSOR: 'bg-yellow-100 text-yellow-800',
PARTNER: 'bg-blue-100 text-blue-800',
SUPPORTER: 'bg-green-100 text-green-800',
MEDIA: 'bg-purple-100 text-purple-800',
OTHER: 'bg-gray-100 text-gray-800',
}
async function PartnersList() {
const caller = await api()
const { data: partners } = await caller.partner.list({
perPage: 50,
})
if (partners.length === 0) {
return (
<Card>
<CardContent className="flex flex-col items-center justify-center py-12">
<Building2 className="h-12 w-12 text-muted-foreground mb-4" />
<h3 className="text-lg font-medium mb-2">No partners yet</h3>
<p className="text-muted-foreground mb-4">
Start by adding your first partner organization
</p>
<Link href="/admin/partners/new">
<Button>
<Plus className="mr-2 h-4 w-4" />
Add Partner
</Button>
</Link>
</CardContent>
</Card>
)
}
return (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{partners.map((partner) => {
const VisibilityIcon = visibilityIcons[partner.visibility]
return (
<Card key={partner.id} className={!partner.isActive ? 'opacity-60' : ''}>
<CardContent className="p-4">
<div className="flex items-start gap-4">
<div className="flex h-12 w-12 items-center justify-center rounded-lg bg-muted shrink-0">
<Building2 className="h-6 w-6" />
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<h3 className="font-medium truncate">{partner.name}</h3>
{!partner.isActive && (
<Badge variant="secondary">Inactive</Badge>
)}
</div>
<div className="flex items-center gap-2 mt-1">
<Badge className={partnerTypeColors[partner.partnerType]} variant="outline">
{partner.partnerType}
</Badge>
<VisibilityIcon className="h-3 w-3 text-muted-foreground" />
</div>
{partner.description && (
<p className="text-sm text-muted-foreground mt-2 line-clamp-2">
{partner.description}
</p>
)}
</div>
</div>
<div className="flex items-center justify-end gap-2 mt-4 pt-4 border-t">
{partner.website && (
<a
href={partner.website}
target="_blank"
rel="noopener noreferrer"
>
<Button variant="ghost" size="sm">
<ExternalLink className="h-4 w-4 mr-1" />
Website
</Button>
</a>
)}
<Link href={`/admin/partners/${partner.id}`}>
<Button variant="ghost" size="sm">
<Pencil className="h-4 w-4 mr-1" />
Edit
</Button>
</Link>
</div>
</CardContent>
</Card>
)
})}
</div>
)
}
function LoadingSkeleton() {
return (
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
{[1, 2, 3, 4, 5, 6].map((i) => (
<Card key={i}>
<CardContent className="p-4">
<div className="flex items-start gap-4">
<Skeleton className="h-12 w-12 rounded-lg" />
<div className="flex-1 space-y-2">
<Skeleton className="h-5 w-32" />
<Skeleton className="h-4 w-20" />
<Skeleton className="h-4 w-full" />
</div>
</div>
</CardContent>
</Card>
))}
</div>
)
}
export default function PartnersPage() {
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div>
<h1 className="text-2xl font-bold">Partners</h1>
<p className="text-muted-foreground">
Manage partner and sponsor organizations
</p>
</div>
<Link href="/admin/partners/new">
<Button>
<Plus className="mr-2 h-4 w-4" />
Add Partner
</Button>
</Link>
</div>
<Suspense fallback={<LoadingSkeleton />}>
<PartnersList />
</Suspense>
</div>
)
}