mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-02 03:38:22 +00:00
Implement parental control features and enhance device management
- Added a new Parental Control page for managing device access and notifications. - Introduced blockDevice function to handle blocking and unblocking devices based on payment status. - Enhanced omada-actions.ts to include device blocking logic and improved error handling. - Updated DevicesTable component to integrate BlockDeviceButton for managing device states. - Implemented API route for checking device statuses and sending notifications for expiring devices. - Refactored payment processing to update device statuses upon successful payment verification. - Added new utility functions for API key validation and SMS notifications. These changes improve user control over device management and enhance the overall functionality of the application.
This commit is contained in:
11
prisma/migrations/20241221120035_add/migration.sql
Normal file
11
prisma/migrations/20241221120035_add/migration.sql
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `firstPaymentDone` on the `user` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Device" ADD COLUMN "registered" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "user" DROP COLUMN "firstPaymentDone";
|
2
prisma/migrations/20241222124118_add/migration.sql
Normal file
2
prisma/migrations/20241222124118_add/migration.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Device" ADD COLUMN "blocked" BOOLEAN NOT NULL DEFAULT false;
|
@ -14,19 +14,19 @@ datasource db {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified Boolean @default(false)
|
||||
firstPaymentDone Boolean @default(false)
|
||||
verified Boolean @default(false)
|
||||
accNo String?
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified Boolean @default(false)
|
||||
|
||||
verified Boolean @default(false)
|
||||
accNo String?
|
||||
// island String?
|
||||
address String?
|
||||
id_card String? @unique
|
||||
dob DateTime?
|
||||
atoll Atoll? @relation(fields: [atollId], references: [id])
|
||||
island Island? @relation(fields: [islandId], references: [id])
|
||||
address String?
|
||||
id_card String? @unique
|
||||
dob DateTime?
|
||||
atoll Atoll? @relation(fields: [atollId], references: [id])
|
||||
island Island? @relation(fields: [islandId], references: [id])
|
||||
|
||||
image String?
|
||||
createdAt DateTime @default(now())
|
||||
@ -114,6 +114,8 @@ model Device {
|
||||
name String
|
||||
mac String
|
||||
isActive Boolean @default(false)
|
||||
registered Boolean @default(false)
|
||||
blocked Boolean @default(false)
|
||||
expiryDate DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
@ -12,12 +11,11 @@ async function main() {
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
name: "Admin",
|
||||
email: "admin@sarlink.net",
|
||||
name: "Admin Admin",
|
||||
email: "admin@example.com",
|
||||
emailVerified: true,
|
||||
firstPaymentDone: true,
|
||||
verified: true,
|
||||
address: "Dharanboodhoo",
|
||||
address: "Sky villa",
|
||||
id_card: "A265117",
|
||||
dob: new Date("1990-01-01"),
|
||||
phoneNumber: "+9607780588",
|
||||
@ -25,38 +23,7 @@ async function main() {
|
||||
role: "ADMIN",
|
||||
},
|
||||
});
|
||||
const users = Array.from({ length: 25 }, () => ({
|
||||
name: `${faker.person.fullName().split(" ")[1]} House-${crypto
|
||||
.randomUUID()
|
||||
.slice(0, 5)}`,
|
||||
email: faker.internet.email(),
|
||||
emailVerified: false,
|
||||
firstPaymentDone: false,
|
||||
verified: false,
|
||||
address: faker.location.streetAddress(),
|
||||
id_card: `A${Math.round(Math.random() * 999999)}`,
|
||||
dob: faker.date.between({
|
||||
from: "1900-01-01",
|
||||
to: "2000-01-01",
|
||||
}),
|
||||
phoneNumber: String(faker.number.int({ min: 7000000, max: 9999999 })),
|
||||
phoneNumberVerified: false,
|
||||
role: "USER",
|
||||
}));
|
||||
|
||||
const seedUsers = await Promise.all(
|
||||
users.map((user) => prisma.user.create({ data: user })),
|
||||
);
|
||||
|
||||
const FAKE_DEVICES = Array.from({ length: 25 }, () => ({
|
||||
name: faker.commerce.productName(),
|
||||
mac: faker.internet.mac(),
|
||||
userId: seedUsers[Math.floor(Math.random() * seedUsers.length)].id,
|
||||
}));
|
||||
|
||||
await prisma.device.createMany({
|
||||
data: FAKE_DEVICES,
|
||||
});
|
||||
const FAAFU_ATOLL = await prisma.atoll.create({
|
||||
data: {
|
||||
name: "F",
|
||||
|
Reference in New Issue
Block a user