mobile
This commit is contained in:
parent
329a71931b
commit
fa9080cdfb
@ -121,7 +121,8 @@ export default function AffiliateManagementPage() {
|
||||
<PageTransitionEffect>
|
||||
<div className="min-h-screen flex flex-col bg-gradient-to-tr from-blue-50 via-white to-blue-100">
|
||||
<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">
|
||||
{/* Error State */}
|
||||
{error && (
|
||||
@ -139,15 +140,19 @@ export default function AffiliateManagementPage() {
|
||||
)}
|
||||
|
||||
{/* Header */}
|
||||
<header className="bg-white/90 backdrop-blur border-b border-blue-100 py-10 px-8 rounded-2xl shadow-lg mb-8">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h1 className="text-4xl font-extrabold text-blue-900 tracking-tight">Affiliate Management</h1>
|
||||
<p className="text-lg text-blue-700 mt-2">Manage your affiliate partners and tracking links</p>
|
||||
<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 flex-col md:flex-row md:items-center md:justify-between gap-4 md:gap-6 mb-4 md:mb-6">
|
||||
<div className="min-w-0">
|
||||
<h1 className="text-2xl md:text-4xl font-extrabold text-blue-900 tracking-tight">
|
||||
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>
|
||||
<button
|
||||
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" />
|
||||
Add Affiliate
|
||||
@ -155,7 +160,7 @@ export default function AffiliateManagementPage() {
|
||||
</div>
|
||||
|
||||
{/* 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">
|
||||
<MagnifyingGlassIcon className="absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400" />
|
||||
<input
|
||||
@ -169,7 +174,7 @@ export default function AffiliateManagementPage() {
|
||||
<select
|
||||
value={categoryFilter}
|
||||
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 => (
|
||||
<option key={cat} value={cat}>
|
||||
@ -181,7 +186,7 @@ export default function AffiliateManagementPage() {
|
||||
</header>
|
||||
|
||||
{/* 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="flex items-center gap-3">
|
||||
<div className="rounded-lg bg-blue-50 p-3">
|
||||
@ -222,7 +227,7 @@ export default function AffiliateManagementPage() {
|
||||
</div>
|
||||
|
||||
{/* 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 && (
|
||||
<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>
|
||||
@ -544,155 +549,155 @@ function CreateAffiliateModal({ onClose, onCreate }: { onClose: () => void; onCr
|
||||
onCropComplete={handleCropComplete}
|
||||
/>
|
||||
<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="sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between rounded-t-2xl">
|
||||
<h2 className="text-2xl font-bold text-blue-900">Add New Affiliate</h2>
|
||||
<button onClick={onClose} className="text-gray-500 hover:text-gray-700 transition">
|
||||
<XMarkIcon className="h-6 w-6" />
|
||||
</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 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-4 sm:px-6 py-3 sm:py-4 flex items-center justify-between rounded-none sm:rounded-t-2xl">
|
||||
<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">
|
||||
<XMarkIcon className="h-6 w-6" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<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">
|
||||
<form onSubmit={handleSubmit} className="p-4 sm:p-6 space-y-5 sm:space-y-6">
|
||||
<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>
|
||||
<label className="block text-sm font-medium text-blue-900 mb-2">Partner Name *</label>
|
||||
<input
|
||||
value={commissionRate}
|
||||
onChange={e => setCommissionRate(e.target.value)}
|
||||
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., 10%"
|
||||
placeholder="e.g., Coffee Equipment Co."
|
||||
/>
|
||||
</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>
|
||||
<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 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>
|
||||
<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>
|
||||
<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>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -808,154 +813,154 @@ function EditAffiliateModal({ affiliate, onClose, onUpdate }: {
|
||||
onCropComplete={handleCropComplete}
|
||||
/>
|
||||
<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="sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between rounded-t-2xl">
|
||||
<h2 className="text-2xl font-bold text-blue-900">Edit Affiliate</h2>
|
||||
<button onClick={onClose} className="text-gray-500 hover:text-gray-700 transition">
|
||||
<XMarkIcon className="h-6 w-6" />
|
||||
</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 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-4 sm:px-6 py-3 sm:py-4 flex items-center justify-between rounded-none sm:rounded-t-2xl">
|
||||
<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">
|
||||
<XMarkIcon className="h-6 w-6" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<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">
|
||||
<form onSubmit={handleSubmit} className="p-4 sm:p-6 space-y-5 sm:space-y-6">
|
||||
<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>
|
||||
<label className="block text-sm font-medium text-blue-900 mb-2">Partner Name *</label>
|
||||
<input
|
||||
value={commissionRate}
|
||||
onChange={e => setCommissionRate(e.target.value)}
|
||||
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 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>
|
||||
<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 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>
|
||||
<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>
|
||||
<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>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -969,7 +974,7 @@ function DeleteConfirmModal({ affiliateName, onClose, onConfirm, isDeleting }: {
|
||||
}) {
|
||||
return (
|
||||
<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="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" />
|
||||
@ -980,7 +985,7 @@ function DeleteConfirmModal({ affiliateName, onClose, onConfirm, isDeleting }: {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-3">
|
||||
<button
|
||||
onClick={onClose}
|
||||
disabled={isDeleting}
|
||||
|
||||
@ -48,36 +48,40 @@ export default function ContractManagementPage() {
|
||||
return (
|
||||
<PageLayout>
|
||||
<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">
|
||||
{/* Sidebar Navigation */}
|
||||
<nav className="md:w-56 w-full flex md:flex-col flex-row gap-2 md:gap-4">
|
||||
{NAV.map((item) => (
|
||||
<button
|
||||
key={item.key}
|
||||
onClick={() => setSection(item.key)}
|
||||
className={`flex items-center gap-2 px-4 py-2 rounded-lg font-medium transition
|
||||
${section === item.key
|
||||
? 'bg-blue-900 text-blue-50 shadow'
|
||||
: 'bg-white text-blue-900 hover:bg-blue-50 hover:text-blue-900 border border-blue-200'}`}
|
||||
>
|
||||
{item.icon}
|
||||
<span>{item.label}</span>
|
||||
</button>
|
||||
))}
|
||||
{/* tighter horizontal padding on mobile */}
|
||||
<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">
|
||||
{/* Sidebar Navigation (mobile = horizontal scroll tabs, desktop = vertical) */}
|
||||
<nav className="md:w-56 w-full md:self-start md:sticky md:top-6">
|
||||
<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">
|
||||
{NAV.map((item) => (
|
||||
<button
|
||||
key={item.key}
|
||||
onClick={() => setSection(item.key)}
|
||||
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
|
||||
${section === item.key
|
||||
? 'bg-blue-900 text-blue-50 shadow'
|
||||
: 'bg-white text-blue-900 hover:bg-blue-50 hover:text-blue-900 border border-blue-200'}`}
|
||||
>
|
||||
{item.icon}
|
||||
<span>{item.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* Main Content */}
|
||||
<main className="flex-1 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">
|
||||
<h1 className="text-4xl font-extrabold text-blue-900 tracking-tight">Contract Management</h1>
|
||||
<p className="text-lg text-blue-700">
|
||||
<main className="flex-1 space-y-6 md:space-y-8">
|
||||
{/* sticky only on md+; smaller padding/title on mobile */}
|
||||
<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">
|
||||
<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.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{/* Section Panels */}
|
||||
{/* Section Panels (compact padding on mobile) */}
|
||||
{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">
|
||||
<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
|
||||
@ -86,7 +90,7 @@ export default function ContractManagementPage() {
|
||||
</section>
|
||||
)}
|
||||
{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">
|
||||
<svg className="w-6 h-6" fill="none" stroke="currentColor"><path d="M4 6h16M4 12h16M4 18h16"/></svg>
|
||||
Templates
|
||||
@ -101,7 +105,7 @@ export default function ContractManagementPage() {
|
||||
</section>
|
||||
)}
|
||||
{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">
|
||||
<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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user