Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Jan 2, 2025
1 parent 8ecdc2e commit cac7732
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 55 deletions.
10 changes: 7 additions & 3 deletions instances/treasury-devdao.near/widget/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const { treasuryDaoID, navbarLinks, logo, isTesting } = VM.require(
`${instance}/widget/config.data`
);

const config = Near.view(treasuryDaoID, "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));
const [showMenu, setShowMenu] = useState(false);

const { href: linkHref } = VM.require("${REPL_DEVHUB}/widget/core.lib.url") || {
Expand Down Expand Up @@ -127,20 +129,22 @@ function getTitle(text) {
return text.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
}

const treasuryLogo = metadata?.flagLogo ? metadata?.flagLogo : logo;

return (
<Navbar className="position-relative d-flex justify-content-between gap-2">
<div className="d-flex flex-column gap-2">
<div className="d-flex gap-2 align-items-center">
{/* logo can be svg or src */}
{logo && typeof logo === "string" ? (
{treasuryLogo && typeof treasuryLogo === "string" ? (
<img
src={logo}
src={treasuryLogo}
width={50}
height={50}
className="rounded-3 object-fit-cover"
/>
) : (
logo
treasuryLogo
)}
<div className="h3 mb-0">{getTitle(page ?? "dashboard")}</div>
{isTesting && <div>(Testing)</div>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ const AppHeader = ({ page, instance }) => (
);

function AppLayout({ page, instance, children, treasuryDaoID }) {
const config = Near.view(treasuryDaoID, "get_config");
const config = useCache(
() => Near.asyncView(treasuryDaoID, "get_config"),
"get_config",
{ subscribe: false }
);

const metadata = JSON.parse(atob(config.metadata ?? ""));

const data = fetch(`https://httpbin.org/headers`);
const gatewayURL = data?.body?.headers?.Origin ?? "";
const isDarkTheme = metadata.theme === "dark";

const getColors = (isDarkTheme) => `
${metadata.primaryColor ? `--theme-color: ${metadata.primaryColor};` : ""}
--bg-header-color: ${isDarkTheme ? "#222222" : "#2C3E50"};
--bg-page-color: ${isDarkTheme ? "#222222" : "#FFFFFF"};
--bg-system-color: ${isDarkTheme ? "#131313" : "#f4f4f4"};
Expand Down Expand Up @@ -366,7 +372,9 @@ function AppLayout({ page, instance, children, treasuryDaoID }) {
}
`;

return (
return !config ? (
<></>
) : (
<ParentContainer data-bs-theme={isDarkTheme ? "dark" : "light"}>
<Theme className="h-100 w-100">
<AppHeader page={page} instance={instance} />
Expand Down
5 changes: 1 addition & 4 deletions instances/treasury-devdao.near/widget/config/css.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

const Theme = styled.div`
--theme-color: ${metadata.primaryColor ?? "#05a36e"};
--theme-color: #05a36e;
`;

return { Theme };
7 changes: 1 addition & 6 deletions instances/treasury-devdao.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

return {
appName: "Treasury",
navbarLinks: [
Expand Down Expand Up @@ -30,9 +27,7 @@ return {
showProposalSelection: true,
showKYC: true,
showReferenceProposal: true,
logo: metadata?.flagLogo ? (
metadata?.flagLogo
) : (
logo: (
<svg
width="48"
height="48"
Expand Down
5 changes: 1 addition & 4 deletions instances/treasury-infinex.near/widget/config/css.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

const Theme = styled.div`
--theme-color: ${metadata.primaryColor ?? "#F76218"};
--theme-color: #f76218;
`;

return { Theme };
7 changes: 1 addition & 6 deletions instances/treasury-infinex.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

return {
appName: "Treasury",
navbarLinks: [
Expand All @@ -25,9 +22,7 @@ return {
showProposalSelection: false,
showKYC: false,
showReferenceProposal: false,
logo: metadata?.flagLogo ? (
metadata?.flagLogo
) : (
logo: (
<svg
width="48"
height="48"
Expand Down
5 changes: 1 addition & 4 deletions instances/treasury-templar.near/widget/config/css.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

const Theme = styled.div`
--theme-color: ${metadata.primaryColor ?? "#8942d9"};
--theme-color: #8942d9;
`;

return { Theme };
7 changes: 1 addition & 6 deletions instances/treasury-templar.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

return {
appName: "Templar",
navbarLinks: [
Expand All @@ -21,9 +18,7 @@ return {
showProposalSelection: false,
showKYC: false,
showReferenceProposal: false,
logo: metadata?.flagLogo ? (
metadata?.flagLogo
) : (
logo: (
<img
src="https://github.com/user-attachments/assets/d1d3da13-452a-4501-bdc6-f906598dd5a4"
style={{ height: 40, width: 40 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

const Theme = styled.div`
--theme-color: ${metadata.primaryColor ?? "#F76218"};
--theme-color: #f76218;
`;

return { Theme };
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

return {
appName: "Treasury",
navbarLinks: [
Expand All @@ -26,9 +23,7 @@ return {
showKYC: false,
showReferenceProposal: false,
lockupContract: "5477a9dcecd54cc53bd08c8e1022405b30642a62.lockup.near",
logo: metadata?.flagLogo ? (
metadata?.flagLogo
) : (
logo: (
<svg
width="48"
height="48"
Expand Down
5 changes: 1 addition & 4 deletions instances/treasury-testing.near/widget/config/css.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

const Theme = styled.div`
--theme-color: ${metadata.primaryColor ?? "#05a36e"};
--theme-color: #05a36e;
`;

return { Theme };
7 changes: 1 addition & 6 deletions instances/treasury-testing.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const config = Near.view("${REPL_TREASURY}", "get_config");
const metadata = JSON.parse(atob(config.metadata ?? ""));

return {
appName: "Treasury",
navbarLinks: [
Expand Down Expand Up @@ -31,9 +28,7 @@ return {
showKYC: true,
showReferenceProposal: true,
isTesting: true,
logo: metadata?.flagLogo ? (
metadata?.flagLogo
) : (
logo: (
<svg
width="48"
height="48"
Expand Down

0 comments on commit cac7732

Please sign in to comment.