ui done
This commit is contained in:
@@ -221,7 +221,7 @@ router.delete("/:id", async (req: Request, res: Response): Promise<any> => {
|
|||||||
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
if (!userId) return res.status(401).json({ message: "Unauthorized" });
|
||||||
|
|
||||||
const id = parseIntOrError(req.params.id, "Payment ID");
|
const id = parseIntOrError(req.params.id, "Payment ID");
|
||||||
await storage.deletePayment(userId, id);
|
await storage.deletePayment(id, userId);
|
||||||
|
|
||||||
res.status(200).json({ message: "Payment deleted successfully" });
|
res.status(200).json({ message: "Payment deleted successfully" });
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ import {
|
|||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@radix-ui/react-select";
|
} from "@/components/ui/select";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import Decimal from "decimal.js";
|
|
||||||
import { toast } from "@/hooks/use-toast";
|
import { toast } from "@/hooks/use-toast";
|
||||||
|
|
||||||
type PaymentEditModalProps = {
|
type PaymentEditModalProps = {
|
||||||
@@ -47,7 +46,7 @@ export default function PaymentEditModal({
|
|||||||
onEditServiceLine,
|
onEditServiceLine,
|
||||||
}: PaymentEditModalProps) {
|
}: PaymentEditModalProps) {
|
||||||
if (!payment) return null;
|
if (!payment) return null;
|
||||||
|
|
||||||
const [expandedLineId, setExpandedLineId] = useState<number | null>(null);
|
const [expandedLineId, setExpandedLineId] = useState<number | null>(null);
|
||||||
const [paymentStatus, setPaymentStatus] = React.useState<PaymentStatus>(
|
const [paymentStatus, setPaymentStatus] = React.useState<PaymentStatus>(
|
||||||
payment.status
|
payment.status
|
||||||
@@ -167,15 +166,15 @@ export default function PaymentEditModal({
|
|||||||
<div className="mt-2 space-y-1">
|
<div className="mt-2 space-y-1">
|
||||||
<p>
|
<p>
|
||||||
<span className="text-gray-500">Total Billed:</span> $
|
<span className="text-gray-500">Total Billed:</span> $
|
||||||
{payment.totalBilled.toNumber().toFixed(2)}
|
{Number(payment.totalBilled || 0).toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="text-gray-500">Total Paid:</span> $
|
<span className="text-gray-500">Total Paid:</span> $
|
||||||
{payment.totalPaid.toNumber().toFixed(2)}
|
{Number(payment.totalPaid || 0).toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="text-gray-500">Total Due:</span> $
|
<span className="text-gray-500">Total Due:</span> $
|
||||||
{payment.totalDue.toNumber().toFixed(2)}
|
{Number(payment.totalDue || 0).toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
<div className="pt-2">
|
<div className="pt-2">
|
||||||
<label className="text-sm text-gray-600">Status</label>
|
<label className="text-sm text-gray-600">Status</label>
|
||||||
@@ -237,19 +236,19 @@ export default function PaymentEditModal({
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="text-gray-500">Billed:</span> $
|
<span className="text-gray-500">Billed:</span> $
|
||||||
{line.totalBilled.toFixed(2)}
|
{Number(line.totalBilled || 0).toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="text-gray-500">Paid:</span> $
|
<span className="text-gray-500">Paid:</span> $
|
||||||
{line.totalPaid.toFixed(2)}
|
{Number(line.totalPaid || 0).toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="text-gray-500">Adjusted:</span> $
|
<span className="text-gray-500">Adjusted:</span> $
|
||||||
{line.totalAdjusted.toFixed(2)}
|
{Number(line.totalAdjusted || 0).toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span className="text-gray-500">Due:</span> $
|
<span className="text-gray-500">Due:</span> $
|
||||||
{line.totalDue.toFixed(2)}
|
{Number(line.totalDue || 0).toFixed(2)}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="pt-2">
|
<div className="pt-2">
|
||||||
@@ -265,7 +264,7 @@ export default function PaymentEditModal({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{expandedLineId === line.id && (
|
{expandedLineId === line.id && (
|
||||||
<div className="mt-3 space-y-2">
|
<div className="mt-3 space-y-4">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<label
|
<label
|
||||||
htmlFor={`paid-${line.id}`}
|
htmlFor={`paid-${line.id}`}
|
||||||
@@ -315,11 +314,14 @@ export default function PaymentEditModal({
|
|||||||
<Select
|
<Select
|
||||||
value={formState.method}
|
value={formState.method}
|
||||||
onValueChange={(value: PaymentMethod) =>
|
onValueChange={(value: PaymentMethod) =>
|
||||||
updateField("method", value)
|
setFormState((prev) => ({
|
||||||
|
...prev,
|
||||||
|
method: value,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue />
|
<SelectValue placeholder="Select a payment method" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{paymentMethodOptions.map((methodOption) => (
|
{paymentMethodOptions.map((methodOption) => (
|
||||||
@@ -381,7 +383,7 @@ export default function PaymentEditModal({
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => handleSavePayment()}
|
onClick={() => handleSavePayment()}
|
||||||
>
|
>
|
||||||
Save
|
Update
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -355,9 +355,9 @@ export default function PaymentsRecentTable({
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
) : (
|
) : (
|
||||||
paymentsData?.payments.map((payment) => {
|
paymentsData?.payments.map((payment) => {
|
||||||
const totalBilled = payment.totalBilled.toNumber();
|
const totalBilled = Number(payment.totalBilled || 0);
|
||||||
const totalPaid = payment.totalPaid.toNumber();
|
const totalPaid = Number(payment.totalPaid || 0);
|
||||||
const totalDue = payment.totalDue.toNumber();
|
const totalDue = Number(payment.totalDue || 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={payment.id}>
|
<TableRow key={payment.id}>
|
||||||
@@ -379,8 +379,8 @@ export default function PaymentsRecentTable({
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<span>
|
<span>
|
||||||
<strong>Total Billed:</strong> $
|
<strong>Total Billed:</strong> $
|
||||||
{totalBilled.toFixed(2)}
|
{Number(totalBilled).toFixed(2)}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<strong>Total Paid:</strong> ${totalPaid.toFixed(2)}
|
<strong>Total Paid:</strong> ${totalPaid.toFixed(2)}
|
||||||
@@ -454,7 +454,7 @@ export default function PaymentsRecentTable({
|
|||||||
isOpen={isDeletePaymentOpen}
|
isOpen={isDeletePaymentOpen}
|
||||||
onConfirm={handleConfirmDeletePayment}
|
onConfirm={handleConfirmDeletePayment}
|
||||||
onCancel={() => setIsDeletePaymentOpen(false)}
|
onCancel={() => setIsDeletePaymentOpen(false)}
|
||||||
entityName={String(currentPayment?.claimId)}
|
entityName={`ClaimID : ${currentPayment?.claimId}`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* /will hanlde both modal later */}
|
{/* /will hanlde both modal later */}
|
||||||
|
|||||||
Reference in New Issue
Block a user