Skip to content

Commit d48bad5

Browse files
committed
feat(notifications): Admin page improvements
1 parent 6007a3f commit d48bad5

File tree

4 files changed

+281
-229
lines changed

4 files changed

+281
-229
lines changed

apps/webapp/app/components/navigation/NotificationPanel.tsx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function NotificationCard({
242242
ref={descriptionRef}
243243
className={cn(!isExpanded && "line-clamp-3")}
244244
>
245-
<ReactMarkdown components={markdownComponents}>{description}</ReactMarkdown>
245+
<ReactMarkdown components={getMarkdownComponents(onLinkClick)}>{description}</ReactMarkdown>
246246
</div>
247247
{(isOverflowing || isExpanded) && (
248248
<button
@@ -269,25 +269,28 @@ function NotificationCard({
269269
);
270270
}
271271

272-
const markdownComponents = {
273-
p: ({ children }: { children?: React.ReactNode }) => (
274-
<p className="my-0.5 text-xs leading-relaxed text-text-dimmed">{children}</p>
275-
),
276-
a: ({ href, children }: { href?: string; children?: React.ReactNode }) => (
277-
<a
278-
href={href}
279-
target="_blank"
280-
rel="noopener noreferrer"
281-
className="text-indigo-400 underline hover:text-indigo-300 transition-colors"
282-
>
283-
{children}
284-
</a>
285-
),
286-
strong: ({ children }: { children?: React.ReactNode }) => (
287-
<strong className="font-semibold text-text-bright">{children}</strong>
288-
),
289-
em: ({ children }: { children?: React.ReactNode }) => <em>{children}</em>,
290-
code: ({ children }: { children?: React.ReactNode }) => (
291-
<code className="rounded bg-charcoal-700 px-1 py-0.5 text-[11px]">{children}</code>
292-
),
293-
};
272+
function getMarkdownComponents(onLinkClick: () => void) {
273+
return {
274+
p: ({ children }: { children?: React.ReactNode }) => (
275+
<p className="my-0.5 text-xs leading-relaxed text-text-dimmed">{children}</p>
276+
),
277+
a: ({ href, children }: { href?: string; children?: React.ReactNode }) => (
278+
<a
279+
href={href}
280+
target="_blank"
281+
rel="noopener noreferrer"
282+
className="text-indigo-400 underline hover:text-indigo-300 transition-colors"
283+
onClick={onLinkClick}
284+
>
285+
{children}
286+
</a>
287+
),
288+
strong: ({ children }: { children?: React.ReactNode }) => (
289+
<strong className="font-semibold text-text-bright">{children}</strong>
290+
),
291+
em: ({ children }: { children?: React.ReactNode }) => <em>{children}</em>,
292+
code: ({ children }: { children?: React.ReactNode }) => (
293+
<code className="rounded bg-charcoal-700 px-1 py-0.5 text-[11px]">{children}</code>
294+
),
295+
};
296+
}

apps/webapp/app/routes/admin.api.v1.platform-notifications.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ async function authenticateAdmin(request: Request): Promise<Result<AdminUser, Au
2121
select: { id: true, admin: true },
2222
});
2323

24-
if (!user) {
25-
return err({ status: 401, message: "Invalid or Missing API key" });
26-
}
27-
28-
if (!user.admin) {
29-
return err({ status: 403, message: "You must be an admin to perform this action" });
24+
if (!user?.admin) {
25+
return err({
26+
status: user ? 403 : 401,
27+
message: user ? "You must be an admin to perform this action" : "Invalid or Missing API key",
28+
});
3029
}
3130

3231
return ok(user);

0 commit comments

Comments
 (0)