feat: enhance fund application process by displaying managed funds for applicants
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m21s
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m21s
This commit is contained in:
@@ -8,6 +8,7 @@ interface Applicant {
|
||||
id: string
|
||||
username: string
|
||||
displayUsername: string | null
|
||||
managedFunds: { fund: { name: string; slug: string } }[]
|
||||
}
|
||||
|
||||
interface Application {
|
||||
@@ -23,7 +24,7 @@ export default function AdminFundApplications({ applications: initial }: { appli
|
||||
const [applications, setApplications] = useState<Application[]>(initial)
|
||||
const [expanded, setExpanded] = useState<string | null>(null)
|
||||
const [approveId, setApproveId] = useState<string | null>(null)
|
||||
const [startingBalance, setStartingBalance] = useState('0')
|
||||
const [startingBalance, setStartingBalance] = useState('10000')
|
||||
const [error, setError] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
@@ -122,6 +123,25 @@ export default function AdminFundApplications({ applications: initial }: { appli
|
||||
<p className="text-xs text-slate-400">
|
||||
Approve <span className="text-white font-medium">{app.fundName}</span> for{' '}
|
||||
<span className="text-slate-200">{app.user.displayUsername ?? app.user.username}</span>
|
||||
{app.user.managedFunds.length > 0 && (
|
||||
<span className="text-slate-500">
|
||||
{' '}(also manages{' '}
|
||||
{app.user.managedFunds.map((m, i) => (
|
||||
<span key={m.fund.slug}>
|
||||
{i > 0 && ', '}
|
||||
<a
|
||||
href={`/fund/${m.fund.slug}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-indigo-400 hover:text-indigo-300 underline underline-offset-2"
|
||||
>
|
||||
{m.fund.name}
|
||||
</a>
|
||||
</span>
|
||||
))}
|
||||
)
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
<div className="flex items-center gap-3">
|
||||
<div>
|
||||
|
||||
@@ -18,7 +18,16 @@ export default async function AdminFundsPage() {
|
||||
}),
|
||||
prisma.fundApplication.findMany({
|
||||
orderBy: { createdAt: 'asc' },
|
||||
include: { user: { select: { id: true, username: true, displayUsername: true } } },
|
||||
include: {
|
||||
user: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
displayUsername: true,
|
||||
managedFunds: { select: { fund: { select: { name: true, slug: true } } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
])
|
||||
|
||||
|
||||
@@ -18,25 +18,6 @@ export default function FundApplicationClient({ existing, managedFund }: Props)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [withdrawing, setWithdrawing] = useState(false)
|
||||
|
||||
// Already a fund manager
|
||||
if (managedFund) {
|
||||
return (
|
||||
<div className="bg-surface-card border border-surface-border rounded-xl p-6 space-y-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<CheckCircle className="h-5 w-5 text-green-400" />
|
||||
<p className="font-medium">You already manage a fund</p>
|
||||
</div>
|
||||
<p className="text-sm text-slate-400">
|
||||
You are a manager of{' '}
|
||||
<Link href={`/fund/${managedFund.slug}`} className="text-indigo-400 hover:text-indigo-300 underline underline-offset-2">
|
||||
{managedFund.name}
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Pending application
|
||||
if (existing) {
|
||||
async function withdraw() {
|
||||
@@ -47,31 +28,45 @@ export default function FundApplicationClient({ existing, managedFund }: Props)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="bg-surface-card border border-indigo-500/30 rounded-xl p-6 space-y-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<Clock className="h-5 w-5 text-amber-400" />
|
||||
<p className="font-medium">Application pending review</p>
|
||||
</div>
|
||||
<div className="space-y-2 text-sm">
|
||||
<div>
|
||||
<span className="text-slate-500 text-xs uppercase tracking-wide">Fund Name</span>
|
||||
<p className="text-white mt-0.5">{existing.fundName}</p>
|
||||
<div className="space-y-4">
|
||||
{managedFund && (
|
||||
<div className="bg-surface-card border border-surface-border rounded-xl p-4 flex items-start gap-3">
|
||||
<CheckCircle className="h-4 w-4 text-green-400 mt-0.5 shrink-0" />
|
||||
<p className="text-sm text-slate-400">
|
||||
You already manage{' '}
|
||||
<Link href={`/fund/${managedFund.slug}`} className="text-indigo-400 hover:text-indigo-300 underline underline-offset-2">
|
||||
{managedFund.name}
|
||||
</Link>
|
||||
. You can still apply for an additional fund.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-slate-500 text-xs uppercase tracking-wide">Reason</span>
|
||||
<p className="text-slate-300 mt-0.5 whitespace-pre-wrap">{existing.reason}</p>
|
||||
)}
|
||||
<div className="bg-surface-card border border-indigo-500/30 rounded-xl p-6 space-y-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<Clock className="h-5 w-5 text-amber-400" />
|
||||
<p className="font-medium">Application pending review</p>
|
||||
</div>
|
||||
<p className="text-xs text-slate-500">
|
||||
Submitted {new Date(existing.createdAt).toLocaleDateString()}
|
||||
</p>
|
||||
<div className="space-y-2 text-sm">
|
||||
<div>
|
||||
<span className="text-slate-500 text-xs uppercase tracking-wide">Fund Name</span>
|
||||
<p className="text-white mt-0.5">{existing.fundName}</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-slate-500 text-xs uppercase tracking-wide">Reason</span>
|
||||
<p className="text-slate-300 mt-0.5 whitespace-pre-wrap">{existing.reason}</p>
|
||||
</div>
|
||||
<p className="text-xs text-slate-500">
|
||||
Submitted {new Date(existing.createdAt).toLocaleDateString()}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={withdraw}
|
||||
disabled={withdrawing}
|
||||
className="text-xs text-red-400 hover:text-red-300 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{withdrawing ? 'Withdrawing…' : 'Withdraw application'}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
onClick={withdraw}
|
||||
disabled={withdrawing}
|
||||
className="text-xs text-red-400 hover:text-red-300 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{withdrawing ? 'Withdrawing…' : 'Withdraw application'}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -94,54 +89,68 @@ export default function FundApplicationClient({ existing, managedFund }: Props)
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="bg-surface-card border border-surface-border rounded-xl p-6 space-y-4">
|
||||
<div className="flex items-center gap-2 text-slate-300">
|
||||
<Building2 className="h-5 w-5 text-indigo-400" />
|
||||
<span className="font-medium">New Fund Application</span>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<p className="text-red-400 text-sm bg-red-400/10 border border-red-400/20 rounded-lg px-3 py-2">{error}</p>
|
||||
<div className="space-y-4">
|
||||
{managedFund && (
|
||||
<div className="bg-surface-card border border-surface-border rounded-xl p-4 flex items-start gap-3">
|
||||
<CheckCircle className="h-4 w-4 text-green-400 mt-0.5 shrink-0" />
|
||||
<p className="text-sm text-slate-400">
|
||||
You already manage{' '}
|
||||
<Link href={`/fund/${managedFund.slug}`} className="text-indigo-400 hover:text-indigo-300 underline underline-offset-2">
|
||||
{managedFund.name}
|
||||
</Link>
|
||||
. You can still apply for an additional fund below.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<form onSubmit={handleSubmit} className="bg-surface-card border border-surface-border rounded-xl p-6 space-y-4">
|
||||
<div className="flex items-center gap-2 text-slate-300">
|
||||
<Building2 className="h-5 w-5 text-indigo-400" />
|
||||
<span className="font-medium">New Fund Application</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
||||
Fund Name <span className="normal-case">(max 60 chars)</span>
|
||||
</label>
|
||||
<input
|
||||
value={fundName}
|
||||
onChange={(e) => setFundName(e.target.value)}
|
||||
maxLength={60}
|
||||
placeholder="TechAlpha Capital"
|
||||
required
|
||||
className="w-full bg-surface border border-surface-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
/>
|
||||
</div>
|
||||
{error && (
|
||||
<p className="text-red-400 text-sm bg-red-400/10 border border-red-400/20 rounded-lg px-3 py-2">{error}</p>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
||||
Why do you want to run this fund?
|
||||
</label>
|
||||
<textarea
|
||||
value={reason}
|
||||
onChange={(e) => setReason(e.target.value)}
|
||||
rows={5}
|
||||
minLength={10}
|
||||
maxLength={1000}
|
||||
placeholder="Describe your strategy, what hashtags you plan to focus on, and why you'd be a good fund manager…"
|
||||
required
|
||||
className="w-full bg-surface border border-surface-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none"
|
||||
/>
|
||||
<p className="text-xs text-slate-600 mt-0.5 text-right">{reason.length}/1000</p>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
||||
Fund Name <span className="normal-case">(max 60 chars)</span>
|
||||
</label>
|
||||
<input
|
||||
value={fundName}
|
||||
onChange={(e) => setFundName(e.target.value)}
|
||||
maxLength={60}
|
||||
placeholder="TechAlpha Capital"
|
||||
required
|
||||
className="w-full bg-surface border border-surface-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading || !fundName.trim() || reason.trim().length < 10}
|
||||
className="w-full py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg disabled:opacity-50 transition-colors"
|
||||
>
|
||||
{loading ? 'Submitting…' : 'Submit Application'}
|
||||
</button>
|
||||
</form>
|
||||
<div>
|
||||
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
||||
Why do you want to run this fund?
|
||||
</label>
|
||||
<textarea
|
||||
value={reason}
|
||||
onChange={(e) => setReason(e.target.value)}
|
||||
rows={5}
|
||||
minLength={10}
|
||||
maxLength={1000}
|
||||
placeholder="Describe your strategy, what hashtags you plan to focus on, and why you'd be a good fund manager…"
|
||||
required
|
||||
className="w-full bg-surface border border-surface-border rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none"
|
||||
/>
|
||||
<p className="text-xs text-slate-600 mt-0.5 text-right">{reason.length}/1000</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading || !fundName.trim() || reason.trim().length < 10}
|
||||
className="w-full py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg disabled:opacity-50 transition-colors"
|
||||
>
|
||||
{loading ? 'Submitting…' : 'Submit Application'}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user