Refactor authentication middleware to use native fetch, update dependencies, and enhance error handling. Add new error boundary component for dashboard and improve user verification UI. Update payment handling and device management components for better user experience. Adjust CSS for error backgrounds and refine input read-only components with validation indicators.
This commit is contained in:
+16
-21
@@ -9,28 +9,23 @@ import { redirect } from "next/navigation";
|
||||
import { addDevicesToGroup } from "./omada-actions";
|
||||
|
||||
export async function createPayment(data: PaymentType) {
|
||||
try {
|
||||
console.log("data", data);
|
||||
const payment = await prisma.payment.create({
|
||||
data: {
|
||||
amount: data.amount,
|
||||
numberOfMonths: data.numberOfMonths,
|
||||
paid: data.paid,
|
||||
userId: data.userId,
|
||||
devices: {
|
||||
connect: data.deviceIds.map((id) => {
|
||||
return {
|
||||
id,
|
||||
};
|
||||
}),
|
||||
},
|
||||
console.log("data", data);
|
||||
const payment = await prisma.payment.create({
|
||||
data: {
|
||||
amount: data.amount,
|
||||
numberOfMonths: data.numberOfMonths,
|
||||
paid: data.paid,
|
||||
userId: data.userId,
|
||||
devices: {
|
||||
connect: data.deviceIds.map((id) => {
|
||||
return {
|
||||
id,
|
||||
};
|
||||
}),
|
||||
},
|
||||
});
|
||||
return { success: true, paymentId: payment.id };
|
||||
} catch (error) {
|
||||
console.error("Error creating payment:", error);
|
||||
return { success: false, error: "Failed to create payment" };
|
||||
}
|
||||
},
|
||||
});
|
||||
redirect(`/payments/${payment.id}`);
|
||||
}
|
||||
|
||||
type VerifyPaymentType = {
|
||||
|
||||
Reference in New Issue
Block a user