From cfb4afac27660e63836cfb18d0a2866b30aced3a Mon Sep 17 00:00:00 2001 From: barsa Date: Tue, 23 Dec 2025 11:37:34 +0900 Subject: [PATCH] Refactor Notification Handling and Improve User Engagement - Updated the NotificationsModule to enhance notification management for user actions and events. - Improved integration with the CheckoutRegistrationService to streamline SIM order notifications. - Refactored CatalogCdcSubscriber to ensure timely creation of notifications for account status changes. - Enhanced frontend components to better display notification alerts, improving user experience and accessibility. --- .../migration.sql | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 apps/bff/prisma/migrations/20251223023617_add_notifications/migration.sql diff --git a/apps/bff/prisma/migrations/20251223023617_add_notifications/migration.sql b/apps/bff/prisma/migrations/20251223023617_add_notifications/migration.sql new file mode 100644 index 00000000..b6ac7e78 --- /dev/null +++ b/apps/bff/prisma/migrations/20251223023617_add_notifications/migration.sql @@ -0,0 +1,40 @@ +-- CreateEnum +CREATE TYPE "NotificationType" AS ENUM ('ELIGIBILITY_ELIGIBLE', 'ELIGIBILITY_INELIGIBLE', 'VERIFICATION_VERIFIED', 'VERIFICATION_REJECTED', 'ORDER_APPROVED', 'ORDER_ACTIVATED', 'ORDER_FAILED', 'CANCELLATION_SCHEDULED', 'CANCELLATION_COMPLETE', 'PAYMENT_METHOD_EXPIRING', 'INVOICE_DUE', 'SYSTEM_ANNOUNCEMENT'); + +-- CreateEnum +CREATE TYPE "NotificationSource" AS ENUM ('SALESFORCE', 'WHMCS', 'PORTAL', 'SYSTEM'); + +-- AlterTable +ALTER TABLE "residence_card_submissions" ALTER COLUMN "updated_at" DROP DEFAULT; + +-- CreateTable +CREATE TABLE "notifications" ( + "id" TEXT NOT NULL, + "user_id" TEXT NOT NULL, + "type" "NotificationType" NOT NULL, + "title" TEXT NOT NULL, + "message" TEXT, + "action_url" TEXT, + "action_label" TEXT, + "source" "NotificationSource" NOT NULL DEFAULT 'SALESFORCE', + "source_id" TEXT, + "read" BOOLEAN NOT NULL DEFAULT false, + "read_at" TIMESTAMP(3), + "dismissed" BOOLEAN NOT NULL DEFAULT false, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "expires_at" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "notifications_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE INDEX "notifications_user_id_read_dismissed_idx" ON "notifications"("user_id", "read", "dismissed"); + +-- CreateIndex +CREATE INDEX "notifications_user_id_created_at_idx" ON "notifications"("user_id", "created_at"); + +-- CreateIndex +CREATE INDEX "notifications_expires_at_idx" ON "notifications"("expires_at"); + +-- AddForeignKey +ALTER TABLE "notifications" ADD CONSTRAINT "notifications_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;