This commit is contained in:
DeathKaioken 2026-01-18 22:12:29 +01:00
parent 329a71931b
commit fa9080cdfb
2 changed files with 323 additions and 314 deletions

View File

@ -121,7 +121,8 @@ export default function AffiliateManagementPage() {
<PageTransitionEffect> <PageTransitionEffect>
<div className="min-h-screen flex flex-col bg-gradient-to-tr from-blue-50 via-white to-blue-100"> <div className="min-h-screen flex flex-col bg-gradient-to-tr from-blue-50 via-white to-blue-100">
<Header /> <Header />
<main className="flex-1 py-8 px-4 sm:px-6 lg:px-8"> {/* tighter padding on mobile */}
<main className="flex-1 py-6 md:py-8 px-4 sm:px-6 lg:px-8">
<div className="max-w-7xl mx-auto"> <div className="max-w-7xl mx-auto">
{/* Error State */} {/* Error State */}
{error && ( {error && (
@ -139,15 +140,19 @@ export default function AffiliateManagementPage() {
)} )}
{/* Header */} {/* Header */}
<header className="bg-white/90 backdrop-blur border-b border-blue-100 py-10 px-8 rounded-2xl shadow-lg mb-8"> <header className="bg-white/90 backdrop-blur border-b border-blue-100 py-6 md:py-10 px-4 md:px-8 rounded-2xl shadow-lg mb-6 md:mb-8">
<div className="flex items-center justify-between mb-6"> <div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4 md:gap-6 mb-4 md:mb-6">
<div> <div className="min-w-0">
<h1 className="text-4xl font-extrabold text-blue-900 tracking-tight">Affiliate Management</h1> <h1 className="text-2xl md:text-4xl font-extrabold text-blue-900 tracking-tight">
<p className="text-lg text-blue-700 mt-2">Manage your affiliate partners and tracking links</p> Affiliate Management
</h1>
<p className="text-sm md:text-lg text-blue-700 mt-1 md:mt-2">
Manage your affiliate partners and tracking links
</p>
</div> </div>
<button <button
onClick={() => setShowCreateModal(true)} onClick={() => setShowCreateModal(true)}
className="inline-flex items-center gap-2 rounded-lg bg-blue-900 hover:bg-blue-800 text-blue-50 px-5 py-3 text-sm font-semibold shadow transition" className="w-full md:w-auto inline-flex items-center justify-center gap-2 rounded-lg bg-blue-900 hover:bg-blue-800 text-blue-50 px-5 py-3 text-sm font-semibold shadow transition"
> >
<PlusIcon className="h-5 w-5" /> <PlusIcon className="h-5 w-5" />
Add Affiliate Add Affiliate
@ -155,7 +160,7 @@ export default function AffiliateManagementPage() {
</div> </div>
{/* Search and Filter */} {/* Search and Filter */}
<div className="flex flex-col sm:flex-row gap-4"> <div className="flex flex-col sm:flex-row gap-3 md:gap-4">
<div className="flex-1 relative"> <div className="flex-1 relative">
<MagnifyingGlassIcon className="absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400" /> <MagnifyingGlassIcon className="absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400" />
<input <input
@ -169,7 +174,7 @@ export default function AffiliateManagementPage() {
<select <select
value={categoryFilter} value={categoryFilter}
onChange={e => setCategoryFilter(e.target.value)} onChange={e => setCategoryFilter(e.target.value)}
className="px-4 py-2.5 rounded-lg border border-gray-300 bg-white text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent" className="w-full sm:w-auto px-4 py-2.5 rounded-lg border border-gray-300 bg-white text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
> >
{categories.map(cat => ( {categories.map(cat => (
<option key={cat} value={cat}> <option key={cat} value={cat}>
@ -181,7 +186,7 @@ export default function AffiliateManagementPage() {
</header> </header>
{/* Stats */} {/* Stats */}
<div className="grid grid-cols-1 sm:grid-cols-3 gap-6 mb-8"> <div className="grid grid-cols-1 sm:grid-cols-3 gap-4 md:gap-6 mb-6 md:mb-8">
<div className="bg-white rounded-2xl border border-gray-100 shadow-lg p-6"> <div className="bg-white rounded-2xl border border-gray-100 shadow-lg p-6">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<div className="rounded-lg bg-blue-50 p-3"> <div className="rounded-lg bg-blue-50 p-3">
@ -222,7 +227,7 @@ export default function AffiliateManagementPage() {
</div> </div>
{/* Affiliates Grid */} {/* Affiliates Grid */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-6">
{loading && ( {loading && (
<div className="col-span-full text-center py-12"> <div className="col-span-full text-center py-12">
<div className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-blue-600 border-r-transparent"></div> <div className="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-blue-600 border-r-transparent"></div>
@ -544,155 +549,155 @@ function CreateAffiliateModal({ onClose, onCreate }: { onClose: () => void; onCr
onCropComplete={handleCropComplete} onCropComplete={handleCropComplete}
/> />
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"> <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm">
<div className="relative w-full max-w-2xl mx-4 bg-white rounded-2xl shadow-2xl max-h-[90vh] overflow-y-auto"> <div className="relative w-full max-w-2xl mx-0 sm:mx-4 bg-white rounded-none sm:rounded-2xl shadow-2xl max-h-[100vh] sm:max-h-[90vh] overflow-y-auto">
<div className="sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between rounded-t-2xl"> <div className="sticky top-0 bg-white border-b border-gray-200 px-4 sm:px-6 py-3 sm:py-4 flex items-center justify-between rounded-none sm:rounded-t-2xl">
<h2 className="text-2xl font-bold text-blue-900">Add New Affiliate</h2> <h2 className="text-xl sm:text-2xl font-bold text-blue-900">Add New Affiliate</h2>
<button onClick={onClose} className="text-gray-500 hover:text-gray-700 transition"> <button onClick={onClose} className="text-gray-500 hover:text-gray-700 transition">
<XMarkIcon className="h-6 w-6" /> <XMarkIcon className="h-6 w-6" />
</button> </button>
</div>
<form onSubmit={handleSubmit} className="p-6 space-y-6">
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Partner Name *</label>
<input
required
value={name}
onChange={e => setName(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
placeholder="e.g., Coffee Equipment Co."
/>
</div> </div>
<div> <form onSubmit={handleSubmit} className="p-4 sm:p-6 space-y-5 sm:space-y-6">
<label className="block text-sm font-medium text-blue-900 mb-2">Description *</label>
<textarea
required
value={description}
onChange={e => setDescription(e.target.value)}
rows={3}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
placeholder="Brief description of the affiliate partner..."
/>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Affiliate URL *</label>
<input
required
type="url"
value={url}
onChange={e => setUrl(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
placeholder="https://example.com/affiliate-link"
/>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Logo Image</label>
<div
className="relative flex justify-center items-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 cursor-pointer overflow-hidden transition hover:border-blue-400 hover:bg-blue-100"
style={{ minHeight: '200px' }}
onClick={(e) => {
e.stopPropagation()
const input = document.getElementById('create-logo-upload') as HTMLInputElement
if (input) input.click()
}}
>
{!previewUrl && (
<div className="text-center w-full px-6 py-10">
<PhotoIcon aria-hidden="true" className="mx-auto h-12 w-12 text-gray-400" />
<div className="mt-4 text-sm font-medium text-gray-700">
<span>Click to upload logo</span>
</div>
<p className="text-xs text-gray-500 mt-2">PNG, JPG, WebP, SVG up to 5MB</p>
</div>
)}
{previewUrl && (
<div className="relative w-full h-full min-h-[200px] flex items-center justify-center bg-white p-4">
<img
src={previewUrl}
alt="Logo preview"
className="max-h-[180px] max-w-full object-contain"
/>
<button
type="button"
onClick={(e) => {
e.stopPropagation()
handleRemoveLogo()
}}
className="absolute top-2 right-2 bg-red-50 hover:bg-red-100 text-red-700 px-3 py-1.5 rounded-lg text-sm font-medium shadow transition"
>
Remove
</button>
</div>
)}
</div>
<input
id="create-logo-upload"
type="file"
accept="image/*"
onChange={handleLogoChange}
className="hidden"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div> <div>
<label className="block text-sm font-medium text-blue-900 mb-2">Category *</label> <label className="block text-sm font-medium text-blue-900 mb-2">Partner Name *</label>
<select
value={category}
onChange={e => setCategory(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
>
{AFFILIATE_CATEGORIES.map(cat => (
<option key={cat} value={cat}>{cat}</option>
))}
</select>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Commission Rate</label>
<input <input
value={commissionRate} required
onChange={e => setCommissionRate(e.target.value)} value={name}
onChange={e => setName(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent" className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
placeholder="e.g., 10%" placeholder="e.g., Coffee Equipment Co."
/> />
</div> </div>
</div>
<div className="flex items-center gap-2"> <div>
<input <label className="block text-sm font-medium text-blue-900 mb-2">Description *</label>
id="isActive" <textarea
type="checkbox" required
checked={isActive} value={description}
onChange={e => setIsActive(e.target.checked)} onChange={e => setDescription(e.target.value)}
className="h-4 w-4 rounded border-gray-300 text-blue-900 focus:ring-blue-900" rows={3}
/> className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
<label htmlFor="isActive" className="text-sm font-medium text-gray-700"> placeholder="Brief description of the affiliate partner..."
Active (visible to users) />
</label> </div>
</div>
<div className="flex items-center justify-end gap-3 pt-4 border-t border-gray-200"> <div>
<button <label className="block text-sm font-medium text-blue-900 mb-2">Affiliate URL *</label>
type="button" <input
onClick={onClose} required
className="px-5 py-2.5 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition" type="url"
> value={url}
Cancel onChange={e => setUrl(e.target.value)}
</button> className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
<button placeholder="https://example.com/affiliate-link"
type="submit" />
className="px-5 py-2.5 text-sm font-semibold text-white bg-blue-900 rounded-lg hover:bg-blue-800 shadow transition" </div>
>
Add Affiliate <div>
</button> <label className="block text-sm font-medium text-blue-900 mb-2">Logo Image</label>
</div> <div
</form> className="relative flex justify-center items-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 cursor-pointer overflow-hidden transition hover:border-blue-400 hover:bg-blue-100"
style={{ minHeight: '200px' }}
onClick={(e) => {
e.stopPropagation()
const input = document.getElementById('create-logo-upload') as HTMLInputElement
if (input) input.click()
}}
>
{!previewUrl && (
<div className="text-center w-full px-6 py-10">
<PhotoIcon aria-hidden="true" className="mx-auto h-12 w-12 text-gray-400" />
<div className="mt-4 text-sm font-medium text-gray-700">
<span>Click to upload logo</span>
</div>
<p className="text-xs text-gray-500 mt-2">PNG, JPG, WebP, SVG up to 5MB</p>
</div>
)}
{previewUrl && (
<div className="relative w-full h-full min-h-[200px] flex items-center justify-center bg-white p-4">
<img
src={previewUrl}
alt="Logo preview"
className="max-h-[180px] max-w-full object-contain"
/>
<button
type="button"
onClick={(e) => {
e.stopPropagation()
handleRemoveLogo()
}}
className="absolute top-2 right-2 bg-red-50 hover:bg-red-100 text-red-700 px-3 py-1.5 rounded-lg text-sm font-medium shadow transition"
>
Remove
</button>
</div>
)}
</div>
<input
id="create-logo-upload"
type="file"
accept="image/*"
onChange={handleLogoChange}
className="hidden"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Category *</label>
<select
value={category}
onChange={e => setCategory(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
>
{AFFILIATE_CATEGORIES.map(cat => (
<option key={cat} value={cat}>{cat}</option>
))}
</select>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Commission Rate</label>
<input
value={commissionRate}
onChange={e => setCommissionRate(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
placeholder="e.g., 10%"
/>
</div>
</div>
<div className="flex items-center gap-2">
<input
id="isActive"
type="checkbox"
checked={isActive}
onChange={e => setIsActive(e.target.checked)}
className="h-4 w-4 rounded border-gray-300 text-blue-900 focus:ring-blue-900"
/>
<label htmlFor="isActive" className="text-sm font-medium text-gray-700">
Active (visible to users)
</label>
</div>
<div className="flex items-center justify-end gap-3 pt-4 border-t border-gray-200">
<button
type="button"
onClick={onClose}
className="px-5 py-2.5 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition"
>
Cancel
</button>
<button
type="submit"
className="px-5 py-2.5 text-sm font-semibold text-white bg-blue-900 rounded-lg hover:bg-blue-800 shadow transition"
>
Add Affiliate
</button>
</div>
</form>
</div>
</div> </div>
</div>
</> </>
) )
} }
@ -808,154 +813,154 @@ function EditAffiliateModal({ affiliate, onClose, onUpdate }: {
onCropComplete={handleCropComplete} onCropComplete={handleCropComplete}
/> />
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"> <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm">
<div className="relative w-full max-w-2xl mx-4 bg-white rounded-2xl shadow-2xl max-h-[90vh] overflow-y-auto"> <div className="relative w-full max-w-2xl mx-0 sm:mx-4 bg-white rounded-none sm:rounded-2xl shadow-2xl max-h-[100vh] sm:max-h-[90vh] overflow-y-auto">
<div className="sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between rounded-t-2xl"> <div className="sticky top-0 bg-white border-b border-gray-200 px-4 sm:px-6 py-3 sm:py-4 flex items-center justify-between rounded-none sm:rounded-t-2xl">
<h2 className="text-2xl font-bold text-blue-900">Edit Affiliate</h2> <h2 className="text-xl sm:text-2xl font-bold text-blue-900">Edit Affiliate</h2>
<button onClick={onClose} className="text-gray-500 hover:text-gray-700 transition"> <button onClick={onClose} className="text-gray-500 hover:text-gray-700 transition">
<XMarkIcon className="h-6 w-6" /> <XMarkIcon className="h-6 w-6" />
</button> </button>
</div>
<form onSubmit={handleSubmit} className="p-6 space-y-6">
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Partner Name *</label>
<input
required
value={name}
onChange={e => setName(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
/>
</div> </div>
<div> <form onSubmit={handleSubmit} className="p-4 sm:p-6 space-y-5 sm:space-y-6">
<label className="block text-sm font-medium text-blue-900 mb-2">Description *</label>
<textarea
required
value={description}
onChange={e => setDescription(e.target.value)}
rows={3}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
/>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Affiliate URL *</label>
<input
required
type="url"
value={url}
onChange={e => setUrl(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
/>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Logo Image</label>
<div
className="relative flex justify-center items-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 cursor-pointer overflow-hidden transition hover:border-blue-400 hover:bg-blue-100"
style={{ minHeight: '200px' }}
onClick={(e) => {
e.stopPropagation()
const input = document.getElementById('edit-logo-upload') as HTMLInputElement
if (input) input.click()
}}
>
{!displayLogoUrl && (
<div className="text-center w-full px-6 py-10">
<PhotoIcon aria-hidden="true" className="mx-auto h-12 w-12 text-gray-400" />
<div className="mt-4 text-sm font-medium text-gray-700">
<span>Click to upload logo</span>
</div>
<p className="text-xs text-gray-500 mt-2">PNG, JPG, WebP, SVG up to 5MB</p>
</div>
)}
{displayLogoUrl && (
<div className="relative w-full h-full min-h-[200px] flex flex-col items-center justify-center bg-white p-4">
<img
src={displayLogoUrl}
alt="Logo"
className="max-h-[180px] max-w-full object-contain"
/>
<p className="mt-2 text-xs text-gray-600">
{logoFile ? '🆕 New logo selected' : '📷 Current logo'}
</p>
<button
type="button"
onClick={(e) => {
e.stopPropagation()
handleRemoveLogo()
}}
className="absolute top-2 right-2 bg-red-50 hover:bg-red-100 text-red-700 px-3 py-1.5 rounded-lg text-sm font-medium shadow transition"
>
Remove
</button>
</div>
)}
</div>
<input
id="edit-logo-upload"
type="file"
accept="image/*"
onChange={handleLogoChange}
className="hidden"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div> <div>
<label className="block text-sm font-medium text-blue-900 mb-2">Category *</label> <label className="block text-sm font-medium text-blue-900 mb-2">Partner Name *</label>
<select
value={category}
onChange={e => setCategory(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
>
{AFFILIATE_CATEGORIES.map(cat => (
<option key={cat} value={cat}>{cat}</option>
))}
</select>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Commission Rate</label>
<input <input
value={commissionRate} required
onChange={e => setCommissionRate(e.target.value)} value={name}
onChange={e => setName(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent" className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
/> />
</div> </div>
</div>
<div className="flex items-center gap-2"> <div>
<input <label className="block text-sm font-medium text-blue-900 mb-2">Description *</label>
id="editIsActive" <textarea
type="checkbox" required
checked={isActive} value={description}
onChange={e => setIsActive(e.target.checked)} onChange={e => setDescription(e.target.value)}
className="h-4 w-4 rounded border-gray-300 text-blue-900 focus:ring-blue-900" rows={3}
/> className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
<label htmlFor="editIsActive" className="text-sm font-medium text-gray-700"> />
Active (visible to users) </div>
</label>
</div>
<div className="flex items-center justify-end gap-3 pt-4 border-t border-gray-200"> <div>
<button <label className="block text-sm font-medium text-blue-900 mb-2">Affiliate URL *</label>
type="button" <input
onClick={onClose} required
className="px-5 py-2.5 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition" type="url"
> value={url}
Cancel onChange={e => setUrl(e.target.value)}
</button> className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
<button />
type="submit" </div>
className="px-5 py-2.5 text-sm font-semibold text-white bg-blue-900 rounded-lg hover:bg-blue-800 shadow transition"
> <div>
Save Changes <label className="block text-sm font-medium text-blue-900 mb-2">Logo Image</label>
</button> <div
</div> className="relative flex justify-center items-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 cursor-pointer overflow-hidden transition hover:border-blue-400 hover:bg-blue-100"
</form> style={{ minHeight: '200px' }}
onClick={(e) => {
e.stopPropagation()
const input = document.getElementById('edit-logo-upload') as HTMLInputElement
if (input) input.click()
}}
>
{!displayLogoUrl && (
<div className="text-center w-full px-6 py-10">
<PhotoIcon aria-hidden="true" className="mx-auto h-12 w-12 text-gray-400" />
<div className="mt-4 text-sm font-medium text-gray-700">
<span>Click to upload logo</span>
</div>
<p className="text-xs text-gray-500 mt-2">PNG, JPG, WebP, SVG up to 5MB</p>
</div>
)}
{displayLogoUrl && (
<div className="relative w-full h-full min-h-[200px] flex flex-col items-center justify-center bg-white p-4">
<img
src={displayLogoUrl}
alt="Logo"
className="max-h-[180px] max-w-full object-contain"
/>
<p className="mt-2 text-xs text-gray-600">
{logoFile ? '🆕 New logo selected' : '📷 Current logo'}
</p>
<button
type="button"
onClick={(e) => {
e.stopPropagation()
handleRemoveLogo()
}}
className="absolute top-2 right-2 bg-red-50 hover:bg-red-100 text-red-700 px-3 py-1.5 rounded-lg text-sm font-medium shadow transition"
>
Remove
</button>
</div>
)}
</div>
<input
id="edit-logo-upload"
type="file"
accept="image/*"
onChange={handleLogoChange}
className="hidden"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Category *</label>
<select
value={category}
onChange={e => setCategory(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
>
{AFFILIATE_CATEGORIES.map(cat => (
<option key={cat} value={cat}>{cat}</option>
))}
</select>
</div>
<div>
<label className="block text-sm font-medium text-blue-900 mb-2">Commission Rate</label>
<input
value={commissionRate}
onChange={e => setCommissionRate(e.target.value)}
className="w-full rounded-lg border border-gray-300 px-4 py-3 text-gray-900 focus:ring-2 focus:ring-blue-900 focus:border-transparent"
/>
</div>
</div>
<div className="flex items-center gap-2">
<input
id="editIsActive"
type="checkbox"
checked={isActive}
onChange={e => setIsActive(e.target.checked)}
className="h-4 w-4 rounded border-gray-300 text-blue-900 focus:ring-blue-900"
/>
<label htmlFor="editIsActive" className="text-sm font-medium text-gray-700">
Active (visible to users)
</label>
</div>
<div className="flex items-center justify-end gap-3 pt-4 border-t border-gray-200">
<button
type="button"
onClick={onClose}
className="px-5 py-2.5 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition"
>
Cancel
</button>
<button
type="submit"
className="px-5 py-2.5 text-sm font-semibold text-white bg-blue-900 rounded-lg hover:bg-blue-800 shadow transition"
>
Save Changes
</button>
</div>
</form>
</div>
</div> </div>
</div>
</> </>
) )
} }
@ -969,7 +974,7 @@ function DeleteConfirmModal({ affiliateName, onClose, onConfirm, isDeleting }: {
}) { }) {
return ( return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm"> <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm">
<div className="relative w-full max-w-md mx-4 bg-white rounded-2xl shadow-2xl p-6"> <div className="relative w-full max-w-md mx-0 sm:mx-4 bg-white rounded-none sm:rounded-2xl shadow-2xl p-4 sm:p-6">
<div className="mb-4"> <div className="mb-4">
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-red-100"> <div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-red-100">
<TrashIcon className="h-6 w-6 text-red-600" /> <TrashIcon className="h-6 w-6 text-red-600" />
@ -980,7 +985,7 @@ function DeleteConfirmModal({ affiliateName, onClose, onConfirm, isDeleting }: {
</p> </p>
</div> </div>
<div className="flex items-center gap-3"> <div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-3">
<button <button
onClick={onClose} onClick={onClose}
disabled={isDeleting} disabled={isDeleting}

View File

@ -48,36 +48,40 @@ export default function ContractManagementPage() {
return ( return (
<PageLayout> <PageLayout>
<div className="bg-gradient-to-tr from-blue-50 via-white to-blue-100 min-h-screen"> <div className="bg-gradient-to-tr from-blue-50 via-white to-blue-100 min-h-screen">
<div className="flex flex-col md:flex-row max-w-7xl mx-auto px-2 sm:px-6 lg:px-8 py-8 gap-8"> {/* tighter horizontal padding on mobile */}
{/* Sidebar Navigation */} <div className="flex flex-col md:flex-row max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 md:py-8 gap-6 md:gap-8">
<nav className="md:w-56 w-full flex md:flex-col flex-row gap-2 md:gap-4"> {/* Sidebar Navigation (mobile = horizontal scroll tabs, desktop = vertical) */}
{NAV.map((item) => ( <nav className="md:w-56 w-full md:self-start md:sticky md:top-6">
<button <div className="flex md:flex-col flex-row gap-2 md:gap-3 overflow-x-auto md:overflow-visible -mx-4 px-4 md:mx-0 md:px-0 pb-2 md:pb-0">
key={item.key} {NAV.map((item) => (
onClick={() => setSection(item.key)} <button
className={`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition key={item.key}
${section === item.key onClick={() => setSection(item.key)}
? 'bg-blue-900 text-blue-50 shadow' className={`flex flex-shrink-0 items-center gap-2 px-4 py-2 rounded-lg font-medium transition whitespace-nowrap text-sm md:text-base
: 'bg-white text-blue-900 hover:bg-blue-50 hover:text-blue-900 border border-blue-200'}`} ${section === item.key
> ? 'bg-blue-900 text-blue-50 shadow'
{item.icon} : 'bg-white text-blue-900 hover:bg-blue-50 hover:text-blue-900 border border-blue-200'}`}
<span>{item.label}</span> >
</button> {item.icon}
))} <span>{item.label}</span>
</button>
))}
</div>
</nav> </nav>
{/* Main Content */} {/* Main Content */}
<main className="flex-1 space-y-8"> <main className="flex-1 space-y-6 md:space-y-8">
<header className="sticky top-0 z-10 bg-white/90 backdrop-blur border-b border-blue-100 py-10 px-8 rounded-2xl shadow-lg flex flex-col gap-4 mb-4"> {/* sticky only on md+; smaller padding/title on mobile */}
<h1 className="text-4xl font-extrabold text-blue-900 tracking-tight">Contract Management</h1> <header className="md:sticky md:top-0 z-10 bg-white/90 backdrop-blur border-b border-blue-100 py-5 px-4 md:py-10 md:px-8 rounded-2xl shadow-lg flex flex-col gap-3 md:gap-4 mb-2 md:mb-4">
<p className="text-lg text-blue-700"> <h1 className="text-2xl md:text-4xl font-extrabold text-blue-900 tracking-tight">Contract Management</h1>
<p className="text-sm md:text-lg text-blue-700">
Manage contract templates, company stamp, and create new templates. Manage contract templates, company stamp, and create new templates.
</p> </p>
</header> </header>
{/* Section Panels */} {/* Section Panels (compact padding on mobile) */}
{section === 'stamp' && ( {section === 'stamp' && (
<section className="rounded-2xl bg-white shadow-lg border border-gray-100 p-6"> <section className="rounded-2xl bg-white shadow-lg border border-gray-100 p-4 md:p-6">
<h2 className="text-xl font-semibold text-blue-900 mb-4 flex items-center gap-2"> <h2 className="text-xl font-semibold text-blue-900 mb-4 flex items-center gap-2">
<svg className="w-6 h-6" fill="none" stroke="currentColor"><circle cx="12" cy="12" r="10"/><path d="M12 8v4l3 3"/></svg> <svg className="w-6 h-6" fill="none" stroke="currentColor"><circle cx="12" cy="12" r="10"/><path d="M12 8v4l3 3"/></svg>
Company Stamp Company Stamp
@ -86,7 +90,7 @@ export default function ContractManagementPage() {
</section> </section>
)} )}
{section === 'templates' && ( {section === 'templates' && (
<section className="rounded-2xl bg-white shadow-lg border border-gray-100 p-6"> <section className="rounded-2xl bg-white shadow-lg border border-gray-100 p-4 md:p-6">
<h2 className="text-xl font-semibold text-blue-900 mb-4 flex items-center gap-2"> <h2 className="text-xl font-semibold text-blue-900 mb-4 flex items-center gap-2">
<svg className="w-6 h-6" fill="none" stroke="currentColor"><path d="M4 6h16M4 12h16M4 18h16"/></svg> <svg className="w-6 h-6" fill="none" stroke="currentColor"><path d="M4 6h16M4 12h16M4 18h16"/></svg>
Templates Templates
@ -101,7 +105,7 @@ export default function ContractManagementPage() {
</section> </section>
)} )}
{section === 'editor' && ( {section === 'editor' && (
<section className="rounded-2xl bg-white shadow-lg border border-gray-100 p-6"> <section className="rounded-2xl bg-white shadow-lg border border-gray-100 p-4 md:p-6">
<h2 className="text-xl font-semibold text-blue-900 mb-4 flex items-center gap-2"> <h2 className="text-xl font-semibold text-blue-900 mb-4 flex items-center gap-2">
<svg className="w-6 h-6" fill="none" stroke="currentColor"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4 12.5-12.5z"/></svg> <svg className="w-6 h-6" fill="none" stroke="currentColor"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4 12.5-12.5z"/></svg>
Create Template Create Template