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
|
id: string
|
||||||
username: string
|
username: string
|
||||||
displayUsername: string | null
|
displayUsername: string | null
|
||||||
|
managedFunds: { fund: { name: string; slug: string } }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Application {
|
interface Application {
|
||||||
@@ -23,7 +24,7 @@ export default function AdminFundApplications({ applications: initial }: { appli
|
|||||||
const [applications, setApplications] = useState<Application[]>(initial)
|
const [applications, setApplications] = useState<Application[]>(initial)
|
||||||
const [expanded, setExpanded] = useState<string | null>(null)
|
const [expanded, setExpanded] = useState<string | null>(null)
|
||||||
const [approveId, setApproveId] = 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 [error, setError] = useState('')
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
@@ -122,6 +123,25 @@ export default function AdminFundApplications({ applications: initial }: { appli
|
|||||||
<p className="text-xs text-slate-400">
|
<p className="text-xs text-slate-400">
|
||||||
Approve <span className="text-white font-medium">{app.fundName}</span> for{' '}
|
Approve <span className="text-white font-medium">{app.fundName}</span> for{' '}
|
||||||
<span className="text-slate-200">{app.user.displayUsername ?? app.user.username}</span>
|
<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>
|
</p>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -18,7 +18,16 @@ export default async function AdminFundsPage() {
|
|||||||
}),
|
}),
|
||||||
prisma.fundApplication.findMany({
|
prisma.fundApplication.findMany({
|
||||||
orderBy: { createdAt: 'asc' },
|
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 [loading, setLoading] = useState(false)
|
||||||
const [withdrawing, setWithdrawing] = 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
|
// Pending application
|
||||||
if (existing) {
|
if (existing) {
|
||||||
async function withdraw() {
|
async function withdraw() {
|
||||||
@@ -47,31 +28,45 @@ export default function FundApplicationClient({ existing, managedFund }: Props)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-surface-card border border-indigo-500/30 rounded-xl p-6 space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="flex items-center gap-3">
|
{managedFund && (
|
||||||
<Clock className="h-5 w-5 text-amber-400" />
|
<div className="bg-surface-card border border-surface-border rounded-xl p-4 flex items-start gap-3">
|
||||||
<p className="font-medium">Application pending review</p>
|
<CheckCircle className="h-4 w-4 text-green-400 mt-0.5 shrink-0" />
|
||||||
</div>
|
<p className="text-sm text-slate-400">
|
||||||
<div className="space-y-2 text-sm">
|
You already manage{' '}
|
||||||
<div>
|
<Link href={`/fund/${managedFund.slug}`} className="text-indigo-400 hover:text-indigo-300 underline underline-offset-2">
|
||||||
<span className="text-slate-500 text-xs uppercase tracking-wide">Fund Name</span>
|
{managedFund.name}
|
||||||
<p className="text-white mt-0.5">{existing.fundName}</p>
|
</Link>
|
||||||
|
. You can still apply for an additional fund.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
)}
|
||||||
<span className="text-slate-500 text-xs uppercase tracking-wide">Reason</span>
|
<div className="bg-surface-card border border-indigo-500/30 rounded-xl p-6 space-y-4">
|
||||||
<p className="text-slate-300 mt-0.5 whitespace-pre-wrap">{existing.reason}</p>
|
<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>
|
||||||
<p className="text-xs text-slate-500">
|
<div className="space-y-2 text-sm">
|
||||||
Submitted {new Date(existing.createdAt).toLocaleDateString()}
|
<div>
|
||||||
</p>
|
<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>
|
</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>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -94,54 +89,68 @@ export default function FundApplicationClient({ existing, managedFund }: Props)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="bg-surface-card border border-surface-border rounded-xl p-6 space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="flex items-center gap-2 text-slate-300">
|
{managedFund && (
|
||||||
<Building2 className="h-5 w-5 text-indigo-400" />
|
<div className="bg-surface-card border border-surface-border rounded-xl p-4 flex items-start gap-3">
|
||||||
<span className="font-medium">New Fund Application</span>
|
<CheckCircle className="h-4 w-4 text-green-400 mt-0.5 shrink-0" />
|
||||||
</div>
|
<p className="text-sm text-slate-400">
|
||||||
|
You already manage{' '}
|
||||||
{error && (
|
<Link href={`/fund/${managedFund.slug}`} className="text-indigo-400 hover:text-indigo-300 underline underline-offset-2">
|
||||||
<p className="text-red-400 text-sm bg-red-400/10 border border-red-400/20 rounded-lg px-3 py-2">{error}</p>
|
{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>
|
{error && (
|
||||||
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
<p className="text-red-400 text-sm bg-red-400/10 border border-red-400/20 rounded-lg px-3 py-2">{error}</p>
|
||||||
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>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
||||||
Why do you want to run this fund?
|
Fund Name <span className="normal-case">(max 60 chars)</span>
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<input
|
||||||
value={reason}
|
value={fundName}
|
||||||
onChange={(e) => setReason(e.target.value)}
|
onChange={(e) => setFundName(e.target.value)}
|
||||||
rows={5}
|
maxLength={60}
|
||||||
minLength={10}
|
placeholder="TechAlpha Capital"
|
||||||
maxLength={1000}
|
required
|
||||||
placeholder="Describe your strategy, what hashtags you plan to focus on, and why you'd be a good fund manager…"
|
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"
|
||||||
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"
|
</div>
|
||||||
/>
|
|
||||||
<p className="text-xs text-slate-600 mt-0.5 text-right">{reason.length}/1000</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
<div>
|
||||||
type="submit"
|
<label className="text-xs text-slate-500 uppercase tracking-wide block mb-1">
|
||||||
disabled={loading || !fundName.trim() || reason.trim().length < 10}
|
Why do you want to run this fund?
|
||||||
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"
|
</label>
|
||||||
>
|
<textarea
|
||||||
{loading ? 'Submitting…' : 'Submit Application'}
|
value={reason}
|
||||||
</button>
|
onChange={(e) => setReason(e.target.value)}
|
||||||
</form>
|
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