@octarq/plugin-links 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,469 @@
1
+ import { Field, Switch, Button, Select, FormError, Input, Textarea, Alert, StatusBadge, useTranslation } from "@octarq/plugin-sdk";
2
+ import { useEffect, useState } from "react";
3
+ import { useNavigate, useInRouterContext } from "react-router-dom";
4
+ import { linksApi, linksAiStatus, suggestLinkSlug, Link, LinksCapabilities } from "../api";
5
+ import { Sparkles, Trash2, Plus } from "lucide-react";
6
+
7
+ function DomainConfigNavButton({ onClick, label }: { onClick: () => void; label: string }) {
8
+ const inRouter = useInRouterContext();
9
+ if (inRouter) {
10
+ return <RouterDomainConfigNavButton onClick={onClick} label={label} />;
11
+ }
12
+ return (
13
+ <Button
14
+ variant="subtle"
15
+ size="sm"
16
+ type="button"
17
+ onClick={() => {
18
+ onClick();
19
+ if (typeof window !== "undefined") window.location.href = "/admin/domains";
20
+ }}
21
+ className="shrink-0 text-xs"
22
+ >
23
+ {label}
24
+ </Button>
25
+ );
26
+ }
27
+
28
+ function RouterDomainConfigNavButton({ onClick, label }: { onClick: () => void; label: string }) {
29
+ const navigate = useNavigate();
30
+ return (
31
+ <Button
32
+ variant="subtle"
33
+ size="sm"
34
+ type="button"
35
+ onClick={() => {
36
+ onClick();
37
+ navigate("/domains");
38
+ }}
39
+ className="shrink-0 text-xs"
40
+ >
41
+ {label}
42
+ </Button>
43
+ );
44
+ }
45
+
46
+ export function toLocalDatetimeInput(iso?: string | null): string {
47
+ if (!iso) return "";
48
+ const d = new Date(iso);
49
+ if (Number.isNaN(d.getTime())) return "";
50
+ const pad = (n: number) => String(n).padStart(2, "0");
51
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
52
+ }
53
+
54
+ export function localDatetimeInputToISO(value?: string | null): string | null {
55
+ if (!value) return null;
56
+ const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(value.trim());
57
+ if (m) {
58
+ const [, y, mo, da, hh, mm, ss] = m;
59
+ const d = new Date(Number(y), Number(mo) - 1, Number(da), Number(hh), Number(mm), Number(ss ?? 0));
60
+ return Number.isNaN(d.getTime()) ? null : d.toISOString();
61
+ }
62
+ const d = new Date(value);
63
+ return Number.isNaN(d.getTime()) ? null : d.toISOString();
64
+ }
65
+
66
+ export function LinkEditorForm({
67
+ link,
68
+ hosts: rawHosts = [],
69
+ onCancel,
70
+ onSaved,
71
+ }: {
72
+ link: Link | null;
73
+ hosts?: string[];
74
+ onCancel: () => void;
75
+ onSaved: (l?: any) => void;
76
+ }) {
77
+ const hosts = rawHosts ?? [];
78
+ const { t } = useTranslation();
79
+ const [slug, setSlug] = useState(link?.slug ?? "");
80
+ const [host, setHost] = useState(() => (link ? (link.host ?? "") : hosts.length > 0 ? hosts[0] : ""));
81
+ const [target, setTarget] = useState(link?.target ?? "");
82
+ const [title, setTitle] = useState(link?.title ?? "");
83
+ const [note, setNote] = useState(link?.note ?? "");
84
+ const [tags, setTags] = useState(link?.tags ?? "");
85
+ const [password, setPassword] = useState("");
86
+ const [expiresAt, setExpiresAt] = useState(() => toLocalDatetimeInput(link?.expiresAt));
87
+ const [expiredUrl, setExpiredUrl] = useState(link?.expiredUrl ?? "");
88
+ const [clickLimit, setClickLimit] = useState(link?.clickLimit ?? 0);
89
+ const [enabled, setEnabled] = useState(link?.enabled ?? true);
90
+ const [routingRules, setRoutingRules] = useState<any[]>(link?.routingRules ?? []);
91
+ const [err, setErr] = useState<string | { message?: string; status?: number; requestId?: string }>("");
92
+ const [fetching, setFetching] = useState(false);
93
+ const [showUtm, setShowUtm] = useState(false);
94
+ const [aiEnabled, setAiEnabled] = useState(false);
95
+ const [aiBusy, setAiBusy] = useState(false);
96
+ const [aiSlugs, setAiSlugs] = useState<string[]>([]);
97
+ const [geoCapabilities, setGeoCapabilities] = useState<LinksCapabilities | null>(null);
98
+
99
+ useEffect(() => {
100
+ linksAiStatus().then((s) => setAiEnabled(s.configured)).catch(() => {});
101
+ linksApi.capabilities().then(setGeoCapabilities).catch(() => setGeoCapabilities({ geoReady: false, mode: "unavailable" }));
102
+ }, []);
103
+
104
+ async function suggestSlugs() {
105
+ if (!target) return;
106
+ setAiBusy(true);
107
+ setAiSlugs([]);
108
+ try {
109
+ const r = await suggestLinkSlug(target, title || undefined);
110
+ setAiSlugs(r.slugs);
111
+ } catch {
112
+ setErr(t("links.aiSuggestFailed"));
113
+ } finally {
114
+ setAiBusy(false);
115
+ }
116
+ }
117
+
118
+ async function fetchTitle() {
119
+ if (!target) return;
120
+ setFetching(true);
121
+ try {
122
+ const m = await linksApi.linkMetadata(target);
123
+ if (m.title) setTitle(m.title);
124
+ } catch {
125
+ } finally {
126
+ setFetching(false);
127
+ }
128
+ }
129
+
130
+ async function save() {
131
+ setErr("");
132
+ const payload: any = {
133
+ slug,
134
+ host,
135
+ target,
136
+ title,
137
+ note,
138
+ tags,
139
+ enabled,
140
+ expiredUrl,
141
+ routingRules,
142
+ clickLimit: Number(clickLimit) || 0,
143
+ expiresAt: localDatetimeInputToISO(expiresAt),
144
+ };
145
+ if (password !== "") {
146
+ payload.password = password;
147
+ }
148
+ try {
149
+ let res;
150
+ if (link) res = await linksApi.updateLink(link.id, payload);
151
+ else res = await linksApi.createLink(payload);
152
+ onSaved(res);
153
+ } catch (e: any) {
154
+ if (e?.status === 400 && typeof e?.message === "string" && e.message.includes("host is required")) {
155
+ setErr({ message: t("links.hostRequired"), status: 400, requestId: e.requestId });
156
+ } else {
157
+ setErr(e);
158
+ }
159
+ }
160
+ }
161
+
162
+ return (
163
+ <div className="space-y-4 min-w-0">
164
+ <Field label={t("links.destinationTargetUrl")}>
165
+ <div className="flex gap-2 items-start min-w-0">
166
+ <Textarea
167
+ className="w-full font-mono text-sm min-w-0"
168
+ rows={3}
169
+ value={target}
170
+ onChange={(e) => setTarget(e.target.value)}
171
+ placeholder="https://example.com/blog-post-xyz"
172
+ required
173
+ />
174
+ <Button variant="subtle" className="shrink-0 text-xs py-2 mt-0.5" type="button" onClick={() => setShowUtm((v) => !v)}>
175
+ UTM
176
+ </Button>
177
+ </div>
178
+ </Field>
179
+ {showUtm && <UtmBuilder target={target} onApply={setTarget} />}
180
+
181
+ {hosts.length === 0 && (
182
+ <Alert variant="warning" className="mb-2">
183
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2 w-full">
184
+ <div className="text-xs">
185
+ <strong>{t("links.noDomainConfiguredTitle", "No custom domain configured.")}</strong>{" "}
186
+ {t("links.noDomainConfiguredDesc", "Short links require a configured domain on this instance.")}
187
+ </div>
188
+ <DomainConfigNavButton
189
+ onClick={onCancel}
190
+ label={t("links.goToDomains", "Configure Domains →")}
191
+ />
192
+ </div>
193
+ </Alert>
194
+ )}
195
+
196
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4 min-w-0">
197
+ <Field label={t("links.shortSlug")} hint={t("links.shortSlugHint")}>
198
+ <div className="flex gap-2 min-w-0">
199
+ <Input className="w-full font-mono min-w-0" value={slug} onChange={(e) => setSlug(e.target.value)} placeholder="e.g. promo2026" />
200
+ {aiEnabled && (
201
+ <Button variant="subtle" className="shrink-0 text-xs py-1 gap-1" type="button" onClick={suggestSlugs} disabled={aiBusy || !target}>
202
+ <Sparkles className="h-3.5 w-3.5" />
203
+ {aiBusy ? t("links.aiSuggesting") : t("links.aiSuggest")}
204
+ </Button>
205
+ )}
206
+ </div>
207
+ {aiSlugs.length > 0 && (
208
+ <div className="mt-2 flex flex-wrap gap-1.5 min-w-0">
209
+ {aiSlugs.map((s) => (
210
+ <button
211
+ key={s}
212
+ type="button"
213
+ onClick={() => setSlug(s)}
214
+ className="rounded-lg bg-info-bg border border-info-border px-2.5 py-1 text-xs font-mono text-info-fg hover:bg-info-fg/10 truncate max-w-full"
215
+ >
216
+ {s}
217
+ </button>
218
+ ))}
219
+ </div>
220
+ )}
221
+ </Field>
222
+ <Field label={t("links.routingHostDomain")} hint={hosts.length ? t("links.configuredDomains") : t("links.configureDomainsFirst")}>
223
+ <Select
224
+ value={host}
225
+ onValueChange={setHost}
226
+ options={[
227
+ ...(hosts.length === 0 ? [{ value: "", label: t("links.defaultApexDomain") }] : []),
228
+ ...hosts.map((h) => ({ value: h, label: h })),
229
+ ...(host && !hosts.includes(host) ? [{ value: host, label: host }] : []),
230
+ ]}
231
+ />
232
+ </Field>
233
+ </div>
234
+
235
+ <Field label={t("links.metadataPageTitle")}>
236
+ <div className="flex gap-2 min-w-0">
237
+ <Input className="w-full text-sm min-w-0" value={title} onChange={(e) => setTitle(e.target.value)} placeholder={t("links.metadataPlaceholder")} />
238
+ <Button variant="subtle" className="shrink-0 text-xs py-1" type="button" onClick={fetchTitle} disabled={fetching}>
239
+ {fetching ? t("links.fetching") : t("links.fetch")}
240
+ </Button>
241
+ </div>
242
+ </Field>
243
+
244
+ <Field label={t("links.tags")} hint={t("links.tagsHint")}>
245
+ <Input className="w-full text-sm min-w-0" value={tags} onChange={(e) => setTags(e.target.value)} placeholder="e.g. q3-ads, product-hunt" />
246
+ </Field>
247
+
248
+ <Field label={t("links.internalAdminNote")}>
249
+ <Textarea className="w-full text-sm min-w-0" rows={2} value={note} onChange={(e) => setNote(e.target.value)} placeholder={t("links.notePlaceholder")} />
250
+ </Field>
251
+
252
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4 min-w-0">
253
+ <Field label={t("links.accessProtectionPassword")} hint={link?.hasPassword ? t("links.passwordSetHint") : t("links.passwordOptionalHint")}>
254
+ <Input className="w-full font-mono text-sm min-w-0" type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="e.g. 123456" />
255
+ </Field>
256
+ <Field label={t("links.totalClickLimitation")} hint={t("links.clickLimitHint")}>
257
+ <Input
258
+ type="number"
259
+ min={0}
260
+ className="w-full font-mono min-w-0"
261
+ value={clickLimit}
262
+ onChange={(e) => setClickLimit(Number(e.target.value))}
263
+ />
264
+ </Field>
265
+ </div>
266
+
267
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4 min-w-0">
268
+ <Field label={t("links.automaticExpiryDate")}>
269
+ <Input type="datetime-local" className="w-full text-sm min-w-0" value={expiresAt} onChange={(e) => setExpiresAt(e.target.value)} />
270
+ </Field>
271
+ <Field label={t("links.redirectUrlAfterExpiry")} hint={t("links.redirectUrlHint")}>
272
+ <Input className="w-full text-sm font-mono min-w-0" value={expiredUrl} onChange={(e) => setExpiredUrl(e.target.value)} placeholder="e.g. https://my-site.com/expired" />
273
+ </Field>
274
+ </div>
275
+
276
+ <div className="flex items-center gap-3 pt-2 min-w-0">
277
+ <Switch checked={enabled} onCheckedChange={setEnabled} aria-label={t("links.linkRoutingActive")} />
278
+ <span className="text-sm text-muted-foreground select-none">{t("links.linkRoutingActive")}</span>
279
+ </div>
280
+
281
+ <Field label={t("links.routingRules")}>
282
+ <RoutingRulesEditor rules={routingRules} onChange={setRoutingRules} geoReady={geoCapabilities?.geoReady ?? false} />
283
+ </Field>
284
+
285
+ {err && <FormError err={err} />}
286
+
287
+ <div className="flex justify-end gap-2.5 pt-4 border-t border-border min-w-0">
288
+ <Button variant="ghost" onClick={onCancel}>
289
+ {t("links.cancel")}
290
+ </Button>
291
+ <Button variant="primary" onClick={save} disabled={!target}>
292
+ {t("links.saveLink")}
293
+ </Button>
294
+ </div>
295
+ </div>
296
+ );
297
+ }
298
+
299
+
300
+ function UtmBuilder({ target, onApply }: { target: string; onApply: (url: string) => void }) {
301
+ const { t } = useTranslation();
302
+ const [utm, setUtm] = useState({ source: "", medium: "", campaign: "", term: "", content: "" });
303
+ function apply() {
304
+ if (!target) return;
305
+ let base = target;
306
+ if (!base.includes("://")) base = "https://" + base;
307
+ try {
308
+ const u = new URL(base);
309
+ const map: Record<string, string> = {
310
+ utm_source: utm.source,
311
+ utm_medium: utm.medium,
312
+ utm_campaign: utm.campaign,
313
+ utm_term: utm.term,
314
+ utm_content: utm.content,
315
+ };
316
+ for (const [k, v] of Object.entries(map)) {
317
+ if (v) u.searchParams.set(k, v);
318
+ else u.searchParams.delete(k);
319
+ }
320
+ onApply(u.toString());
321
+ } catch {
322
+ }
323
+ }
324
+ const fields: [keyof typeof utm, string][] = [
325
+ ["source", "source"],
326
+ ["medium", "medium"],
327
+ ["campaign", "campaign"],
328
+ ["term", "term"],
329
+ ["content", "content"],
330
+ ];
331
+ return (
332
+ <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2.5 p-4 bg-well border border-border rounded-lg min-w-0">
333
+ {fields.map(([k, label]) => (
334
+ <Input
335
+ key={k}
336
+ className="w-full text-xs h-8 min-w-0"
337
+ placeholder={`utm_${label}`}
338
+ value={utm[k]}
339
+ onChange={(e) => setUtm({ ...utm, [k]: e.target.value })}
340
+ />
341
+ ))}
342
+ <Button variant="subtle" className="sm:col-span-2 md:col-span-3 h-8 text-xs py-1.5" onClick={apply}>
343
+ {t("links.applyUtmParameters")}
344
+ </Button>
345
+ </div>
346
+ );
347
+ }
348
+
349
+ function RoutingRulesEditor({ rules, onChange, geoReady }: { rules: any[]; onChange: (r: any[]) => void; geoReady: boolean }) {
350
+ const { t } = useTranslation();
351
+ const types = [
352
+ { value: "geo", label: t("links.ruleTypeGeo") },
353
+ { value: "device", label: t("links.ruleTypeDevice") },
354
+ { value: "os", label: t("links.ruleTypeOS") },
355
+ { value: "language", label: t("links.ruleTypeLanguage") },
356
+ { value: "split", label: t("links.ruleTypeSplit") },
357
+ ];
358
+
359
+ const splitTotal = rules.filter((r) => r.type === "split").reduce((acc, r) => acc + (Number(r.weight) || 0), 0);
360
+ const splitRem = Math.max(0, 100 - splitTotal);
361
+
362
+ return (
363
+ <div className="space-y-3 min-w-0">
364
+ {rules.map((rule, i) => (
365
+ <div key={i} className="flex gap-2 items-start bg-well p-3 rounded-lg border border-border min-w-0">
366
+ <div className="flex-1 space-y-2 min-w-0">
367
+ <div className="flex gap-2 min-w-0">
368
+ <div className="w-1/3 min-w-[100px] shrink-0">
369
+ <Select
370
+ value={rule.type}
371
+ onValueChange={(v) => {
372
+ const next = [...rules];
373
+ next[i] = { ...rule, type: v };
374
+ if (v === "split") {
375
+ delete next[i].match;
376
+ next[i].weight = 50;
377
+ } else {
378
+ delete next[i].weight;
379
+ next[i].match = "";
380
+ }
381
+ onChange(next);
382
+ }}
383
+ options={types}
384
+ />
385
+ </div>
386
+ <div className="flex-1 min-w-0">
387
+ {rule.type === "split" ? (
388
+ <Input
389
+ type="number"
390
+ min={0}
391
+ max={100}
392
+ className="w-full text-sm font-mono min-w-0"
393
+ placeholder={t("links.ruleWeight")}
394
+ value={rule.weight ?? ""}
395
+ onChange={(e) => {
396
+ const next = [...rules];
397
+ next[i] = { ...rule, weight: Number(e.target.value) };
398
+ onChange(next);
399
+ }}
400
+ />
401
+ ) : (
402
+ <Input
403
+ className="w-full text-sm font-mono min-w-0"
404
+ placeholder={t("links.ruleMatch")}
405
+ value={rule.match ?? ""}
406
+ onChange={(e) => {
407
+ const next = [...rules];
408
+ next[i] = { ...rule, match: e.target.value };
409
+ onChange(next);
410
+ }}
411
+ />
412
+ )}
413
+ </div>
414
+ </div>
415
+ {rule.type === "geo" && (
416
+ <div className="flex items-center gap-2 pt-0.5">
417
+ {geoReady ? (
418
+ <StatusBadge tone="success" shape="dot">
419
+ {t("links.geoReady", "GeoIP Active")}
420
+ </StatusBadge>
421
+ ) : (
422
+ <StatusBadge tone="warning" shape="dash" title={t("links.geoUnavailableDesc", "Server lacks GeoIP database. Country routing is bypassed.")}>
423
+ {t("links.geoUnavailable", "GeoIP Unavailable (bypassed)")}
424
+ </StatusBadge>
425
+ )}
426
+ {!geoReady && (
427
+ <span className="text-[11px] text-warning-fg">
428
+ {t("links.geoUnavailableDesc", "Server lacks GeoIP database. Country routing is bypassed.")}
429
+ </span>
430
+ )}
431
+ </div>
432
+ )}
433
+ <Input
434
+ className="w-full text-sm font-mono min-w-0"
435
+ placeholder={t("links.ruleTarget")}
436
+ value={rule.target ?? ""}
437
+ onChange={(e) => {
438
+ const next = [...rules];
439
+ next[i] = { ...rule, target: e.target.value };
440
+ onChange(next);
441
+ }}
442
+ />
443
+ </div>
444
+ <Button variant="ghost" className="shrink-0 p-2 text-danger-fg" onClick={() => {
445
+ const next = [...rules];
446
+ next.splice(i, 1);
447
+ onChange(next);
448
+ }}>
449
+ <Trash2 className="h-4 w-4" />
450
+ </Button>
451
+ </div>
452
+ ))}
453
+
454
+ <div className="flex items-center justify-between mt-2 flex-wrap gap-2 min-w-0">
455
+ <Button variant="subtle" className="text-xs py-1.5 gap-1" onClick={() => onChange([...rules, { type: "split", weight: 50, target: "" }])}>
456
+ <Plus className="h-3.5 w-3.5" />
457
+ {t("links.addRule")}
458
+ </Button>
459
+
460
+ {rules.some((r) => r.type === "split") && (
461
+ <div className="text-xs text-muted-foreground font-mono">
462
+ {t("links.splitTotalLabel", { total: splitTotal })} · {t("links.ruleSplitRemainder")}: {splitRem}%
463
+ </div>
464
+ )}
465
+ </div>
466
+ </div>
467
+ );
468
+ }
469
+
@@ -0,0 +1,135 @@
1
+ import { Button, buttonVariants, cn, Modal, useTranslation } from "@octarq/plugin-sdk";
2
+ import { Link } from "../api";
3
+ import { Check, Copy, Download } from "lucide-react";
4
+ import { LinkEditorForm } from "./LinkEditorForm";
5
+ import { StatsView } from "./StatsView";
6
+
7
+ export interface LinkModalsProps {
8
+ createOpen: boolean;
9
+ editingLink: Link | null;
10
+ analyticsLink: Link | null;
11
+ qrLink: Link | null;
12
+ linkHostOptions: string[];
13
+ copiedId: number | null;
14
+ onCloseCreate: () => void;
15
+ onCloseEdit: () => void;
16
+ onCloseAnalytics: () => void;
17
+ onCloseQr: () => void;
18
+ onRefreshLinks: () => void;
19
+ onCopyQrLink: (l: Link) => void;
20
+ linkURL: (l: Link) => string;
21
+ }
22
+
23
+ export function LinkModals({
24
+ createOpen,
25
+ editingLink,
26
+ analyticsLink,
27
+ qrLink,
28
+ linkHostOptions,
29
+ copiedId,
30
+ onCloseCreate,
31
+ onCloseEdit,
32
+ onCloseAnalytics,
33
+ onCloseQr,
34
+ onRefreshLinks,
35
+ onCopyQrLink,
36
+ linkURL,
37
+ }: LinkModalsProps) {
38
+ const { t } = useTranslation();
39
+
40
+ return (
41
+ <>
42
+ {createOpen && (
43
+ <Modal title={t("links.createNewLink")} onClose={onCloseCreate}>
44
+ <div className="p-1">
45
+ <LinkEditorForm
46
+ link={null}
47
+ hosts={linkHostOptions}
48
+ onCancel={onCloseCreate}
49
+ onSaved={() => {
50
+ onCloseCreate();
51
+ onRefreshLinks();
52
+ }}
53
+ />
54
+ </div>
55
+ </Modal>
56
+ )}
57
+
58
+ {editingLink && (
59
+ <Modal
60
+ title={`${t("links.editLink")} — ${editingLink.title || `/${editingLink.slug}`}`}
61
+ onClose={onCloseEdit}
62
+ >
63
+ <div className="p-1">
64
+ <LinkEditorForm
65
+ key={editingLink.id}
66
+ link={editingLink}
67
+ hosts={linkHostOptions}
68
+ onCancel={onCloseEdit}
69
+ onSaved={() => {
70
+ onCloseEdit();
71
+ onRefreshLinks();
72
+ }}
73
+ />
74
+ </div>
75
+ </Modal>
76
+ )}
77
+
78
+ {analyticsLink && (
79
+ <Modal
80
+ title={`${t("links.clickPerformanceAnalytics")} — ${analyticsLink.title || `/${analyticsLink.slug}`}`}
81
+ onClose={onCloseAnalytics}
82
+ >
83
+ <div className="p-2 max-h-[80vh] overflow-y-auto">
84
+ <StatsView link={analyticsLink} />
85
+ </div>
86
+ </Modal>
87
+ )}
88
+
89
+ {qrLink && (
90
+ <Modal
91
+ title={`${t("links.linkQrCode")} — ${qrLink.title || `/${qrLink.slug}`}`}
92
+ onClose={onCloseQr}
93
+ >
94
+ <div className="flex flex-col items-center gap-5 py-4">
95
+ {/* ui-color-ok: QR modules require a solid white quiet zone in both light and dark themes */}
96
+ <div className="rounded-lg border border-border bg-white p-4">
97
+ <img
98
+ src={`/api/links/${qrLink.id}/qr`}
99
+ alt={t("links.qrAlt")}
100
+ className="rounded-lg"
101
+ width={220}
102
+ height={220}
103
+ />
104
+ </div>
105
+ <div className="font-mono text-xs text-foreground bg-well px-3 py-1.5 rounded-lg border border-border truncate max-w-sm">
106
+ {linkURL(qrLink)}
107
+ </div>
108
+ <div className="flex items-center gap-2">
109
+ <Button
110
+ variant="subtle"
111
+ className="text-xs py-1.5 px-4 gap-1.5"
112
+ onClick={() => onCopyQrLink(qrLink)}
113
+ >
114
+ {copiedId === qrLink.id ? (
115
+ <Check className="h-3.5 w-3.5 text-success-fg" />
116
+ ) : (
117
+ <Copy className="h-3.5 w-3.5" />
118
+ )}
119
+ {copiedId === qrLink.id ? t("links.copied") : t("links.copyLink")}
120
+ </Button>
121
+ <a
122
+ href={`/api/links/${qrLink.id}/qr`}
123
+ download={`qr-${qrLink.slug}.png`}
124
+ className={cn(buttonVariants({ variant: "primary" }), "text-xs py-1.5 px-4 gap-1.5")}
125
+ >
126
+ <Download className="h-3.5 w-3.5" />
127
+ {t("links.downloadQrCode")}
128
+ </a>
129
+ </div>
130
+ </div>
131
+ </Modal>
132
+ )}
133
+ </>
134
+ );
135
+ }