Skip to content

Commit

Permalink
add notification item code
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Nov 28, 2023
1 parent 79f6ee2 commit 12b5690
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/DevGov/Notification/Item/Left.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* INCLUDE: "common.jsx" */
function href(widgetName, linkProps) {
linkProps = { ...linkProps };

if (props.referral) {
linkProps.referral = props.referral;
}

const linkPropsQuery = Object.entries(linkProps)
.filter(([_key, nullable]) => (nullable ?? null) !== null)
.map(([key, value]) => `${key}=${value}`)
.join("&");

return `/#/${REPL_DEVHUB}/widget/devhub.page.${widgetName}${
linkPropsQuery ? "?" : ""
}${linkPropsQuery}`;
}
/* END_INCLUDE: "common.jsx" */

if (!props.type) {
return "Loading ...";
}

const type = props.type.split("/")[1];
return props.type ? (
<>
{type == "like"
? "liked your"
: type == "reply"
? "replied to your"
: type == "edit"
? "edited your"
: type == "mention"
? "mentioned you in their"
: "???"}{" "}
<a className="fw-bold text-muted" href={href("post", { id: props.post })}>
DevHub post
</a>
</>
) : (
"Loading ..."
);
28 changes: 28 additions & 0 deletions src/DevGov/Notification/Item/Right.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* INCLUDE: "common.jsx" */
function href(widgetName, linkProps) {
linkProps = { ...linkProps };

if (props.referral) {
linkProps.referral = props.referral;
}

const linkPropsQuery = Object.entries(linkProps)
.filter(([_key, nullable]) => (nullable ?? null) !== null)
.map(([key, value]) => `${key}=${value}`)
.join("&");

return `/#/${REPL_DEVHUB}/widget/devhub.page.${widgetName}${
linkPropsQuery ? "?" : ""
}${linkPropsQuery}`;
}
/* END_INCLUDE: "common.jsx" */

return props.post === undefined ? (
"Loading ..."
) : (
<>
<a className="btn btn-outline-dark" href={href("post", { id: props.post })}>
View DevHub post
</a>
</>
);

0 comments on commit 12b5690

Please sign in to comment.