%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/opti/www/startup-life/assets/
Upload File :
Create Path :
Current File : /home/opti/www/startup-life/assets/create-community-a35880ef.js

import{r as w,j as e,Q as x,u as k,t as T}from"./index-5492fbe1.js";import{D as $}from"./dashboard-page-layout-2cec2413.js";import{F as q,c as B}from"./communities-a840685a.js";import{u as D}from"./index.esm-1be9f6a3.js";import{C as b}from"./index-2c4b8b3c.js";import{I as _}from"./index-fbb310b5.js";import{j as S}from"./joinClasses-adfcc520.js";import{F as P}from"./index-5e112d84.js";import{b as R}from"./base64-converter-db95817a.js";import{u as F}from"./index-9f8785a2.js";import{B as z}from"./Button-e32596e7.js";import{D as L}from"./dashboard-footer-navigation-f658b457.js";import{u as M}from"./post-notification.api-d7cee9b0.js";import{v as O}from"./v4-4a60fe23.js";import{A as U}from"./add-community-members-04dde5ff.js";import"./motion-4a110d9b.js";import"./Box-263f925f.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"./useControlled-967f9278.js";import"./createSvgIcon-6a373a0a.js";import"./FileIcon-23592c30.js";import"./styled-components.browser.esm-ee37ee23.js";import"./tslib.es6-ace8e431.js";import"./index.esm-b6fe913b.js";import"./iconBase-4b2ba95c.js";import"./isNativeReflectConstruct-061ae640.js";import"./assertThisInitialized-081f9914.js";import"./useQuery-0abbcf43.js";import"./ButtonBase-0400401d.js";import"./index-4de96b18.js";import"./update-stream-users.api-08113ef6.js";import"./get-all-users-as-vendor.api-465b5409.js";import"./Checkbox-5f253e47.js";import"./SwitchBase-f9d84931.js";const Z=({handleSubmit:l,setValue:n,control:p,setSteps:u,community:m,getValues:o})=>{const h=w.useRef(null),[r,d]=w.useState(null),{client:f,decoded:g}=F(),t=async()=>{var i;try{const s={type:"messaging",members:{$in:[g.user_id]}},a=[{last_message_at:-1}];return(await f.queryChannels(s,a,{watch:!0,state:!0,limit:30})).filter(N=>N.data.name===o("community_name"))??[]}catch(s){return console.log(s),(i=s.response)==null?void 0:i.data}},y=async()=>{if((await t()).length>0){x.error("channel name already exists");return}if(!r){x.error("you have to select a logo");return}u(2)};return e.jsxs("div",{className:"px-[40px]",children:[e.jsxs("header",{className:"font-bold text-[#537473]",children:["New ",m==null?void 0:m.name]}),e.jsxs("div",{className:"bg-white max-w-[786px] w-full flex flex-col justify-center items-center p-5 space-y-5 m-auto !mt-10",children:[e.jsxs("div",{className:"bg-[rgb(197,197,197)]/30 rounded-full w-[238px] h-[238px] flex items-center justify-center overflow-hidden",children:[e.jsx(b,{appear:!r||!o("community_img"),children:e.jsx(q,{width:150,height:150,color:"#537473"})}),e.jsx(b,{appear:!!r||!!o("community_img"),children:e.jsx("img",{src:`data:image/png;base64,${r??o("community_img")}`,className:"object-cover h-full w-full",alt:"community photo"})})]}),e.jsx(P,{accept:"image/png,image/jpeg",component:e.jsx("button",{className:"bg-transparent text-[#A8CF45]",children:"Upload Community Logo"}),inputRef:h,name:"community photo",handleFileChange:i=>{const s=i.target.files[0];console.log(s);const a=40;if(s){if(s.size>a*1024){console.log("processed"),x.error("Error: File size exceeds the allowed 40kb limit.");return}n("community_img",s),console.log("oopppss",s),R({selectedFile:i.target.files[0],callback:c=>{d(c)}})}}}),e.jsxs("form",{onSubmit:l(y),className:"space-y-14 max-w-[584px] w-full",children:[e.jsx(_,{name:"community_name",label:"Add Community Name",control:p,rules:{required:"This field is required"},onChange:i=>{n("community_name",i.target.value)}}),e.jsx(_,{name:"community_description",label:"Add Community Description",control:p,rules:{required:"This field is required"},onChange:i=>{n("community_description",i.target.value)}}),e.jsx("div",{className:"flex",children:e.jsx(z,{type:"submit",className:S("text-white !bg-[#A8CF45] !w-full !max-w-xs !mx-auto py-3"),children:"Continue"})})]})]})]})},v=({enabled:l})=>e.jsx("div",{className:"w-[20px] h-[20px] border border-[#A8CF45] p-1 rounded-full",children:e.jsx("div",{className:S("w-full h-full rounded-full",l&&"!bg-[#A8CF45]")})}),G=({setSteps:l,community:n,handleSubmit:p,client:u,token:m})=>{const[o,h]=w.useState("public"),r=o==="private",d=o==="public",f=k(),{mutateAsync:g}=M();console.log(u);const t=JSON.parse(localStorage.getItem("user"));async function y(s){var a;try{console.log(n.id.split("/")[0].replace(/[^a-zA-Z0-9\s]/g,""));const{community_name:c,community_description:j,community_img:N}=s,A=O(),C=u.channel("messaging",n.id.split("/")[0].replace(/[^a-zA-Z0-9]/g,"")+"_"+A,{name:c,Image:N??"",description:j,members:[m.user_id],private:o!=="public",channelType:n.id.split("/"),identifier:"community_group"}),I=await C.watch();console.log("Channel created successfully:",I),g({message:`${c} channel created successfully. Kindly proceed to add members.`,email:[t==null?void 0:t.email],to:[t==null?void 0:t.id],fullName:[`${t==null?void 0:t.firstName} ${t==null?void 0:t.lastName}`],channelId:(a=C==null?void 0:C.data)==null?void 0:a.id}).then(()=>{x.success("channel created successfully."),x.success("Note: that channel will not be recreated if channel name already exist."),f(`/groups/${n.id}/join-community`)}).catch(E=>{console.log(E),x.error("error while creating notification")})}catch(c){console.error("Error creating channel:",c)}}const i=async s=>{const{community_name:a,community_img:c,community_description:j}=s;y({community_name:a,community_img:c,community_description:j})};return e.jsxs("section",{children:[e.jsxs("header",{className:"font-bold text-[#537473] !px-5",children:["New ",n==null?void 0:n.name]}),e.jsx("div",{className:"w-full !px-5",children:e.jsxs("div",{className:" w-full space-y-5 font-bold pt-3",children:[e.jsxs("button",{onClick:()=>h("public"),className:"w-full flex justify-between bg-white items-center p-3",children:[e.jsx("p",{children:"Public- Anyone in StartUp life"}),e.jsx(v,{enabled:d})]}),e.jsxs("button",{onClick:()=>h("private"),className:"w-full flex justify-between bg-white items-center p-3",children:[e.jsxs("div",{className:"text-start",children:[e.jsx("p",{children:"Private- Only Accesible to specific users"}),e.jsx("p",{className:"text-[#C5C5C5] font-light",children:"This is strictly by invitation"})]}),e.jsx(v,{enabled:r})]})]})}),e.jsx(L,{cancelEventHandler:()=>l(1),backBtnText:"back",continueEventHandler:p(i)})]})},Be=()=>{const l={community_name:"",community_description:"",community_img:null},{control:n,getValues:p,setValue:u,handleSubmit:m,formState:{errors:o}}=D(l),{pathname:h}=T(),r=B.find(a=>h.includes(a.id)),[d,f]=w.useState(1),{client:g,decoded:t}=F(),y=d===1,i=d===2,s=d===3;return e.jsxs($,{children:[e.jsx(b,{appear:y,children:e.jsx(Z,{getValues:p,control:n,handleSubmit:m,initialState:l,setSteps:f,setValue:u,community:r,errors:o})}),e.jsx(b,{appear:i,children:e.jsx(G,{handleSubmit:m,setSteps:f,community:r,client:g,token:t})}),e.jsx(b,{appear:s,children:e.jsx(U,{community:r,getValues:p})})]})};export{Be as default};

Zerion Mini Shell 1.0