feat: notifications link to relevant pages when available.

This commit is contained in:
= 2025-07-01 15:52:30 +01:00
parent 75abbb3d51
commit 3081adc945
12 changed files with 59 additions and 12 deletions

View file

@ -205,11 +205,12 @@
<div class="flex items-center justify-center gap-2">
{#each tips as _, index}
<button
aria-label={`Go to page ${index + 1}`}
onclick={() => goToPage(index)}
class="h-2 w-2 rounded-full transition-colors {index === currentPage
? 'bg-primary'
: 'bg-muted-foreground/30 hover:bg-muted-foreground/50'}"
/>
></button>
{/each}
</div>
</div>

View file

@ -265,6 +265,7 @@ export const notifications = pgTable("notification", {
type: notificationTypeEnum("type").notNull(),
title: varchar("title", { length: 200 }).notNull(),
message: text("message").notNull(),
link: text("link"),
isRead: boolean("is_read").notNull().default(false),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
}, (table) => {

View file

@ -120,6 +120,7 @@ export async function resolveExpiredQuestions() {
'HOPIUM',
title,
message,
`/hopium/${question.id}`
);
}
});
@ -219,6 +220,7 @@ export async function resolveExpiredQuestions() {
'HOPIUM',
title,
message,
`/hopium/${question.id}`
);
}
});

View file

@ -9,12 +9,14 @@ export async function createNotification(
type: NotificationType,
title: string,
message: string,
link?: string,
): Promise<void> {
await db.insert(notifications).values({
userId: parseInt(userId),
type,
title,
message
message,
link
});
try {
@ -27,6 +29,7 @@ export async function createNotification(
notificationType: type,
title,
message,
link
};
await redis.publish(channel, JSON.stringify(payload));

View file

@ -5,6 +5,7 @@ export interface Notification {
type: string;
title: string;
message: string;
link?: string;
data: any;
isRead: boolean;
createdAt: string;

View file

@ -197,6 +197,7 @@ function handleWebSocketMessage(event: MessageEvent): void {
type: message.notificationType,
title: message.title,
message: message.message,
link: message.link,
isRead: false,
createdAt: message.timestamp,
data: message.amount ? { amount: message.amount } : null