%PDF- %PDF-
Direktori : /home/opti/public_html/startup-life/assets/ |
Current File : /home/opti/public_html/startup-life/assets/CreateAdvert-5be40712.js |
import{j as e,d as w,e as H,u as P,r as u,Q as c}from"./index-5492fbe1.js";import{C as p}from"./index-2c4b8b3c.js";import{s as m}from"./style.module-d249dcf0.js";import{I as T}from"./index-fbb310b5.js";import V from"./DragDropBox-3f5c4e15.js";import{C as G}from"./index-fdf728e2.js";import{G as x}from"./Grid-edacc4c9.js";import{D as Q}from"./dashboard-footer-navigation-f658b457.js";import{u as W}from"./index.esm-1be9f6a3.js";import{S as z,a as J}from"./set-add-budget-cc045c98.js";import"./joinClasses-adfcc520.js";import"./Menu-c26e62ae.js";import"./useFormControl-45c447f9.js";import"./useForkRef-ff55d5c8.js";import"./TransitionGroupContext-29effe25.js";import"./setPrototypeOf-0bb37fbe.js";import"./Modal-01a2ce69.js";import"./useTheme-0dfa0cbc.js";import"./useSlotProps-b42d44e4.js";import"./index-e5978b8b.js";import"./Paper-26f2abc8.js";import"./ImgIcon-9b978e7d.js";import"./index-b50c944e.js";import"./tslib.es6-ace8e431.js";import"./Box-263f925f.js";import"./isNativeReflectConstruct-061ae640.js";import"./assertThisInitialized-081f9914.js";import"./use-isomorphic-layout-effect.browser.esm-1e1530e9.js";import"./styled-components.browser.esm-ee37ee23.js";import"./motion-4a110d9b.js";import"./useControlled-967f9278.js";import"./createSvgIcon-6a373a0a.js";import"./Checkbox-5f253e47.js";import"./SwitchBase-f9d84931.js";import"./ButtonBase-0400401d.js";const R=({control:s,setLogo:t,logo:a,handleLogoChange:r})=>e.jsx("form",{children:e.jsxs("div",{className:"grid grid-cols-2 gap-[40px]",children:[e.jsxs(x,{spacing:4,md:6,children:[e.jsx(x,{item:!0,md:12,sx:{mb:"1.5rem"},children:e.jsx(T,{name:"ad_title",label:"Ad Title",control:s,rules:{required:"Enter Ad Title"}})}),e.jsx(x,{item:!0,md:12,sx:{mb:"1.5rem"},children:e.jsx(T,{name:"ad_desc",label:"Write Something (max length 255)",control:s,rules:{required:"Write Ads Desc"}})}),e.jsx(x,{item:!0,md:6,sx:{mb:"1.5rem"},children:e.jsx(G,{options:[{label:"CREATE AWARENESS FOR YOUR STARTUPS/BUSINESS",value:"AWARENESS"},{label:"RAISE FUNDS FOR YOUR STARTUPS/BUSINESS",value:"RAISEFUNDS"},{label:"TAKE THE SERVICES YOU OFFER TO ELIGIBLE CLIENTS",value:"SERVICES"},{label:"GET PARTIES THAT SHARES SIMILAR INTEREST TO JOIN YOUR COMMUNITY",value:"COMMUNITY"},{label:"INFORM QUALIFIED CREATIVES THAT YOU ARE EMPLOYING",value:"JOBS"},{label:"OTHER",value:"AWARENESS"}],name:"campaign_objective",control:s,rules:{required:"Select your campaign objective"},label:"Picking a campaign objective is important to take your Ads to interested individuals"})})]}),e.jsx(x,{item:!0,md:6,children:e.jsx(V,{setLogo:t,logo:a,handleChange:r})})]})}),K=({control:s,logo:t,setLogo:a,handleLogoChange:r})=>e.jsxs("div",{children:[e.jsx("div",{className:m["advert-page-title"],children:"Quick Ads"}),e.jsx("div",{className:"text-[1rem] text-gray-400 mb-[20px]",children:"Strategically take your ads to interested parties"}),e.jsxs("div",{className:"text-[1rem] text-gray-400 mb-[20px]",children:["Note: that advert display is available both ",e.jsx("strong",{children:"In-app"})," and ",e.jsx("strong",{children:"In-Mail"})]}),e.jsx(R,{handleLogoChange:r,control:s,logo:t,setLogo:a})]}),X=({control:s,logo:t,setLogo:a,handleLogoChange:r})=>e.jsxs("div",{children:[e.jsx("div",{className:m["advert-page-title"],children:"Custom Ads"}),e.jsx("div",{className:"text-[1rem] text-gray-400 mb-[20px]",children:"Strategically take your ads to interested parties"}),e.jsxs("div",{className:"text-[1rem] text-gray-400 mb-[20px]",children:["Note: that advert display is available both ",e.jsx("strong",{children:"In-app"})," and ",e.jsx("strong",{children:"In-Mail"})]}),e.jsx(R,{control:s,handleLogoChange:r,logo:t,setLogo:a})]}),Z=({selectedAddOption:s,control:t,logo:a,setLogo:r,handleLogoChange:n})=>e.jsxs("div",{className:m["advert-page"],children:[e.jsx(p,{appear:s==="quick",children:e.jsx(K,{control:t,handleLogoChange:n,logo:a,setLogo:r})}),e.jsx(p,{appear:s==="custom",children:e.jsx(X,{logo:a,handleLogoChange:n,control:t,setLogo:r})})]}),$=({setSelectedAddOption:s,setSelectedCategory:t})=>e.jsxs("div",{className:"mb-[40px]",children:[e.jsx("div",{className:m["advert-page-title"],children:"ads category"}),e.jsxs("div",{onClick:()=>{s("quick"),t("quick")},className:m["quick-ads"],children:[e.jsx("h1",{children:"quick ads"}),e.jsx("p",{children:"Add a quick Ads with a minimum of N3000"})]}),e.jsxs("div",{className:m["custom-ads"],onClick:()=>{s("custom"),t("custom")},children:[e.jsx("h1",{children:"custom ads"}),e.jsx("p",{children:"Set your Ads preferences with Custom Ads"})]})]}),ee=()=>w({mutationFn:async a=>{var r;try{return(await H.post("https://startuplife.api.cube700.net/api/v1/advert",a)).data}catch(n){return(r=n.response)==null?void 0:r.data}}}),Fe=()=>{const s=P(),[t,a]=u.useState(""),[r,n]=u.useState(""),{control:g,watch:d,getValues:i,setValue:k}=W({mode:"onBlur"}),[j,v]=u.useState(null),[O,U]=u.useState([]),[h,q]=u.useState([]),[S,_]=u.useState([]),{mutateAsync:D,isLoading:F}=ee(),M=()=>{},B=l=>{v(l),console.log(l),k("banner",l)},L=l=>{var b,E,f,N,y,C,I;l.preventDefault(),console.log(i());const A={title:(b=d())==null?void 0:b.ad_title,description:(E=d())==null?void 0:E.ad_desc,banner:(f=d())==null?void 0:f.banner,campaign_objective:[(N=d())==null?void 0:N.campaign_objective],duration:(y=d())==null?void 0:y.duration,budget:(C=d())==null?void 0:C.budget,billing:(I=d())==null?void 0:I.billing,status:"INACTIVE",locations:["Nigeria"],demographics:h,type:r==="quick"?"QUICK_ADS":"CUSTOM_ADS"};console.log(A),D(A).then(o=>{if(console.log(o),o.statusCode===400||o.statusCode===401||o.statusCode===500){Array.isArray(o.message)?o.message.forEach(Y=>{c.error(Y)}):c.error("Request failed to complete. Try again shortly.");return}o.info.authorization_url&&(c.success("You will be redirected to facilitate payment for advert. If not, kindly visit yor adverts page to process the payment again",{autoClose:1e4}),setTimeout(()=>{window.open(o.info.authorization_url,"_blank")},3e3),s("/advert/all-adverts"))})};return e.jsxs("div",{className:m["advert-page"],children:[e.jsx(p,{appear:t==="quick"||t==="custom",children:e.jsx(Z,{control:g,logo:j,handleLogoChange:B,setLogo:v,selectedAddOption:t,setSelectedAddOption:a})}),e.jsx(p,{appear:t==="",children:e.jsx($,{setSelectedAddOption:a,setSelectedCategory:n})}),e.jsx(p,{appear:t==="set-target",children:e.jsx(z,{selectedLocation:O,handleSelectedLocation:U,selectedDemo:h,handleSelectedDemo:q,selectedAcc:S,handleSelectedAcc:_})}),e.jsx(p,{appear:t==="set-ads-budget",children:e.jsx(J,{control:g,handleChange:M})}),e.jsx(Q,{rowReverse:!1,backBtnText:"Cancel",continueBtnText:F?"loading...":"continue",hideCancelBtn:t==="",cancelEventHandler:()=>a(""),hideContinueBtn:t==="",continueEventHandler:l=>{if(t==="quick"||t==="custom"){if(console.log(i()),!i().ad_title||!i().ad_desc||!i().banner||!i().campaign_objective){c.error("Input fields cannot be empty");return}if(j===null){c.error("you have to select a logo");return}a("set-target")}else if(t==="set-target"){if(h===""||S.length===0){c.error("set ads target");return}a("set-ads-budget")}else if(t==="set-ads-budget"){if(!i().budget||!i().billing||!i().duration){c.error("Please fill all fields");return}L(l)}}})]})};export{Fe as default};