Skip to content

Commit

Permalink
Add page not found banner (#971)
Browse files Browse the repository at this point in the history
* feat: page not found all instances + proposal id prop missing page.Proposal

* missing id check rfp page
  • Loading branch information
Tguntenaar authored Oct 26, 2024
1 parent 30c8e87 commit 1611dd6
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 10 deletions.
3 changes: 1 addition & 2 deletions instances/devhub.near/widget/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ function Page() {
);
}
default: {
// TODO: 404 page
return <p>404</p>;
return <Widget src={"${REPL_DEVHUB}/widget/devhub.page.notfound"} />;
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions instances/devhub.near/widget/devhub/entity/proposal/Proposal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ const LinkProfile = ({ account, children }) => {
const stepsArray = [1, 2, 3, 4, 5];

const { id, timestamp } = props;

if (id === undefined) {
return (
<Widget
src={`${REPL_DEVHUB}/widget/devhub.page.notfound`}
props={{ missing: "proposal id" }}
/>
);
}

const proposal = Near.view("${REPL_DEVHUB_CONTRACT}", "get_proposal", {
proposal_id: parseInt(id),
});
Expand Down
44 changes: 44 additions & 0 deletions instances/devhub.near/widget/devhub/page/notfound.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { missing } = props;

const BannerWrapper = styled.div`
margin-top: 3rem;
background-color: #ffd2d2;
.text-sm {
font-size: 13px;
}
`;

return (
<div className="container-xl gap-3">
<Widget src={`${REPL_DEVHUB}/widget/devhub.components.island.banner`} />
<BannerWrapper className="d-flex gap-3 align-items-center mb-4 p-3 rounded-3">
<div>
<i class="bi bi-exclamation-triangle-fill"></i>
</div>
<div>
<div className="fw-bold">Page not found! </div>
<div className="text-sm">
Please visit the{" "}
<a
href="?page=home"
className="text-decoration-underline"
target="_blank"
rel="noopener noreferrer"
>
Home Page
</a>
.
{missing ? (
<span>The {missing} prop is missing from the url</span>
) : (
<span>
We searched high and low but couldn't found what you're looking
for.{" "}
</span>
)}
.
</div>
</div>
</BannerWrapper>
</div>
);
7 changes: 1 addition & 6 deletions instances/events-committee.near/widget/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ function Page() {
);
}
default: {
return (
<Widget
src={"${REPL_EVENTS}/widget/devhub.page.proposals"}
props={passProps}
/>
);
return <Widget src={"${REPL_DEVHUB}/widget/devhub.page.notfound"} />;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ const LinkProfile = ({ account, children }) => {
const stepsArray = [1, 2, 3, 4, 5];

const { id, timestamp } = props;

if (id === undefined) {
return (
<Widget
src={`${REPL_DEVHUB}/widget/devhub.page.notfound`}
props={{ missing: "proposal id" }}
/>
);
}

const proposal = Near.view("${REPL_EVENTS_CONTRACT}", "get_proposal", {
proposal_id: parseInt(id),
});
Expand Down
3 changes: 1 addition & 2 deletions instances/infrastructure-committee.near/widget/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ function Page() {
);
}
default: {
// TODO: 404 page
return <p>404</p>;
return <Widget src={"${REPL_DEVHUB}/widget/devhub.page.notfound"} />;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ const LinkProfile = ({ account, children }) => {
const stepsArray = [1, 2, 3, 4, 5];

const { id, timestamp } = props;

if (id === undefined) {
return (
<Widget
src={`${REPL_DEVHUB}/widget/devhub.page.notfound`}
props={{ missing: "proposal id" }}
/>
);
}

const proposal = Near.view(
"${REPL_INFRASTRUCTURE_COMMITTEE_CONTRACT}",
"get_proposal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ const accountId = context.accountId;

const { id, timestamp } = props;

if (id === undefined) {
return (
<Widget
src={`${REPL_DEVHUB}/widget/devhub.page.notfound`}
props={{ missing: "rfp id" }}
/>
);
}

const Container = styled.div`
.full-width-div {
width: 100vw;
Expand Down

0 comments on commit 1611dd6

Please sign in to comment.