/* Me2You - Seller flow: Dashboard, Create Listing wizard */
/* global React, Icon, StatusTag, Price, Field, panelStyle, btnPrimary, btnGhost, btnSmall, PRODUCTS, SAMPLE_ORDERS */
const { useState } = React;
const SELLER_LISTINGS = [
{ id:1, title:'Hisense 32" Smart TV', price:1850, status:'live', views:342, orders:3, emoji:'', bg:'linear-gradient(135deg,#FFE7C8,#FFF6E9)' },
{ id:2, title:'Nike Air Max - UK 9', price:1200, status:'live', views:128, orders:1, emoji:'', bg:'linear-gradient(135deg,#DDF1E4,#FFF6E9)' },
{ id:3, title:'Defy Microwave 20L', price:850, status:'pending', views:0, orders:0, emoji:'', bg:'linear-gradient(135deg,#ECE6F2,#FFF6E9)' },
];
const SELLER_ORDERS = [
{ id:'M2Y-2026-00248', item:'Hisense 32" Smart TV', buyer:'Nomsa M.', status:'paid', total:1910, date:'28 Apr 2026' },
{ id:'M2Y-2026-00245', item:'Cast-iron pot, 4L', buyer:'Thandi K.', status:'dispatched', total:440, date:'26 Apr 2026' },
{ id:'M2Y-2026-00241', item:'Samsung Galaxy A14', buyer:'James R.', status:'completed', total:1460, date:'22 Apr 2026' },
];
function SellerDashboard({ onCreateListing, onNav }) {
const [tab, setTab] = useState('overview');
const [onVacation, setOnVacation] = useState(false);
const [awayFrom, setAwayFrom] = useState('26 May 2026');
const [backOn, setBackOn] = useState('3 Jun 2026');
const [vacationMsg, setVacationMsg] = useState('Away at a family event. Watching the shop, will reply on 3 June. Thanks for your patience.');
const [savedSettings, setSavedSettings] = useState(false);
const stats = [
{ label:'Revenue (30d)', value:'R 3 810', icon:'wallet' },
{ label:'Active listings', value:'2', icon:'package' },
{ label:'Orders (30d)', value:'5', icon:'receipt' },
{ label:'Rating', value:'4.8 ', icon:'star' },
];
return (
Seller dashboard
Welcome back, Thandi Q.
{['overview','listings','orders','settings'].map(t => (
))}
{tab === 'overview' && (
Recent orders
{SELLER_ORDERS.map(o => (
{o.item}
{o.id} - {o.buyer} - {o.date}
))}
)}
{tab === 'listings' && (
{onVacation && (
Vacation mode is on
New orders are paused until {backOn}. Every listing below shows a "Back soon" badge to buyers.
)}
{SELLER_LISTINGS.map(l => (
{l.title}
{onVacation && (
Back {backOn}
)}
))}
)}
{tab === 'orders' && (
| Reference | Item | Buyer |
Status | Total |
{SELLER_ORDERS.map(o => (
| {o.id} |
{o.item} |
{o.buyer} |
|
|
))}
)}
{tab === 'settings' && (
Availability
Pause new orders while you are away. Buyers still see your shop, marked as "Back soon".
Vacation mode
Pause new orders. Buyers still see listings, marked as "Back soon".
{onVacation && (
<>
setAwayFrom(e.target.value)}/>
setBackOn(e.target.value)}/>
Buyers still see your shop. Lay-bye plans already running keep going as normal.
>
)}
{savedSettings && (
Saved. {onVacation ? `Your shop shows "Back ${backOn}".` : 'Vacation mode is off.'}
)}
)}
);
}
/* --- Create Listing --- */
function CreateListing({ onBack, onPublish }) {
const [step, setStep] = useState(1);
return (
Sell something
Takes about 4 minutes. New listings go to moderation; live within 1 business day.
{['Details','Photos','Review'].map((s,i) => (
))}
{step === 1 && (
)}
{step === 2 && (
)}
{step === 3 && (
Ready to publish?
Your listing will go to moderation and be live within 1 business day. You'll get a shareable WhatsApp link once approved.
)}
);
}
const thStyle = { padding:'10px 16px',fontFamily:'var(--font-mono)',fontSize:11,fontWeight:600,color:'var(--ink-500)',textTransform:'uppercase',letterSpacing:'.06em' };
const tdStyle = { padding:'12px 16px' };
/* --- Image Uploader --- */
function ImageUploader() {
const [files, setFiles] = useState([]);
const inputRef = useRef(null);
const handleFiles = (selected) => {
const arr = Array.from(selected).slice(0, 6 - files.length);
const promises = arr.map(f => new Promise(res => {
const r = new FileReader();
r.onload = () => res({ name: f.name, size: f.size, url: r.result });
r.readAsDataURL(f);
}));
Promise.all(promises).then(loaded => setFiles(prev => [...prev, ...loaded].slice(0,6)));
};
const removeFile = (idx) => setFiles(prev => prev.filter((_,i) => i !== idx));
return (
handleFiles(e.target.files)} style={{display:'none'}}/>
{files.length === 0 ? (
inputRef.current?.click()}
onDragOver={e => { e.preventDefault(); e.currentTarget.style.background='var(--brand-orange-100)'; }}
onDragLeave={e => e.currentTarget.style.background='transparent'}
onDrop={e => { e.preventDefault(); e.currentTarget.style.background='transparent'; handleFiles(e.dataTransfer.files); }}
style={{border:'1.5px dashed var(--brand-orange)',borderRadius:'var(--radius-lg)',padding:48,textAlign:'center',
background:'repeating-linear-gradient(45deg,var(--brand-orange-50),var(--brand-orange-50) 8px,transparent 8px,transparent 16px)',
color:'var(--brand-orange-700)',cursor:'pointer',transition:'background .15s'}}>
Tap to upload photos
or drag & drop - JPG - PNG - WebP - up to 6 images - max 2 MB each
) : (
{files.map((f,i) => (

{i === 0 && (
COVER
)}
{(f.size/1024).toFixed(0)} KB
))}
{files.length < 6 && (
)}
{files.length} of 6 photos - first photo is the cover
)}
);
}
Object.assign(window, { SellerDashboard, CreateListing });