Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/easyaccessqr
BETTER_AUTH_URL: http://127.0.0.1:3000
BETTER_AUTH_SECRET: ci-super-secret-value
BETTER_AUTH_SECRET: ci-only-secret-at-least-32-characters-long
BETTER_AUTH_TRUSTED_ORIGINS: http://127.0.0.1:3000,http://localhost:3000
ALLOWED_HOSTS: localhost,127.0.0.1
API_ALLOWED_ORIGINS: http://127.0.0.1:3000,http://localhost:3000
Expand Down
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,41 @@ bun run dev
- Hitting a short link (`/r/:org/:slug`) records a view and redirects to the selected destination.
- If a code is paused, a styled status page is shown.
- If a code is public, `?view=1` renders a public QR preview page without auth.

## Campaign toolkit release

The QR toolkit is available from workspace navigation at `/app/toolkit`.

1. **Wi-Fi QR codes** — personal network credentials, hidden networks, and open networks.
2. **Contact QR codes** — vCard 4.0 with name, company, phone, email, and website.
3. **Email QR codes** — recipient, subject, and prefilled message.
4. **SMS QR codes** — international number and prefilled message.
5. **Phone QR codes** — dialer links using international numbers.
6. **Map QR codes** — validated latitude and longitude, including zero coordinates.
7. **Text QR codes** — multiline and Unicode content.
8. **WhatsApp QR codes** — click-to-chat links with prefilled messages.
9. **Campaign URL builder** — source, medium, campaign, term, and content parameters.
10. **Tracking cleanup** — remove UTM and common advertising identifiers while retaining other query parameters and anchors.
11. **Printable QR cards** — custom heading and caption, with PNG/SVG downloads and a print layout.
12. **Bulk pause** — stop redirects for selected codes in one operation.
13. **Bulk resume** — reactivate codes with atomic plan-limit checks.
14. **Bulk visibility** — enable or disable public preview pages.
15. **Bulk tagging** — add or remove a tag, respecting the 12-tag limit.
16. **Bulk link copying** — copy selected tracked URLs, one per line.
17. **Visibility filtering** — find codes with public pages enabled or disabled.
18. **Routing filtering** — distinguish single destinations from weighted routing.
19. **Scan-activity filtering** — find codes that have never been scanned or already have scans.
20. **Library pagination** — 10, 25, or 50 codes per page with selection across pages.

Toolkit codes embed their content directly: they are not stored as managed codes,
are not editable after printing, and do not produce scan analytics. Network
passwords are included in Wi-Fi codes; share the resulting card appropriately.
Scanner support for contact and action formats depends on the scanning device.
Payload conventions follow [ZXing's barcode content documentation](https://github.com/zxing/zxing/wiki/Barcode-Contents)
and [vCard 4.0 (RFC 6350)](https://www.rfc-editor.org/rfc/rfc6350).

Batch writes affect at most 100 selected codes in the current organization. A
missing or unauthorized code, tag overflow, or activation-limit failure rolls
back the whole batch. Changing filters clears selection. Individual and batch
activation writes share an organization lock to protect plan limits under
concurrent requests. This release requires no database schema migration.
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default defineConfig({
...process.env,
BETTER_AUTH_URL: process.env.BETTER_AUTH_URL ?? baseURL,
BETTER_AUTH_SECRET:
process.env.BETTER_AUTH_SECRET ?? "playwright-local-secret",
process.env.BETTER_AUTH_SECRET ?? "playwright-local-secret-at-least-32-characters",
BETTER_AUTH_TRUSTED_ORIGINS:
process.env.BETTER_AUTH_TRUSTED_ORIGINS ??
"http://127.0.0.1:3000,http://localhost:3000",
Expand Down
10 changes: 10 additions & 0 deletions src/components/app-command-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ export function AppCommandMenu({
icon: QrCode,
action: () => navigate({ to: "/app/qr-codes" }),
},
{
id: "go-toolkit",
group: "Navigation",
label: "Open QR toolkit",
description: "/app/toolkit",
keywords:
"wifi contact email sms phone map text whatsapp campaign print",
icon: QrCode,
action: () => navigate({ to: "/app/toolkit" }),
},
{
id: "go-analytics",
group: "Navigation",
Expand Down
49 changes: 49 additions & 0 deletions src/components/qr/qr-library-controls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { LibraryFilters } from "@/lib/qr-library";
export function QrLibraryFilters({
value,
onChange,
}: {
value: LibraryFilters;
onChange: (value: LibraryFilters) => void;
}) {
return (
<div className="mt-3 grid gap-3 sm:grid-cols-3">
<label className="toolkit-label">
Public page
<select
className="toolkit-input"
value={value.visibility}
onChange={(e) => onChange({ ...value, visibility: e.target.value })}
>
<option value="all">All visibility</option>
<option value="public">Public page enabled</option>
<option value="private">Public page disabled</option>
</select>
</label>
<label className="toolkit-label">
Routing
<select
className="toolkit-input"
value={value.routing}
onChange={(e) => onChange({ ...value, routing: e.target.value })}
>
<option value="all">All routing</option>
<option value="single">Single destination</option>
<option value="weighted">Weighted destinations</option>
</select>
</label>
<label className="toolkit-label">
Scan activity
<select
className="toolkit-input"
value={value.activity}
onChange={(e) => onChange({ ...value, activity: e.target.value })}
>
<option value="all">All scan activity</option>
<option value="never">Never scanned</option>
<option value="scanned">Has scans</option>
</select>
</label>
</div>
);
}
143 changes: 143 additions & 0 deletions src/components/qr/qr-toolkit-preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import type QRCodeStyling from "qr-code-styling";
import { useEffect, useRef, useState } from "react";
import { toast } from "sonner";
import { copyText } from "@/lib/client-export";
import { downloadQrAsset } from "@/lib/qr-export";
import { slugifyQrName } from "@/lib/qr-links";

export function QrToolkitPreview({
data,
title,
caption,
}: {
data: string;
title: string;
caption: string;
}) {
const container = useRef<HTMLDivElement>(null);
const instance = useRef<QRCodeStyling | null>(null);
const [readyData, setReadyData] = useState("");
const [error, setError] = useState("");
useEffect(() => {
let cancelled = false;
setReadyData("");
setError("");
instance.current = null;
container.current?.replaceChildren();
if (!data) return;
void import("qr-code-styling")
.then(async ({ default: QR }) => {
const qr = new QR({
width: 600,
height: 600,
type: "svg",
data,
margin: 48,
qrOptions: { errorCorrectionLevel: "Q" },
dotsOptions: { color: "#172522" },
backgroundOptions: { color: "#ffffff" },
});
await qr.getRawData("svg");
if (cancelled || !container.current) return;
instance.current = qr;
qr.append(container.current);
setReadyData(data);
})
.catch(() => {
if (!cancelled)
setError(
"Unable to render this QR code. Try shorter content or reload the page.",
);
});
return () => {
cancelled = true;
};
}, [data]);
const ready = Boolean(data && readyData === data);
async function download(extension: "png" | "svg") {
if (!ready || !instance.current) return;
try {
await downloadQrAsset({
instance: instance.current,
name: slugifyQrName(title) || "qr-card",
extension,
backgroundColor: "#ffffff",
});
} catch {
toast.error("The download failed. Please try again.");
}
}
return (
<section className="space-y-4 rounded-2xl border border-ds-border bg-ds-surface p-5">
<div
id="toolkit-print-card"
className="rounded-xl bg-[#ffffff] p-5 text-center text-[#172522]"
>
<h2 className="break-words text-2xl font-bold">{title || "Scan me"}</h2>
<div
role="img"
aria-label="QR code preview"
ref={container}
className="mx-auto my-4 aspect-square w-full max-w-[320px] [&>svg]:h-full [&>svg]:w-full"
/>
<p className="whitespace-pre-wrap break-words text-sm">
{caption || "Point your camera at the QR code"}
</p>
</div>
{error ? (
<p role="alert" className="text-sm text-red-600">
{error}
</p>
) : null}
<div className="flex flex-wrap gap-2">
<button
className="toolkit-button"
disabled={!ready}
type="button"
onClick={() => void download("png")}
>
Download PNG
</button>
<button
className="toolkit-button"
disabled={!ready}
type="button"
onClick={() => void download("svg")}
>
Download SVG
</button>
<button
className="toolkit-button"
disabled={!ready}
type="button"
onClick={() => window.print()}
>
Print QR card
</button>
<button
className="toolkit-button"
disabled={!ready}
type="button"
onClick={() =>
void copyText(data)
.then(() => toast.success("QR content copied"))
.catch(() => toast.error("Unable to copy content."))
}
>
Copy content
</button>
</div>
<details>
<summary className="cursor-pointer text-sm font-semibold">
Encoded content
</summary>
<pre
className="mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-all text-xs"
data-testid="toolkit-payload"
>
{data}
</pre>
</details>
</section>
);
}
Loading
Loading