bugfixing

This commit is contained in:
MuslemRahimi 2025-03-20 10:10:20 +01:00
parent fa274cc01d
commit 8e3ebe2c99
3 changed files with 13 additions and 5 deletions

View File

@ -112,20 +112,30 @@ export const POST = async ({ request, locals }) => {
//console.log(tier, payload?.data?.attributes?.product_name) //console.log(tier, payload?.data?.attributes?.product_name)
// Update the user and log the payment // Update the user and log the payment
try { try {
await locals.pb.collection("users").update(userId, { await locals.pb.collection("users").update(userId, {
tier, tier,
freeTrial: false, freeTrial: false,
lifetime: productName?.includes("Life Time"), lifetime: productName?.includes("Life Time"),
}); });
const paymentData = { user: userId, data: payload }; const paymentData = { user: userId, data: payload };
await locals.pb.collection("payments").create(paymentData); await locals.pb.collection("payments").create(paymentData);
} catch (dbError) { } catch (dbError) {
console.error("Database error:", dbError); console.error("Database error:", dbError);
// Depending on your requirements, you might want to propagate this error.
return new Response(
JSON.stringify({ error: "Pocketbase error" }),
{
status: 500,
headers: { "Content-Type": "application/json" },
}
);
} }
return new Response( return new Response(

View File

@ -195,5 +195,4 @@ module.exports = {
}, },
}, },
plugins: [require("flowbite/plugin")], plugins: [require("flowbite/plugin")],
darkMode: "class",
}; };

View File

@ -34,7 +34,6 @@ const config = {
brotliSize: true, // Enable Brotli compression brotliSize: true, // Enable Brotli compression
}, },
}; };
export default config; export default config;