Enhance payment processing and device management features

- Introduced wallet payment option in verifyPayment function to allow users to pay using their wallet balance.
- Added new BlockDeviceDialog component for managing device blocking and unblocking actions.
- Updated DeviceCard component to display device status and integrate blocking functionality.
- Refactored DevicesTable to utilize DeviceCard for better UI representation of devices.
- Implemented Wallet component to manage wallet balance and top-up functionality.
- Enhanced API routes and Prisma schema to support wallet transactions and device blocking reasons.
- Improved overall user experience with responsive design adjustments and new UI elements.

These changes improve user control over payments and device management, enhancing the overall functionality of the application.
This commit is contained in:
2024-12-25 17:21:04 +05:00
parent c06c4fee3f
commit 75ad431160
21 changed files with 536 additions and 228 deletions

View File

@ -1,23 +1,10 @@
import { DevicesTable } from "@/components/devices-table";
import Filter from "@/components/filter";
import Search from "@/components/search";
import AddDeviceDialogForm from "@/components/user/add-device-dialog";
import { getCurrentUser } from "@/lib/auth-utils";
import { AArrowDown, AArrowUp } from "lucide-react";
import React, { Suspense } from "react";
const sortfilterOptions = [
{
value: 'asc',
label: 'Ascending',
icon: <AArrowUp size={16} />,
},
{
value: 'desc',
label: 'Descending',
icon: <AArrowDown size={16} />,
},
]
export default async function Devices({
@ -46,11 +33,7 @@ export default async function Devices({
className=" border-b-2 pb-4 gap-4 flex sm:flex-row flex-col items-start justify-start"
>
<Search />
<Filter
options={sortfilterOptions}
defaultOption="asc"
queryParamKey="sortBy"
/>
</div>
<Suspense key={query} fallback={"loading...."}>
<DevicesTable searchParams={searchParams} />

View File

@ -1,21 +1,8 @@
import { DevicesTable } from "@/components/devices-table";
import Filter from "@/components/filter";
import Search from "@/components/search";
import { AArrowDown, AArrowUp } from "lucide-react";
import React, { Suspense } from "react";
import { Suspense } from "react";
const sortfilterOptions = [
{
value: 'asc',
label: 'Ascending',
icon: <AArrowUp size={16} />,
},
{
value: 'desc',
label: 'Descending',
icon: <AArrowDown size={16} />,
},
]
export default async function ParentalControl({
@ -42,11 +29,7 @@ export default async function ParentalControl({
className=" border-b-2 pb-4 gap-4 flex sm:flex-row flex-col items-start justify-start"
>
<Search />
<Filter
options={sortfilterOptions}
defaultOption="asc"
queryParamKey="sortBy"
/>
</div>
<Suspense key={query} fallback={"loading...."}>
<DevicesTable parentalControl={true} searchParams={searchParams} />

View File

@ -70,6 +70,11 @@ export async function GET(request: Request) {
// Check if device has expired
if (isAfter(currentDate, expiryDate)) {
// Device has expired, block it
// TODO: add a reason for blocking
await blockDevice({
macAddress: device.mac,
type: "block",
});
await prisma.device.update({
where: { id: device.id },
data: {
@ -79,10 +84,6 @@ export async function GET(request: Request) {
});
devicesBlocked++;
}
await blockDevice({
macAddress: device.mac,
type: "block",
});
}
if (hoursSinceLastRun < 24) {