mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-01 15:23:58 +00:00
Enhance payment processing and device management features
- Updated `package.json` to add a new script for pushing Prisma database changes. - Refactored payment processing functions to include payment method handling for both wallet and transfer options. - Improved `DevicesTable` and `AdminDevicesTable` components to support new payment method display and user association. - Updated Prisma schema to introduce a new `PaymentType` enum and modified the `Payment` model to include a `method` field. - Enhanced UI components to improve user experience in displaying payment and device information. These changes improve the overall functionality and maintainability of the application, particularly in payment processing and device management.
This commit is contained in:
5
prisma/migrations/20250108172258_add/migration.sql
Normal file
5
prisma/migrations/20250108172258_add/migration.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PaymentType" AS ENUM ('WALLET', 'TRANSFER');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Payment" ADD COLUMN "method" "PaymentType" NOT NULL DEFAULT 'TRANSFER';
|
28
prisma/migrations/20250108173116_change/migration.sql
Normal file
28
prisma/migrations/20250108173116_change/migration.sql
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `paymentId` on the `Device` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Device" DROP CONSTRAINT "Device_paymentId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Device" DROP COLUMN "paymentId";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_DeviceToPayment" (
|
||||
"A" TEXT NOT NULL,
|
||||
"B" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "_DeviceToPayment_AB_pkey" PRIMARY KEY ("A","B")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_DeviceToPayment_B_index" ON "_DeviceToPayment"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_DeviceToPayment" ADD CONSTRAINT "_DeviceToPayment_A_fkey" FOREIGN KEY ("A") REFERENCES "Device"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_DeviceToPayment" ADD CONSTRAINT "_DeviceToPayment_B_fkey" FOREIGN KEY ("B") REFERENCES "Payment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
@ -115,6 +115,11 @@ enum Blocker {
|
||||
PARENT
|
||||
}
|
||||
|
||||
enum PaymentType {
|
||||
WALLET
|
||||
TRANSFER
|
||||
}
|
||||
|
||||
model Device {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
@ -129,20 +134,20 @@ model Device {
|
||||
updatedAt DateTime @updatedAt
|
||||
User User? @relation(fields: [userId], references: [id])
|
||||
userId String?
|
||||
payment Payment? @relation(fields: [paymentId], references: [id])
|
||||
paymentId String?
|
||||
payments Payment[]
|
||||
}
|
||||
|
||||
model Payment {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
numberOfMonths Int
|
||||
amount Float
|
||||
paid Boolean @default(false)
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
paid Boolean @default(false)
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
paidAt DateTime?
|
||||
method PaymentType @default(TRANSFER)
|
||||
expiresAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
devices Device[]
|
||||
userId String
|
||||
}
|
||||
|
Reference in New Issue
Block a user