mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-01 21:28:23 +00:00
Implement new features and enhance existing components for improved user experience
- Added a new `bun.lockb` file for dependency management. - Updated `next.config.ts` to set output to "standalone" for better deployment options. - Removed `package-lock.json` to streamline package management. - Modified `package.json` to update dependencies, including `@prisma/client` and `sonner`, and adjusted build scripts for improved functionality. - Enhanced Tailwind CSS configuration to include new animations and color schemes. - Refactored various dashboard components to improve UI consistency, including adding a new `My Wallet` page and updating existing pages to use a unified styling approach. - Introduced a new `BlockDeviceDialog` component for managing device blocking with user-defined reasons. - Improved logging and error handling in payment verification and device management functions. These changes enhance the overall functionality, maintainability, and user experience of the application.
This commit is contained in:
@ -9,7 +9,7 @@ import {
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { formatDate } from "@/lib/utils";
|
||||
import type { BillFormula, Prisma, User } from "@prisma/client";
|
||||
import type { Prisma, User } from "@prisma/client";
|
||||
import { BadgeDollarSign, Clipboard, ClipboardCheck, Loader2, Wallet } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
@ -22,28 +22,24 @@ type PaymentWithDevices = Prisma.PaymentGetPayload<{
|
||||
}>;
|
||||
|
||||
export default function DevicesToPay({
|
||||
billFormula,
|
||||
payment,
|
||||
user
|
||||
}: { billFormula?: BillFormula; payment?: PaymentWithDevices, user?: User }) {
|
||||
}: { payment?: PaymentWithDevices, user?: User }) {
|
||||
const [verifying, setVerifying] = useState(false)
|
||||
|
||||
const devices = payment?.devices;
|
||||
if (devices?.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const baseAmount = billFormula?.baseAmount ?? 100;
|
||||
const discountPercentage = billFormula?.discountPercentage ?? 75;
|
||||
// 100+(n−1)×75
|
||||
const total = baseAmount + (devices?.length ?? 1 - 1) * discountPercentage;
|
||||
const walletBalance = user?.walletBalance ?? 0;
|
||||
const isWalletPayVisible = walletBalance > total;
|
||||
const isWalletPayVisible = walletBalance > (payment?.amount ?? 0);
|
||||
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<div className="p-2 flex flex-col gap-2">
|
||||
<h3 className="title-bg my-1 p-2 font-semibold text-lg">
|
||||
<h3 className="title-bg my-1 p-2 border border-dashed rounded-md font-semibold text-lg">
|
||||
{!payment?.paid ? "Devices to pay" : "Devices Paid"}
|
||||
</h3>
|
||||
<div className="flex flex-col gap-2">
|
||||
@ -85,7 +81,7 @@ export default function DevicesToPay({
|
||||
paymentId: payment?.id,
|
||||
benefName: user?.name ?? "",
|
||||
accountNo: user?.accNo ?? "",
|
||||
absAmount: String(total),
|
||||
absAmount: String(payment?.amount),
|
||||
time: formatDate(new Date(payment?.createdAt || "")),
|
||||
type: "WALLET",
|
||||
});
|
||||
@ -105,7 +101,7 @@ export default function DevicesToPay({
|
||||
paymentId: payment?.id,
|
||||
benefName: user?.name ?? "",
|
||||
accountNo: user?.accNo ?? "",
|
||||
absAmount: String(total),
|
||||
absAmount: String(payment?.amount),
|
||||
type: "TRANSFER",
|
||||
time: formatDate(new Date(payment?.createdAt || "")),
|
||||
});
|
||||
@ -140,7 +136,7 @@ export default function DevicesToPay({
|
||||
<TableFooter>
|
||||
<TableRow className="">
|
||||
<TableCell colSpan={1}>Total Due</TableCell>
|
||||
<TableCell className="text-right text-3xl font-bold">{total.toFixed(2)}</TableCell>
|
||||
<TableCell className="text-right text-3xl font-bold">{payment?.amount.toFixed(2)}</TableCell>
|
||||
</TableRow>
|
||||
</TableFooter>
|
||||
</Table>
|
||||
|
Reference in New Issue
Block a user