UNPKG

@tycoonsystems/tycoon-modules

Version:
1 lines 6.99 kB
function _extends(){return(_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a,s=arguments[t];for(a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e}).apply(this,arguments)}import React from"react";import{useRouter}from"next/router";import{createShop}from"@tycoonsystems/tycoon-modules/utility/ecommerce";import{v4 as uuidv4}from"uuid";import ManagerStyles from"./Manager.module.scss";import Close from"@mui/icons-material/Close";import{StreamManagerInternal}from".";import RegisterVendor from"@tycoonsystems/tycoon-modules/ecommerce/vendor/RegisterVendor";const Module=s=>{const[,r]=React.useState(!1);let[e,o]=React.useState(null);const[t,a]=React.useState(!1),[,n]=React.useState(null),[l,c]=React.useState("stream"),[i,m]=React.useState({}),u=React.useRef(),p=React.useRef(),d=(s._LocalEventEmitter.unsubscribe("manager"),s._LocalEventEmitter.subscribe("manager",e=>{e&&e.dispatch&&"setMenu"===e.dispatch&&"stream"===e?.menu&&c("stream")}),useRouter());React.useEffect(()=>{var e;t||(e=uuidv4(),n(e),a(!0))},[t]);var h=React.useCallback(e=>{try{var t;e.target.getAttribute("menu")&&(t=e.target.getAttribute("menu"),c(t))}catch(e){}}),y=React.useCallback(async e=>{try{if(o(null),e.target.getAttribute("phase")){var t=e.target.getAttribute("phase");if("1"==t)m({status:"start"});else if("end"==t)if(console.log("Run request create shop",u.current),r(!0),u.current&&u.current.value){var a=await createShop(s.apiUrl,s.domainKey,s._loggedIn,{shopName:u.current.value,shopDescription:p.current.value});if(a){console.log(a);try{d.reload(window.location.pathname)}catch(e){}}else o({message:"Shop creation submission failed",placement:"openshop"})}else o({message:"Please fill out a Shop Name",placement:"description"})}}catch(e){console.log(e)}}),g=React.useCallback(e=>{o(null)});return React.createElement("div",{className:ManagerStyles.container+" "+s.className},e&&e.message&&!e.placement?React.createElement("div",{className:"error",style:{margin:".25rem",marginBottom:"0"},onClick:g},e.message):null,React.createElement("div",{className:ManagerStyles.innerContainer+" flex gap-p2",style:{flexDirection:"column"}},React.createElement("div",{className:"flex",style:{justifyContent:"space-between",alignItems:"center"}},React.createElement("div",{className:ManagerStyles.itemsContainer+" flex Manager_Items",style:{padding:".5rem"}},React.createElement("button",{className:`${"stream"==l?ManagerStyles.activeItem:""} `+ManagerStyles.item,onClick:h,menu:"stream"},"Stream"),React.createElement("button",{className:`${"shop"==l?ManagerStyles.activeItem:""} `+ManagerStyles.item,onClick:h,menu:"shop"},"Shop"),React.createElement("button",{className:`${"vendor"==l?ManagerStyles.activeItem:""} `+ManagerStyles.item,onClick:h,menu:"vendor"},"Vendor")),React.createElement("div",{style:{padding:".25rem .5rem"}},React.createElement(Close,{className:"Misc_Icon_Button",style:{margin:"0rem 0",float:"right"},onClick:s.toggleAdminPanel}))),s._loggedIn?"stream"===l?React.createElement("div",{style:{padding:".5rem"}},React.createElement(StreamManagerInternal,s)):"shop"===l?React.createElement("div",{style:{padding:".5rem"}},s.shopProfileData&&s.shopProfileData.shop&&s.shopProfileData.shop.status&&"nonexistent"==s.shopProfileData.shop.status?React.createElement("div",null,i.status?i.status&&"start"==i.status?React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:".25rem",paddingTop:".25rem"}},React.createElement("div",{style:{fontSize:".85rem"}},"Name your Shop"),React.createElement("input",{ref:u,type:"text",placeholder:"Shop Name",className:"simpleTextInput"}),React.createElement("textarea",{rows:"5",style:{height:"auto",resize:"none"},ref:p,type:"text",placeholder:"You can describe your Shop here. You might put a company slogan, introduce your business, describe the products you sell or nothing at all. It is up to you and your stakeholders.",className:"simpleTextInput"}),e&&e.message&&"description"==e.placement?React.createElement("div",{className:"error",onClick:g},e.message):null,React.createElement("div",{style:{fontSize:".75rem",background:"black",padding:".125rem"}},"When creating your shop, you must set up your vendor account. Please have your banking details ready for direct deposit setup. If you don't have banking details prepared at the moment, you can always set them up later. Once your shop is created, you can start creating products and showcasing them to the public. For all physical products, it is your responsibility to ensure that you have sufficient inventory available for direct-to-consumer sales through the platform. If any products offered for sale are out of stock, any payments received must be fully refunded to customers without exceptions. As a shop owner, you will be subject to platform fees, which will be deducted from your total revenues on the platform. ",s.siteTitle," reserves the right to close any shop that is suspected of operating in a manner that jeopardizes the quality of service and integrity of the platform. All transactions on ",s.siteTitle," are handled using Tycoon Systems Ecommerce Services. Any disputes on ",s.siteTitle," are settled by the ",s.siteTitle," platform. By submitting a request to open your shop below, you agree to the above terms and conditions."),React.createElement("button",{onClick:y,phase:"end"},"Open Shop"),e&&e.message&&"openshop"==e.placement?React.createElement("div",{className:"error",onClick:g},e.message):null):null:React.createElement("div",{style:{display:"flex",flexDirection:"column",gap:".25rem",paddingTop:".25rem"}},React.createElement("div",{style:{fontSize:".85rem"}},"You do not currently own a shop. Would you like to request to open one?"),React.createElement("button",{onClick:y,phase:"1"},"Start Creating Shop"),React.createElement("div",{style:{fontSize:".85rem"}},"A shop allows for you to sell products on ",s.siteTitle," with ease to all customers, fans, collectors, enthusiasts and passerbys utilizing all the tools offered on the platform. You will be able to track pending orders that have yet to be completed, products in carts, your personal inventory, sales and much more as well as sell products in such a way that makes it easier for your customers."))):s.shopProfileData&&s.shopProfileData.shop&&s.shopProfileData.shop.name?React.createElement("div",null,React.createElement("h4",{style:{marginTop:0}},s.shopProfileData.shop.name),React.createElement(RegisterVendor,_extends({},s,{refreshUrl:`https://${s?.domainUrl}/p`,returnUrl:`https://${s?.domainUrl}/p`,label:`To sell products and services on ${s?.siteTitle} register as a Vendor`,className:"width100"}))):null):"vendor"===l?React.createElement("div",{style:{padding:".5rem"}},React.createElement(RegisterVendor,_extends({},s,{refreshUrl:`https://${s?.domainUrl}/p`,returnUrl:`https://${s?.domainUrl}/p`,label:"To receive donations register as a Vendor",className:"width100"}))):null:null))};export default Module;