import React, { useState, useEffect } from "react"; import ReactGA from 'react-ga4'; import theme from "../theme.jsx"; import { ToastContainer, toast } from "react-toastify" import { Paper, Typography, Divider, Button, Grid, Card, } from "@mui/material"; //import { useAlert const Branding = (props) => { const { globalUrl, userdata, serverside, billingInfo,clickedFromOrgTab, stripeKey, selectedOrganization, handleGetOrg, } = props; //const alert = useAlert(); const [publishingInfo, setPublishingInfo] = useState(""); const [publishRequirements, setPublishRequirements] = useState([]) const handleEditOrg = (joinStatus) => { const data = { "org_id": selectedOrganization.id, "creator_config": joinStatus, }; const url = globalUrl + `/api/v1/orgs/${selectedOrganization.id}`; fetch(url, { mode: "cors", method: "POST", body: JSON.stringify(data), credentials: "include", crossDomain: true, withCredentials: true, headers: { "Content-Type": "application/json; charset=utf-8", }, }) .then((response) => response.json().then((responseJson) => { if (responseJson["success"] === false) { toast("Failed updating org: ", responseJson.reason); } else { if (joinStatus == "join") { setPublishingInfo("Your organization is now part of the Creator Incentive Program. You can now create and publish content to your organization's page. You can also create a creator account to manage your organization's content.") } else { setPublishingInfo("Your organization is no longer part of the Creator Incentive Program. You can still create a creator account to manage your organization's content.") } handleGetOrg(selectedOrganization.id); } }) ) .catch((error) => { toast("Err: " + error.toString()); }); }; // Should enable / disable org branding const handleChangePublishing = () => { console.log("Handle change publishing"); if (selectedOrganization.creator_id == "") { handleEditOrg("join") } else { handleEditOrg("leave") } } const isOrganizationReady = () => { console.log("Is organization ready?") // A simple checklist to ensure the button shows up properly if (selectedOrganization.name === selectedOrganization.org) { const comment = "Change the name of your organization" if (!publishRequirements.includes(comment)) { setPublishRequirements([...publishRequirements, comment]) } return false; } // Check if it's a suborg if (selectedOrganization.creator_org !== "") { const comment = "Child orgs can't become creators" if (!publishRequirements.includes(comment)) { setPublishRequirements([...publishRequirements, comment]) } return false; } if (selectedOrganization.large_image === "" || selectedOrganization.large_image === theme.palette.defaultImage) { const comment = "Add a logo for your organization" if (!publishRequirements.includes(comment)) { setPublishRequirements([...publishRequirements, comment]) } return false; } return true } return (