/* INCLUDE: "common.jsx" */ const nearDevGovGigsContractAccountId = props.nearDevGovGigsContractAccountId || (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; const nearDevGovGigsWidgetsAccountId = props.nearDevGovGigsWidgetsAccountId || (context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0]; function widget(widgetName, widgetProps, key) { widgetProps = { ...widgetProps, nearDevGovGigsContractAccountId: props.nearDevGovGigsContractAccountId, nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId, referral: props.referral, }; return ( <Widget src={`${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.${widgetName}`} props={widgetProps} key={key} /> ); } function href(widgetName, linkProps) { linkProps = { ...linkProps }; if (props.nearDevGovGigsContractAccountId) { linkProps.nearDevGovGigsContractAccountId = props.nearDevGovGigsContractAccountId; } if (props.nearDevGovGigsWidgetsAccountId) { linkProps.nearDevGovGigsWidgetsAccountId = props.nearDevGovGigsWidgetsAccountId; } if (props.referral) { linkProps.referral = props.referral; } const linkPropsQuery = Object.entries(linkProps) .map(([key, value]) => `${key}=${value}`) .join("&"); return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${ linkPropsQuery ? "?" : "" }${linkPropsQuery}`; } const WrapperWidget = ({ children, id }) => { // This function handles the state change for the children widgets const handleStateChange = (key, value) => { // Use the unique identifier to create a unique storage key const storageKey = `${id}_${key}`; // Update the local storage with the new state localStorage.setItem(storageKey, JSON.stringify(value)); }; // This function initializes the state of the children widgets const initState = (key, defaultValue) => { // Use the unique identifier to create a unique storage key const storageKey = `${id}_${key}`; let storedValue = localStorage.getItem(storageKey); if (storedValue) { try { return JSON.parse(storedValue); } catch (e) { console.error("Error parsing JSON from storage", e); } } return defaultValue; }; // Render the children widgets and pass the state management functions as props return React.Children.map(children, (child) => child && typeof child === "object" ? React.cloneElement(child, { handleStateChange, initState }) : child ); }; /* END_INCLUDE: "common.jsx" */ const Banner = styled.div` { height: 62px; background: #181818; margin-top: -24px; padding: 16px 20px; img { height: 30px; } margin-bottom: 25px; } `; return ( <> <Banner className="d-flex justify-content-between"> <a href={href("Feed")}> <img src="https://ipfs.near.social/ipfs/bafkreibjsn3gswlcc5mvgkfv7ady2lzkd2htm55l472suarbd34qryh2uy"></img> </a> <div> <a href="https://www.neardevgov.org/blog/near-developer-dao" class="text-white me-2" > Developer DAO </a> <div class="btn-group" role="group"> <button type="button" class="btn btn-outline-light rounded-circle" style={{ width: "30px", height: "30px", padding: "6px 0px", borderWidth: "0.5px", lineHeight: "0px", }} data-bs-toggle="dropdown" aria-expanded="false" > <i class="bi bi-question-lg"></i> </button> <ul class="dropdown-menu dropdown-menu-end"> <li> <a target="_blank" class="dropdown-item" href="https://github.com/near/devgigsboard-widgets/issues/new?assignees=&labels=bug&template=bug_report.md&title=" > Report a bug </a> </li> <li> <a target="_blank" class="dropdown-item" href="https://github.com/near/devgigsboard-widgets/issues/new?assignees=&labels=enhancement&template=feature-request.md&title=" > Suggest an improvement </a> </li> </ul> </div> </div> </Banner> </> );