1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3966],{38991:function(e,a,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/ugc/createnews",function(){return s(29082)}])},77128:function(e,a,s){"use strict";s.d(a,{x:function(){return UGCNavbar}});var l=s(85893),t=s(67294),i=s(41664),r=s.n(i),n=s(40287),c=s(10840),o=s.n(c),d=s(25675),m=s.n(d),u=s(19451),h=s(11163),x=s(24169);let UGCNavbar=()=>{let e=(0,u.v0)(),a=(0,t.useContext)(x.S),s=null==a?void 0:a.user,i=(0,h.useRouter)(),signOut=async()=>{await e.signOut(),await i.push("/")};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("header",{className:"navbar sticky-top flex-md-nowrap p-0 shadow ","data-bs-theme":"dark",children:[(0,l.jsx)(r(),{className:"navbar-brand ".concat(o().brand," col-md-3 col-lg-2 me-0 px-3 "),href:"/ugc/dashboard",children:(0,l.jsx)(m(),{className:o().logo,src:n.Z,alt:"TechShots Logo",height:50,width:230})}),(0,l.jsx)("ul",{className:"navbar-nav flex-row d-lg-none",children:(0,l.jsx)("li",{className:"nav-item text-nowrap",children:(0,l.jsx)("button",{className:"nav-link px-3 btn btn-light",type:"button","data-bs-toggle":"offcanvas","data-bs-target":"#sidebarMenu","aria-controls":"sidebarMenu","aria-expanded":"false","aria-label":"Toggle navigation",children:(0,l.jsx)("span",{className:"navbar-toggler-icon"})})})}),(0,l.jsx)("div",{id:"navbarSearch",className:"navbar-search w-100 collapse",children:(0,l.jsx)("input",{className:"form-control w-100 rounded-0 border-0",type:"text",placeholder:"Search","aria-label":"Search"})})]}),(0,l.jsx)("div",{className:"sidebar border border-right col-lg-2 p-0 bg-body-tertiary",children:(0,l.jsxs)("div",{className:"offcanvas-lg offcanvas-end bg-body-tertiary",tabIndex:-1,id:"sidebarMenu","aria-labelledby":"sidebarMenuLabel",children:[(0,l.jsxs)("div",{className:"offcanvas-header",children:[(0,l.jsx)("h5",{className:"offcanvas-title w-100",id:"offcanvasNavbarLabel",children:s?(0,l.jsx)("div",{className:"border-bottom ",children:(0,l.jsxs)("h4",{children:["Hello, ",s.name]})}):(0,l.jsx)(r(),{className:"navbar-brand ".concat(o().brand," m-0 "),href:"/",children:(0,l.jsx)(m(),{className:o().logo,src:n.Z,alt:"TechShots Logo",height:60,width:250})})}),(0,l.jsx)("button",{type:"button",className:"btn-close","data-bs-dismiss":"offcanvas","data-bs-target":"#sidebarMenu","aria-label":"Close"})]}),(0,l.jsxs)("div",{className:"offcanvas-body d-md-flex flex-column p-0 pt-lg-3 overflow-y-auto",children:[(0,l.jsxs)("ul",{className:"nav flex-column",children:[(0,l.jsx)("li",{className:"nav-item",children:(0,l.jsx)(r(),{className:"nav-link d-flex align-items-center gap-2 active","aria-current":"page",href:"/ugc/dashboard",children:"UGC Home"})}),(0,l.jsx)("li",{className:"nav-item",children:(0,l.jsx)(r(),{className:"nav-link d-flex align-items-center gap-2 active","aria-current":"page",href:"/ugc/createnews",children:"Create News"})}),(0,l.jsx)("li",{className:"nav-item",children:(0,l.jsx)(r(),{className:"nav-link d-flex align-items-center gap-2 active","aria-current":"page",href:"/ugc/myarticles",children:"My articles"})})]}),(0,l.jsx)("hr",{className:"my-3"}),(0,l.jsx)("ul",{className:"nav flex-column mb-auto",children:(0,l.jsx)("li",{className:"nav-item",children:(0,l.jsx)("button",{className:"btn btn-link text-center ",onClick:signOut,children:"Sign Out"})})})]})]})})]})}},29082:function(e,a,s){"use strict";s.r(a);var l=s(85893),t=s(67294),i=s(60283),r=s(46634),n=s(33139),c=s(77128),o=s(87536),d=s(56312),m=s(25675),u=s.n(m),h=s(1764),x=s(30192),f=s(64759),b=s.n(f),g=s(3421),v=s(16976),j=s(5054),p=s(19451),N=s(24169),w=s(62734);let fetcher=e=>fetch(e).then(e=>e.json()),y=h.p.extend({is_featured:w.O7().optional().default(!1),notify_user:w.O7().optional().default(!1)});a.default=()=>{let e=(0,t.useContext)(N.S),a=null==e?void 0:e.user,[s,m]=(0,t.useState)(!1),[h,f]=(0,t.useState)([]),[w,_]=(0,t.useState)(),[S,T]=(0,t.useState)([]),[k,C]=(0,t.useState)(void 0),[U,F]=(0,t.useState)(""),[M,P]=(0,t.useState)([]),[L,I]=(0,t.useState)(!1),[E,O]=(0,t.useState)(""),{data:R}=(0,v.ZP)("/api/tags",fetcher);(0,t.useEffect)(()=>{R&&P(R)},[R]);let{register:H,handleSubmit:B,formState:{errors:V},reset:A}=(0,o.cI)({resolver:(0,d.F)(y),defaultValues:{is_featured:!1,notify_user:!1}}),onSubmit=async e=>{if(F(""),!w){C(" Please Select Image or Video "),F("Validation failed: selectedMedia is missing");return}if(0===h.length){C(" Please Select Categories "),F("Validation failed: categories are missing");return}
1if(0===S.length){C(" Please Select Tags"),F("Validation failed: tags are missing");return}m(!0);try{let t=w;if("Image"===w.mediaType&&!1===w.fromSelector){let{URL:a,name:s}=await (0,x.Z)(e.main_title),l=w.media,i=await fetch(a,{method:"PUT",headers:{"Content-Type":l.type||"image/webp"},body:l});if(!i.ok){C("Image upload failed. Please try again."),F("Upload failed: PUT signed URL returned ".concat(i.status)),m(!1);return}t={mediaType:"Image",media:"https://d3vnc3w6v6jm99.cloudfront.net/"+s,fromSelector:!1}}let i={...e,is_featured:!1,notify_user:!1,selectedMedia:t,categories:h,tags:S,isLong:!1,long_description:""};L&&(i={...i,isLong:!0,long_description:E});let r=(0,p.v0)(),n=r.currentUser,c=n?await n.getIdToken():"";if(!c&&!a){C("Please login again and try."),F("Auth failed: no Firebase token and no UserContext user present"),m(!1);return}let o={"Content-Type":"application/json"};c&&(o.Authorization="Bearer ".concat(c));let d=await fetch("/api/ugc/news",{method:"POST",headers:o,body:JSON.stringify({news:i,user:a?{uid:a.uid,email:a.email,role:a.role}:void 0})});if(!d.ok){var s,l;let e=await d.json().catch(()=>null),t=null!==(s=null==e?void 0:e.message)&&void 0!==s?s:"Failed to create news";C(t),F(["Create route failed","API: /api/ugc/news","HTTP: ".concat(d.status),"TokenPresent: ".concat(c?"yes":"no"),"UserContextPresent: ".concat(a?"yes":"no"),"UserUID: ".concat(null!==(l=null==a?void 0:a.uid)&&void 0!==l?l:"none"),"BackendMessage: ".concat(t)].join("\n")),m(!1);return}A(),f([]),_(void 0),T([]),I(!1),O(""),C(void 0)}catch(a){console.error("Create news flow failed:",a);let e=a instanceof Error?a.message:"Failed to create news";C(e),F(["Create flow exception","API: /api/ugc/news","Token/User fallback used","Exception: ".concat(e)].join("\n"))}finally{m(!1)}};return(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("div",{className:"container-fluid",children:(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)(c.x,{}),(0,l.jsxs)("div",{className:"col-lg-5 col-md-6",children:[k&&(0,l.jsxs)("div",{className:"alert alert-danger",role:"alert",children:[(0,l.jsx)("div",{children:k}),U?(0,l.jsx)("pre",{style:{marginTop:"8px",marginBottom:0,whiteSpace:"pre-wrap",fontSize:"12px"},children:U}):null]}),(0,l.jsxs)("form",{onSubmit:B(onSubmit),children:[(0,l.jsx)("div",{className:"row",children:(0,l.jsx)("div",{className:"col-12",children:(0,l.jsxs)("button",{className:"btn btn-dark w-100 mt-2 mb-2",type:"submit",children:["Create News",s&&(0,l.jsx)("div",{className:"".concat(b().ldsDualRing)})]})})}),(0,l.jsxs)("div",{className:"form-group",children:[(0,l.jsx)("label",{htmlFor:"mainTitle",children:"Main Title:"}),(0,l.jsx)("input",{...H("main_title"),type:"text",className:V.main_title?"form-control is-invalid":"form-control",id:"mainTitle","aria-describedby":"emailHelp",placeholder:"Enter Main Title",name:"main_title"}),V.main_title&&(0,l.jsx)("div",{className:"invalid-feedback d-block",children:(0,l.jsx)("small",{children:V.main_title.message})})]}),(0,l.jsxs)("div",{className:"form-group",children:[(0,l.jsx)("label",{htmlFor:"footerTitle",children:"Footer Title:"}),(0,l.jsx)("input",{...H("redirect_title1"),type:"text",className:V.redirect_title1?"form-control is-invalid":"form-control",id:"footerTitle","aria-describedby":"emailHelp",placeholder:"Swipe Left to Read Full Story",name:"redirect_title1"}),V.redirect_title1&&(0,l.jsx)("div",{className:"invalid-feedback d-block",children:(0,l.jsx)("small",{children:V.redirect_title1.message})})]}),(0,l.jsxs)("div",{className:"form-group mt-2",children:[(0,l.jsx)("label",{htmlFor:"footerSubTitle",children:"Footer Sub Title:"}),(0,l.jsx)("input",{...H("redirect_title2"),type:"text",className:V.redirect_title2?"form-control is-invalid":"form-control",id:"footerSubTitle","aria-describedby":"emailHelp",placeholder:"Enter Footer Sub Title",name:"redirect_title2"}),V.redirect_title2&&(0,l.jsx)("div",{className:"invalid-feedback d-block",children:(0,l.jsx)("small",{children:V.redirect_title2.message})})]}),(0,l.jsxs)("div",{className:"form-group",children:[(0,l.jsx)("label",{htmlFor:"exampleFormControlTextarea1",children:"News Body:"}),(0,l.jsx)("textarea",{...H("short_description"),className:V.short_description?"form-control is-invalid":"form-control",id:"exampleFormControlTextarea1",rows:5,name:"short_description"}),V.short_description&&(0,l.jsx)("div",{className:"invalid-feedback d-block",children:(0,l.jsx)("small",{children:V.short_description.message})})]}),(0,l.jsx)("div",{className:"row",children:(0,l.jsx)("div",{className:"col-md-6",children:(0,l.jsx)(r.K,{selectedMedia:w,setSelectedMedia:_})})}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("div",{className:"col-md-4",children:(0,l.jsxs)("div",{className:"form-group",children:[(0,l.jsx)("label",{htmlFor:"sourceName",children:"Source Name:"}),(0,l.jsx)("input",{...H("source_name"),type:"text",className:V.source_name?"form-control is-invalid":"form-control",id:"sourceName","aria-describedby":"emailHelp",placeholder:"Enter Source Name",name:"source_name"}),V.source_name&&(0,l.jsx)("div",{className:"invalid-feedback d-block",children:(0,l.jsx)("small",{children:V.source_name.message})})]})}),(0,l.jsx)("div",{className:"col-md-8",children:(0,l.jsxs)("div",{className:"form-group",children:[(0,l.jsx)("label",{htmlFor:"mainTitle",children:"Source URL:"}),(0,l.jsx)("input",{...H("source_url"),type:"text",className:V.source_url?"form-control is-invalid":"form-control",id:"footerTitle","aria-describedby":"emailHelp",placeholder:"Enter Source URL",name:"source_url"}),V.source_url&&(0,l.jsx)("div",{className:"invalid-feedback d-block",children:(0,l.jsx)("small",{children:V.source_url.message})})]})})]})]}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("div",{className:"col-md-6",children:(0,l.jsx)(i.T,{selectedCategories:h,setSelectedCategories:f})}),(0,l.jsx)("div",{className:"col-md-6 mt-2",children:(0,l.jsx)(n.U,{tags:S,setTags:T,serverTags:M,setServerTags:P})})]}),L?(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("div",{className:"col",children:(0,l.jsx)("button",{type:"button",className:"btn btn-outline-dark",onClick:()=>{I(!1),O("")},children:"Make This Short News"})}),(0,l.jsx)(j.b,{longBody:E,setLongBody:O})]}):(0,l.jsx)("button",{type:"button",className:"btn btn-outline-dark",onClick:()=>{I(!0),O("")},children:"Make This Long News"})]}),(0,l.jsxs)("div",{className:"col-lg-5 col-md-6 mt-3",children:[(0,l.jsx)("div",{className:"row mb-3",children:w&&"Image"===w.mediaType&&("string"==typeof w.media?(0,l.jsxs)("div",{className:"row",children:["Selected Image:",(0,l.jsx)("div",{className:"col-4",children:(0,l.jsx)(u(),{src:w.media,alt:"",width:200,height:100,className:"p-0 ".concat(b().smallImage)})})]}):(0,l.jsxs)("div",{className:"row",children:["Selected Image:",(0,l.jsx)("div",{className:"col-4",children:(0,l.jsx)(u(),{src:URL.createObjectURL(w.media),alt:"",width:200,height:100})})]}))}),(0,l.jsx)(g.m,{tags:S,setSelectedMedia:_})]})]})})})}}},function(e){e.O(0,[9774,1664,5675,6976,2734,6312,7369,950,2888,179],function(){return e(e.s=38991)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.