Test-app/app/routes/qrcodes.$id.scan.jsx
Albez0-An7h 49d55588b0 feat: QR redirection app
- Scanning the QR code app redicts to page
- Option to chose if we want to redirect to page or checkout
2026-03-04 13:36:11 +05:30

21 lines
602 B
JavaScript

import { redirect } from "react-router";
import invariant from "tiny-invariant";
import db from "../db.server";
import { getDestinationUrl } from "../models/QRCode.server";
export const loader = async ({ params }) => {
invariant(params.id, "Could not find QR code destination");
const id = Number(params.id);
const qrCode = await db.qRCode.findFirst({ where: { id } });
invariant(qrCode, "Could not find QR code destination");
await db.qRCode.update({
where: { id },
data: { scans: { increment: 1 } },
});
return redirect(getDestinationUrl(qrCode));
};