| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/elite-events-storybook/ |
Upload File : |
"use strict";(self.webpackChunkelite_events_nextjs=self.webpackChunkelite_events_nextjs||[]).push([[4645],{"./src/components/features/user/affiliate/AffiliateDashboard/index.tsx":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{A:()=>AffiliateDashboard});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("./node_modules/next/dist/compiled/react/jsx-runtime.js"),react__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("./node_modules/next/dist/compiled/react/index.js"),_components_ui_icons_Icon__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("./src/components/ui/icons/Icon.tsx"),_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("./src/lib/logging/clientLogger.ts");const TIER_COLORS={BRONZE:"bg-amber-600",SILVER:"bg-gray-400",GOLD:"bg-yellow-500",PLATINUM:"bg-purple-500"},STATUS_COLORS={PENDING:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",ACTIVE:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",APPROVED:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",REJECTED:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",PAID:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",PROCESSING:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",COMPLETED:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",CANCELLED:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200"};function AffiliateDashboard({className=""}){const[activeTab,setActiveTab]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)("dashboard"),[affiliate,setAffiliate]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null),[dashboard,setDashboard]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null),[sales,setSales]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)([]),[payouts,setPayouts]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)([]),[pagination,setPagination]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)({page:1,limit:20,total:0,totalPages:0}),[loading,setLoading]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(!0),[error,setError]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null),[successMessage,setSuccessMessage]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null),[showRegisterForm,setShowRegisterForm]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(!1),[registerData,setRegisterData]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)({website:"",bio:"",payoutMethod:""}),[settingsData,setSettingsData]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)({website:"",bio:"",payoutMethod:""}),[savingSettings,setSavingSettings]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(!1),[copied,setCopied]=(0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(!1),fetchAffiliateData=(0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(async()=>{setLoading(!0);try{const response=await fetch("/api/user/affiliate"),data=await response.json();data.success?data.data&&(setAffiliate(data.data.affiliate),setDashboard(data.data.dashboard),setSettingsData({website:data.data.affiliate.website||"",bio:data.data.affiliate.bio||"",payoutMethod:data.data.affiliate.payoutMethod||""})):setError(data.error)}catch(err){setError("Failed to fetch affiliate data"),_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__.q.error("Failed to fetch affiliate data",err instanceof Error?err:new Error(String(err)))}finally{setLoading(!1)}},[]),fetchSales=(0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(async()=>{try{const params=new URLSearchParams({page:pagination.page.toString(),limit:pagination.limit.toString()}),response=await fetch(`/api/user/affiliate/sales?${params}`),data=await response.json();data.success?(setSales(data.data),setPagination(data.pagination)):setError(data.error)}catch(err){setError("Failed to fetch sales"),_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__.q.error("Failed to fetch sales",err instanceof Error?err:new Error(String(err)))}},[pagination.page,pagination.limit]),fetchPayouts=(0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(async()=>{try{const params=new URLSearchParams({page:pagination.page.toString(),limit:pagination.limit.toString()}),response=await fetch(`/api/user/affiliate/payouts?${params}`),data=await response.json();data.success?(setPayouts(data.data),setPagination(data.pagination)):setError(data.error)}catch(err){setError("Failed to fetch payouts"),_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__.q.error("Failed to fetch payouts",err instanceof Error?err:new Error(String(err)))}},[pagination.page,pagination.limit]);(0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{fetchAffiliateData()},[fetchAffiliateData]),(0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{affiliate&&("sales"===activeTab?fetchSales():"payouts"===activeTab&&fetchPayouts())},[activeTab,affiliate,fetchSales,fetchPayouts]);const handleRegister=async e=>{e.preventDefault(),setLoading(!0);try{const response=await fetch("/api/user/affiliate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(registerData)}),data=await response.json();data.success?(setSuccessMessage("Registration submitted successfully! Your application is pending review."),setShowRegisterForm(!1),fetchAffiliateData()):setError(data.error)}catch(err){setError("Failed to register as affiliate"),_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__.q.error("Failed to register as affiliate",err instanceof Error?err:new Error(String(err)))}finally{setLoading(!1)}},handleSaveSettings=async e=>{e.preventDefault(),setSavingSettings(!0);try{const response=await fetch("/api/user/affiliate",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(settingsData)}),data=await response.json();data.success?(setSuccessMessage("Settings saved successfully!"),fetchAffiliateData()):setError(data.error)}catch(err){setError("Failed to save settings"),_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__.q.error("Failed to save settings",err instanceof Error?err:new Error(String(err)))}finally{setSavingSettings(!1)}},handleRequestPayout=async()=>{try{const response=await fetch("/api/user/affiliate/payouts",{method:"POST"}),data=await response.json();data.success?(setSuccessMessage("Payout request submitted successfully!"),fetchAffiliateData(),fetchPayouts()):setError(data.error)}catch(err){setError("Failed to request payout"),_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__.q.error("Failed to request payout",err instanceof Error?err:new Error(String(err)))}},formatCurrency=amount=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(amount),formatDate=dateString=>new Date(dateString).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});if(!loading&&!affiliate)return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:`space-y-6 ${className}`,children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-center py-12",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons_Icon__WEBPACK_IMPORTED_MODULE_2__.I,{name:"users",className:"w-16 h-16 mx-auto text-gray-400 dark:text-gray-600 mb-4"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:"Join Our Affiliate Program"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-gray-500 dark:text-gray-400 mb-6 max-w-md mx-auto",children:"Earn commissions by referring customers to our platform. Share your unique link and earn money for every sale!"}),showRegisterForm?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"max-w-md mx-auto bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form",{onSubmit:handleRegister,className:"space-y-4 text-left",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Website (optional)"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("input",{type:"url",value:registerData.website,onChange:e=>setRegisterData({...registerData,website:e.target.value}),className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-3 py-2 text-sm",placeholder:"https://yourwebsite.com"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Bio (optional)"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("textarea",{value:registerData.bio,onChange:e=>setRegisterData({...registerData,bio:e.target.value}),rows:3,className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-3 py-2 text-sm",placeholder:"Tell us about yourself..."})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Preferred Payout Method"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("select",{value:registerData.payoutMethod,onChange:e=>setRegisterData({...registerData,payoutMethod:e.target.value}),className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-3 py-2 text-sm",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"",children:"Select..."}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"paypal",children:"PayPal"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"bank_transfer",children:"Bank Transfer"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"crypto",children:"Cryptocurrency"})]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex gap-2",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{type:"button",onClick:()=>setShowRegisterForm(!1),className:"flex-1 px-4 py-2 rounded border border-gray-300 dark:border-gray-600 text-sm hover:bg-gray-100 dark:hover:bg-gray-700",children:"Cancel"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{type:"submit",disabled:loading,className:"flex-1 px-4 py-2 bg-blue-600 text-white rounded text-sm hover:bg-blue-700 disabled:opacity-50",children:loading?"Submitting...":"Apply Now"})]})]})}):(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{onClick:()=>setShowRegisterForm(!0),className:"px-6 py-3 bg-blue-600 text-white rounded-lg text-lg hover:bg-blue-700",children:"Become an Affiliate"})]})});if("PENDING"===affiliate?.status)return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:`space-y-6 ${className}`,children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-center py-12",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons_Icon__WEBPACK_IMPORTED_MODULE_2__.I,{name:"clock",className:"w-16 h-16 mx-auto text-yellow-500 dark:text-yellow-400 mb-4"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:"Application Pending"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-gray-500 dark:text-gray-400 mb-6 max-w-md mx-auto",children:"Your affiliate application is being reviewed. We'll notify you once it's approved."}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-sm text-gray-400",children:["Applied on ",formatDate(affiliate.createdAt)]})]})});if("SUSPENDED"===affiliate?.status||"REJECTED"===affiliate?.status)return(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:`space-y-6 ${className}`,children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-center py-12",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons_Icon__WEBPACK_IMPORTED_MODULE_2__.I,{name:"alert-circle",className:"w-16 h-16 mx-auto text-red-500 dark:text-red-400 mb-4"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:["Account ","SUSPENDED"===affiliate.status?"Suspended":"Rejected"]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-gray-500 dark:text-gray-400 mb-6 max-w-md mx-auto",children:"SUSPENDED"===affiliate.status?"Your affiliate account has been suspended. Please contact support for more information.":"Your affiliate application was not approved. Please contact support if you have questions."})]})});return loading&&!affiliate?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"flex justify-center items-center h-64",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:`space-y-6 ${className}`,children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center justify-between",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Affiliate Dashboard"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Track your referrals, earnings, and payouts"})]}),affiliate&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span",{className:`inline-flex items-center px-3 py-1 rounded-full text-sm font-medium text-white ${TIER_COLORS[affiliate.tier]}`,children:[affiliate.tier," Affiliate"]})]}),error&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-red-100 dark:bg-red-900 border border-red-400 dark:border-red-700 text-red-700 dark:text-red-200 px-4 py-3 rounded",children:[error,(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{onClick:()=>setError(null),className:"float-right font-bold",children:"×"})]}),successMessage&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-green-100 dark:bg-green-900 border border-green-400 dark:border-green-700 text-green-700 dark:text-green-200 px-4 py-3 rounded",children:[successMessage,(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{onClick:()=>setSuccessMessage(null),className:"float-right font-bold",children:"×"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("nav",{className:"flex -mb-px gap-4",children:["dashboard","sales","payouts","settings"].map(tab=>(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{onClick:()=>{setActiveTab(tab),setPagination(p=>({...p,page:1}))},className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors "+(activeTab===tab?"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"),children:tab.charAt(0).toUpperCase()+tab.slice(1)},tab))})}),"dashboard"===activeTab&&(affiliate&&dashboard?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"space-y-6",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Your Referral Link"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex gap-2",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("input",{type:"text",readOnly:!0,value:affiliate.referralUrl,className:"flex-1 rounded-md border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 px-3 py-2 text-sm"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{onClick:()=>(async text=>{try{await navigator.clipboard.writeText(text),setCopied(!0),setTimeout(()=>setCopied(!1),2e3)}catch(err){_lib_logging_clientLogger__WEBPACK_IMPORTED_MODULE_3__.q.error("Failed to copy to clipboard",err instanceof Error?err:new Error(String(err)))}})(affiliate.referralUrl),className:"px-4 py-2 bg-blue-600 text-white rounded text-sm hover:bg-blue-700",children:copied?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons_Icon__WEBPACK_IMPORTED_MODULE_2__.I,{name:"check",className:"w-4 h-4"}):(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons_Icon__WEBPACK_IMPORTED_MODULE_2__.I,{name:"copy",className:"w-4 h-4"})})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:["Share this link to earn ",affiliate.commissionRate,"% commission on referred sales"]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center justify-between",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Total Earnings"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium text-white ${TIER_COLORS[affiliate.tier]}`,children:affiliate.tier})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:formatCurrency(affiliate.totalEarnings)})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Pending Earnings"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-2xl font-bold text-yellow-600 dark:text-yellow-400",children:formatCurrency(affiliate.pendingEarnings)}),affiliate.pendingEarnings>=affiliate.minimumPayout&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{onClick:handleRequestPayout,className:"mt-2 px-3 py-1 bg-green-600 text-white rounded text-xs hover:bg-green-700",children:"Request Payout"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Total Clicks"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:affiliate.totalClicks.toLocaleString()}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-xs text-green-600 dark:text-green-400",children:["+",dashboard.stats.clicksToday," today"]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Conversion Rate"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:[affiliate.conversionRate.toFixed(2),"%"]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[affiliate.totalConversions," conversions"]})]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-4",children:"Recent Clicks"}),0===dashboard.recentClicks.length?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No clicks yet"}):(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"space-y-2",children:dashboard.recentClicks.slice(0,5).map(click=>(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center gap-2",children:[click.converted?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components_ui_icons_Icon__WEBPACK_IMPORTED_MODULE_2__.I,{name:"check-circle",className:"w-4 h-4 text-green-500"}):(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:"w-4 h-4 rounded-full border-2 border-gray-400 inline-block"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:"text-gray-700 dark:text-gray-300 truncate max-w-[150px]",children:click.landingPage||"/"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:"text-gray-500 dark:text-gray-400 text-xs",children:formatDate(click.clickedAt)})]},click.id))})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-4",children:"Recent Sales"}),0===dashboard.recentSales.length?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No sales yet"}):(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"space-y-2",children:dashboard.recentSales.slice(0,5).map(sale=>(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"flex items-center gap-2",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:`px-2 py-0.5 rounded text-xs ${STATUS_COLORS[sale.status]}`,children:sale.status}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span",{className:"text-gray-700 dark:text-gray-300",children:["Order #",sale.orderId]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["+",formatCurrency(sale.commissionAmount)]})]},sale.id))})]})]})]}):null),"sales"===activeTab&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"space-y-4",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"overflow-x-auto",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("thead",{className:"bg-gray-50 dark:bg-gray-700",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("tr",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Order"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Order Total"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Commission"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Status"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Date"})]})}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:0===sales.length?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("tr",{children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{colSpan:5,className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:"No sales yet"})}):sales.map(sale=>(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:["#",sale.orderId]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-right text-sm text-gray-700 dark:text-gray-300",children:formatCurrency(sale.orderTotal)}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("td",{className:"px-4 py-3 whitespace-nowrap text-right text-sm text-green-600 dark:text-green-400 font-medium",children:["+",formatCurrency(sale.commissionAmount)]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("td",{className:"px-4 py-3 whitespace-nowrap",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:`px-2 py-0.5 rounded text-xs ${STATUS_COLORS[sale.status]}`,children:sale.status}),sale.rejectionReason&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"text-xs text-red-500 mt-1",children:sale.rejectionReason})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:formatDate(sale.createdAt)})]},sale.id))})]})})})}),"payouts"===activeTab&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"space-y-4",children:[affiliate&&affiliate.pendingEarnings>=affiliate.minimumPayout&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 flex items-center justify-between",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"font-medium text-green-800 dark:text-green-200",children:["You have ",formatCurrency(affiliate.pendingEarnings)," available for payout"]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"text-sm text-green-600 dark:text-green-400",children:["Minimum payout: ",formatCurrency(affiliate.minimumPayout)]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{onClick:handleRequestPayout,className:"px-4 py-2 bg-green-600 text-white rounded text-sm hover:bg-green-700",children:"Request Payout"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"overflow-x-auto",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("thead",{className:"bg-gray-50 dark:bg-gray-700",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("tr",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"ID"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Amount"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Method"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Status"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Requested"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase",children:"Processed"})]})}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:0===payouts.length?(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("tr",{children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-gray-500 dark:text-gray-400",children:"No payouts yet"})}):payouts.map(payout=>(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:["#",payout.id]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-right text-sm font-medium text-gray-900 dark:text-white",children:formatCurrency(payout.amount)}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:payout.method||"N/A"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{className:"px-4 py-3 whitespace-nowrap",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span",{className:`px-2 py-0.5 rounded text-xs ${STATUS_COLORS[payout.status]}`,children:payout.status})}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:formatDate(payout.requestedAt)}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-sm text-gray-700 dark:text-gray-300",children:payout.processedAt?formatDate(payout.processedAt):"-"})]},payout.id))})]})})})]}),"settings"===activeTab&&(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div",{className:"max-w-lg",children:(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-4",children:"Profile Settings"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form",{onSubmit:handleSaveSettings,className:"space-y-4",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Affiliate Code"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("input",{type:"text",value:affiliate?.code||"",readOnly:!0,className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 px-3 py-2 text-sm"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Website"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("input",{type:"url",value:settingsData.website,onChange:e=>setSettingsData({...settingsData,website:e.target.value}),className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-3 py-2 text-sm",placeholder:"https://yourwebsite.com"})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Bio"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("textarea",{value:settingsData.bio,onChange:e=>setSettingsData({...settingsData,bio:e.target.value}),rows:3,className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-3 py-2 text-sm",placeholder:"Tell us about yourself..."})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div",{children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Payout Method"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("select",{value:settingsData.payoutMethod,onChange:e=>setSettingsData({...settingsData,payoutMethod:e.target.value}),className:"w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-3 py-2 text-sm",children:[(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"",children:"Select..."}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"paypal",children:"PayPal"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"bank_transfer",children:"Bank Transfer"}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("option",{value:"crypto",children:"Cryptocurrency"})]})]}),(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button",{type:"submit",disabled:savingSettings,className:"w-full px-4 py-2 bg-blue-600 text-white rounded text-sm hover:bg-blue-700 disabled:opacity-50",children:savingSettings?"Saving...":"Save Settings"})]})]})})]})}}}]);