๐Ÿš€ Deploy New Client Site

โ† Back to Dashboard

๐Ÿ“‹ Client Information

Becomes: [name].netlify.app

๐ŸŽจ Select Template

๐Ÿš—
Auto Detailing
๐Ÿ’ช
Personal Training
๐Ÿพ
Pet Grooming
๐Ÿงน
House Cleaning

๐Ÿš€ Deploy

'; } async function sha1(str){ var buf=new TextEncoder().encode(str); var hash=await crypto.subtle.digest('SHA-1',buf); return Array.from(new Uint8Array(hash)).map(function(b){return b.toString(16).padStart(2,'0')}).join(''); } async function deploySite(){ var name=document.getElementById('bizName').value.trim(); var site=document.getElementById('siteName').value.trim().toLowerCase().replace(/[^a-z0-9-]/g,''); var phone=document.getElementById('bizPhone').value.trim(); var email=document.getElementById('bizEmail').value.trim(); var hours=document.getElementById('bizHours').value.trim()||'Mon-Sat 9am-5pm'; if(!name||!site||!phone||!email){ showResult('Please fill in all required fields',true); return; } var btn=document.getElementById('deployBtn'); btn.disabled=true; btn.textContent='Deploying...'; document.getElementById('deployLog').innerHTML=''; document.getElementById('deployResult').style.display='none'; log('Starting deployment: '+name,'info'); try{ log('Creating site: '+site+'.netlify.app','info'); var res=await fetch('https://api.netlify.com/api/v1/sites',{ method:'POST', headers:{'Authorization':'Bearer '+TOKEN,'Content-Type':'application/json'}, body:JSON.stringify({name:site}) }); var data=await res.json(); if(!res.ok){ if(JSON.stringify(data).includes('unique')||JSON.stringify(data).includes('taken')){ log('Name taken, adding suffix...','info'); site=site+'-'+Math.random().toString(36).substr(2,4); res=await fetch('https://api.netlify.com/api/v1/sites',{ method:'POST', headers:{'Authorization':'Bearer '+TOKEN,'Content-Type':'application/json'}, body:JSON.stringify({name:site}) }); data=await res.json(); if(!res.ok)throw new Error(JSON.stringify(data)); }else{ throw new Error(JSON.stringify(data)); } } log('โœ“ Site created: '+data.name,'success'); var siteId=data.site_id||data.id; log('Generating HTML...','info'); var html=getHTML({name:name,type:selectedType,phone:phone,email:email,hours:hours}); log('Creating deploy...','info'); var hash=await sha1(html); var depRes=await fetch('https://api.netlify.com/api/v1/sites/'+siteId+'/deploys',{ method:'POST', headers:{'Authorization':'Bearer '+TOKEN,'Content-Type':'application/json'}, body:JSON.stringify({files:{'/index.html':hash}}) }); var depData=await depRes.json(); if(!depRes.ok)throw new Error('Deploy failed'); log('Uploading...','info'); var upRes=await fetch('https://api.netlify.com/api/v1/deploys/'+depData.id+'/files/index.html',{ method:'PUT', headers:{'Authorization':'Bearer '+TOKEN,'Content-Type':'application/octet-stream'}, body:html }); if(!upRes.ok)throw new Error('Upload failed'); log('โœ“ LIVE!','success'); var url='https://'+data.name+'.netlify.app'; showResult('

๐ŸŽ‰ Deployed!

Live: '+url+'

Admin: Netlify Dashboard

',false); }catch(e){ log('ERROR: '+e.message,'error'); showResult('Failed: '+e.message,true); } btn.disabled=false; btn.textContent='๐Ÿš€ Deploy to Netlify'; }