glitchgrab 1.65.2 → 1.66.1
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.
- package/README.md +13 -5
- package/dist/index.d.mts +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +525 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +524 -41
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +51 -4
- package/dist/server.d.ts +51 -4
- package/dist/server.js +31 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +30 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8976,7 +8976,7 @@ function getPlaceholder(type, idx = 0, hasVoice = false) {
|
|
|
8976
8976
|
case "OTHER":
|
|
8977
8977
|
return "Tell us what's on your mind...";
|
|
8978
8978
|
case "VIDEO_SCRIPT":
|
|
8979
|
-
return "
|
|
8979
|
+
return "Describe the video or paste a script, and say which screens it should show...";
|
|
8980
8980
|
}
|
|
8981
8981
|
}
|
|
8982
8982
|
function getTypeIcon(type, color, size = 24) {
|
|
@@ -9103,6 +9103,70 @@ function getTypeIcon(type, color, size = 24) {
|
|
|
9103
9103
|
// src/booking-dialog.tsx
|
|
9104
9104
|
import { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo3, useState as useState5 } from "react";
|
|
9105
9105
|
|
|
9106
|
+
// src/calendar-links.ts
|
|
9107
|
+
function stamp(iso) {
|
|
9108
|
+
return new Date(iso).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "");
|
|
9109
|
+
}
|
|
9110
|
+
function details(ev) {
|
|
9111
|
+
return [ev.description, ev.meetUrl ? `Join: ${ev.meetUrl}` : null].filter(Boolean).join("\n\n");
|
|
9112
|
+
}
|
|
9113
|
+
function googleCalendarUrl(ev) {
|
|
9114
|
+
const params = new URLSearchParams({
|
|
9115
|
+
action: "TEMPLATE",
|
|
9116
|
+
text: ev.title,
|
|
9117
|
+
dates: `${stamp(ev.startsAt)}/${stamp(ev.endsAt)}`,
|
|
9118
|
+
details: details(ev)
|
|
9119
|
+
});
|
|
9120
|
+
if (ev.meetUrl) params.set("location", ev.meetUrl);
|
|
9121
|
+
return `https://calendar.google.com/calendar/render?${params.toString()}`;
|
|
9122
|
+
}
|
|
9123
|
+
function esc(s) {
|
|
9124
|
+
return s.replace(/\\/g, "\\\\").replace(/;/g, ";").replace(/,/g, "\\,").replace(/\r?\n/g, "\\n");
|
|
9125
|
+
}
|
|
9126
|
+
function fold(line) {
|
|
9127
|
+
const out = [];
|
|
9128
|
+
let rest = line;
|
|
9129
|
+
while (rest.length > 74) {
|
|
9130
|
+
out.push(rest.slice(0, 74));
|
|
9131
|
+
rest = ` ${rest.slice(74)}`;
|
|
9132
|
+
}
|
|
9133
|
+
out.push(rest);
|
|
9134
|
+
return out.join("\r\n");
|
|
9135
|
+
}
|
|
9136
|
+
function buildIcs(ev) {
|
|
9137
|
+
const lines = [
|
|
9138
|
+
"BEGIN:VCALENDAR",
|
|
9139
|
+
"VERSION:2.0",
|
|
9140
|
+
"PRODID:-//Glitchgrab//Booking//EN",
|
|
9141
|
+
"CALSCALE:GREGORIAN",
|
|
9142
|
+
"METHOD:PUBLISH",
|
|
9143
|
+
"BEGIN:VEVENT",
|
|
9144
|
+
`UID:${ev.id}@glitchgrab.dev`,
|
|
9145
|
+
`DTSTAMP:${stamp((/* @__PURE__ */ new Date()).toISOString())}`,
|
|
9146
|
+
`DTSTART:${stamp(ev.startsAt)}`,
|
|
9147
|
+
`DTEND:${stamp(ev.endsAt)}`,
|
|
9148
|
+
`SUMMARY:${esc(ev.title)}`,
|
|
9149
|
+
`DESCRIPTION:${esc(details(ev))}`,
|
|
9150
|
+
...ev.meetUrl ? [`LOCATION:${esc(ev.meetUrl)}`, `URL:${ev.meetUrl}`] : [],
|
|
9151
|
+
// 15 minutes before — the calendar's own reminder, the point of the feature.
|
|
9152
|
+
"BEGIN:VALARM",
|
|
9153
|
+
"ACTION:DISPLAY",
|
|
9154
|
+
"DESCRIPTION:Demo starts in 15 minutes",
|
|
9155
|
+
"TRIGGER:-PT15M",
|
|
9156
|
+
"END:VALARM",
|
|
9157
|
+
"END:VEVENT",
|
|
9158
|
+
"END:VCALENDAR"
|
|
9159
|
+
];
|
|
9160
|
+
return lines.map(fold).join("\r\n") + "\r\n";
|
|
9161
|
+
}
|
|
9162
|
+
function icsDownloadUrl(ev) {
|
|
9163
|
+
try {
|
|
9164
|
+
return URL.createObjectURL(new Blob([buildIcs(ev)], { type: "text/calendar;charset=utf-8" }));
|
|
9165
|
+
} catch (e) {
|
|
9166
|
+
return null;
|
|
9167
|
+
}
|
|
9168
|
+
}
|
|
9169
|
+
|
|
9106
9170
|
// src/phone.ts
|
|
9107
9171
|
var COUNTRIES = [
|
|
9108
9172
|
{ iso: "IN", name: "India", dial: "91" },
|
|
@@ -9170,10 +9234,12 @@ function readQuestions(value) {
|
|
|
9170
9234
|
if (!Array.isArray(value)) return [];
|
|
9171
9235
|
return value.flatMap((row) => {
|
|
9172
9236
|
if (!row || typeof row !== "object") return [];
|
|
9173
|
-
const { id, label, options, required } = row;
|
|
9174
|
-
if (typeof id !== "string" || typeof label !== "string"
|
|
9237
|
+
const { id, label, options, required, type } = row;
|
|
9238
|
+
if (typeof id !== "string" || typeof label !== "string") return [];
|
|
9239
|
+
if (type === "text") return [{ id, label, type: "text", options: [], required: required !== false }];
|
|
9240
|
+
if (!Array.isArray(options)) return [];
|
|
9175
9241
|
const choices = options.filter((o) => typeof o === "string" && o !== "");
|
|
9176
|
-
return choices.length > 0 ? [{ id, label, options: choices, required: required !== false }] : [];
|
|
9242
|
+
return choices.length > 0 ? [{ id, label, type: "choice", options: choices, required: required !== false }] : [];
|
|
9177
9243
|
});
|
|
9178
9244
|
}
|
|
9179
9245
|
var LIGHT = {
|
|
@@ -9337,6 +9403,7 @@ function BookingDialog({
|
|
|
9337
9403
|
const [dial, setDial] = useState5(() => defaultDialForZone(localZone()));
|
|
9338
9404
|
const [phoneTouched, setPhoneTouched] = useState5(false);
|
|
9339
9405
|
const [tried, setTried] = useState5(false);
|
|
9406
|
+
const [toast, setToast] = useState5(null);
|
|
9340
9407
|
const [questions, setQuestions] = useState5([]);
|
|
9341
9408
|
const [answers, setAnswers] = useState5({});
|
|
9342
9409
|
const [pageLoaded, setPageLoaded] = useState5(false);
|
|
@@ -9440,8 +9507,14 @@ function BookingDialog({
|
|
|
9440
9507
|
const daySlots = day ? (_d = byDay.get(day)) != null ? _d : [] : [];
|
|
9441
9508
|
const atFirstMonth = month <= today.slice(0, 7);
|
|
9442
9509
|
const pastHorizon = monthLoaded && !error && byDay.size === 0 && !atFirstMonth;
|
|
9443
|
-
const
|
|
9444
|
-
|
|
9510
|
+
const isAnswered = (q) => {
|
|
9511
|
+
var _a2;
|
|
9512
|
+
return q.type === "text" ? Boolean((_a2 = answers[q.id]) == null ? void 0 : _a2.trim()) : q.options.includes(answers[q.id]);
|
|
9513
|
+
};
|
|
9514
|
+
const given = questions.flatMap(
|
|
9515
|
+
(q) => isAnswered(q) ? [{ ...q, answer: q.type === "text" ? answers[q.id].trim() : answers[q.id] }] : []
|
|
9516
|
+
);
|
|
9517
|
+
const unanswered = questions.filter((q) => q.required && !isAnswered(q));
|
|
9445
9518
|
const phoneError = phoneProblem(dial, phone);
|
|
9446
9519
|
const nameMissing = !name.trim();
|
|
9447
9520
|
const emailMissing = !email.includes("@");
|
|
@@ -9452,12 +9525,25 @@ function BookingDialog({
|
|
|
9452
9525
|
...unanswered.map((q) => `an answer to \u201C${q.label}\u201D`),
|
|
9453
9526
|
...selected ? [] : ["a day and time"]
|
|
9454
9527
|
];
|
|
9528
|
+
useEffect5(() => {
|
|
9529
|
+
if (!toast) return;
|
|
9530
|
+
const id = setTimeout(() => setToast(null), 4500);
|
|
9531
|
+
return () => clearTimeout(id);
|
|
9532
|
+
}, [toast]);
|
|
9455
9533
|
const roomy = step === "pick";
|
|
9456
9534
|
async function startBooking() {
|
|
9457
|
-
var _a2, _b2, _c2;
|
|
9535
|
+
var _a2, _b2, _c2, _d2;
|
|
9458
9536
|
if (missing.length > 0 || !selected) {
|
|
9459
9537
|
setTried(true);
|
|
9460
9538
|
setPhoneTouched(true);
|
|
9539
|
+
const parts = [
|
|
9540
|
+
...nameMissing ? ["your name"] : [],
|
|
9541
|
+
...phoneError ? ["a valid mobile number"] : [],
|
|
9542
|
+
...emailMissing ? ["your email"] : [],
|
|
9543
|
+
...unanswered.length ? [unanswered.length === 1 ? "1 required answer" : `${unanswered.length} required answers`] : [],
|
|
9544
|
+
...selected ? [] : ["a day and time"]
|
|
9545
|
+
];
|
|
9546
|
+
setToast(`Add ${parts.length > 1 ? `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}` : parts[0]}`);
|
|
9461
9547
|
return;
|
|
9462
9548
|
}
|
|
9463
9549
|
if (preview) {
|
|
@@ -9489,9 +9575,10 @@ function BookingDialog({
|
|
|
9489
9575
|
return;
|
|
9490
9576
|
}
|
|
9491
9577
|
if (json.data.confirmed) {
|
|
9492
|
-
|
|
9578
|
+
setBookingId((_b2 = json.data.bookingId) != null ? _b2 : null);
|
|
9579
|
+
setMeetUrl((_c2 = json.data.meetUrl) != null ? _c2 : null);
|
|
9493
9580
|
setStep("done");
|
|
9494
|
-
reportBooked(json.data.bookingId, (
|
|
9581
|
+
reportBooked(json.data.bookingId, (_d2 = json.data.meetUrl) != null ? _d2 : null);
|
|
9495
9582
|
return;
|
|
9496
9583
|
}
|
|
9497
9584
|
setBookingId(json.data.bookingId);
|
|
@@ -9538,6 +9625,7 @@ function BookingDialog({
|
|
|
9538
9625
|
const selectedEnd = selected ? (_e = selected.endsAt) != null ? _e : new Date(new Date(selected.startsAt).getTime() + page.slotMinutes * 6e4).toISOString() : null;
|
|
9539
9626
|
const monthDate = new Date(keyToUtc(`${month}-01`));
|
|
9540
9627
|
const muted = { color: t.muted };
|
|
9628
|
+
const calendarEvent = step === "done" && bookingId && selected && selectedEnd ? { id: bookingId, title: page.title, startsAt: selected.startsAt, endsAt: selectedEnd, meetUrl } : null;
|
|
9541
9629
|
const credit = /* @__PURE__ */ jsx6(
|
|
9542
9630
|
"div",
|
|
9543
9631
|
{
|
|
@@ -9975,7 +10063,7 @@ function BookingDialog({
|
|
|
9975
10063
|
}
|
|
9976
10064
|
)
|
|
9977
10065
|
] });
|
|
9978
|
-
const
|
|
10066
|
+
const details2 = /* @__PURE__ */ jsxs6(
|
|
9979
10067
|
"div",
|
|
9980
10068
|
{
|
|
9981
10069
|
style: {
|
|
@@ -10029,7 +10117,22 @@ function BookingDialog({
|
|
|
10029
10117
|
),
|
|
10030
10118
|
!pageLoaded && /* @__PURE__ */ jsx6("div", { style: { fontSize: 13, ...muted }, children: "Loading\u2026" }),
|
|
10031
10119
|
questions.map((q) => {
|
|
10120
|
+
var _a2;
|
|
10032
10121
|
const gap = tried && unanswered.includes(q);
|
|
10122
|
+
if (q.type === "text") {
|
|
10123
|
+
return /* @__PURE__ */ jsx6(
|
|
10124
|
+
Field,
|
|
10125
|
+
{
|
|
10126
|
+
t,
|
|
10127
|
+
label: q.required ? q.label : `${q.label} (optional)`,
|
|
10128
|
+
value: (_a2 = answers[q.id]) != null ? _a2 : "",
|
|
10129
|
+
onChange: (v) => setAnswers((prev) => ({ ...prev, [q.id]: v })),
|
|
10130
|
+
maxLength: 300,
|
|
10131
|
+
error: gap ? "Please fill this in" : null
|
|
10132
|
+
},
|
|
10133
|
+
q.id
|
|
10134
|
+
);
|
|
10135
|
+
}
|
|
10033
10136
|
return /* @__PURE__ */ jsxs6("div", { role: "group", "aria-label": q.label, children: [
|
|
10034
10137
|
/* @__PURE__ */ jsxs6("div", { style: { fontSize: 13, fontWeight: 500, overflowWrap: "anywhere" }, children: [
|
|
10035
10138
|
q.label,
|
|
@@ -10118,7 +10221,7 @@ function BookingDialog({
|
|
|
10118
10221
|
onClick: startBooking,
|
|
10119
10222
|
disabled: busy,
|
|
10120
10223
|
"aria-disabled": missing.length > 0,
|
|
10121
|
-
style: { ...primaryStyle(t, busy
|
|
10224
|
+
style: { ...primaryStyle(t, busy), cursor: busy ? "default" : "pointer", whiteSpace: "nowrap" },
|
|
10122
10225
|
children: requireOtp ? busy ? "Sending code\u2026" : "Send verification code" : busy ? "Booking\u2026" : "Book demo"
|
|
10123
10226
|
}
|
|
10124
10227
|
)
|
|
@@ -10170,6 +10273,41 @@ function BookingDialog({
|
|
|
10170
10273
|
email,
|
|
10171
10274
|
", and we'll send a WhatsApp reminder before the call."
|
|
10172
10275
|
] }),
|
|
10276
|
+
calendarEvent && /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexWrap: "wrap", gap: 8 }, children: [
|
|
10277
|
+
/* @__PURE__ */ jsx6(
|
|
10278
|
+
"a",
|
|
10279
|
+
{
|
|
10280
|
+
href: googleCalendarUrl(calendarEvent),
|
|
10281
|
+
target: "_blank",
|
|
10282
|
+
rel: "noreferrer",
|
|
10283
|
+
style: { ...primaryStyle(t, false), textDecoration: "none" },
|
|
10284
|
+
children: "Add to Google Calendar"
|
|
10285
|
+
}
|
|
10286
|
+
),
|
|
10287
|
+
/* @__PURE__ */ jsx6(
|
|
10288
|
+
"button",
|
|
10289
|
+
{
|
|
10290
|
+
type: "button",
|
|
10291
|
+
onClick: () => {
|
|
10292
|
+
const url = icsDownloadUrl(calendarEvent);
|
|
10293
|
+
if (!url) return;
|
|
10294
|
+
const a = document.createElement("a");
|
|
10295
|
+
a.href = url;
|
|
10296
|
+
a.download = "demo.ics";
|
|
10297
|
+
a.click();
|
|
10298
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
10299
|
+
},
|
|
10300
|
+
style: {
|
|
10301
|
+
...primaryStyle(t, false),
|
|
10302
|
+
background: "transparent",
|
|
10303
|
+
color: t.ink,
|
|
10304
|
+
border: `1px solid ${t.border}`,
|
|
10305
|
+
cursor: "pointer"
|
|
10306
|
+
},
|
|
10307
|
+
children: "Download .ics (Outlook, Apple)"
|
|
10308
|
+
}
|
|
10309
|
+
)
|
|
10310
|
+
] }),
|
|
10173
10311
|
meetUrl && /* @__PURE__ */ jsx6(
|
|
10174
10312
|
"a",
|
|
10175
10313
|
{
|
|
@@ -10243,6 +10381,30 @@ function BookingDialog({
|
|
|
10243
10381
|
lineHeight: 1.4
|
|
10244
10382
|
},
|
|
10245
10383
|
children: [
|
|
10384
|
+
toast && /* @__PURE__ */ jsx6(
|
|
10385
|
+
"div",
|
|
10386
|
+
{
|
|
10387
|
+
role: "status",
|
|
10388
|
+
"aria-live": "polite",
|
|
10389
|
+
style: {
|
|
10390
|
+
position: "fixed",
|
|
10391
|
+
left: "50%",
|
|
10392
|
+
bottom: wide ? 88 : 96,
|
|
10393
|
+
transform: "translateX(-50%)",
|
|
10394
|
+
maxWidth: "min(480px, calc(100vw - 32px))",
|
|
10395
|
+
padding: "10px 16px",
|
|
10396
|
+
borderRadius: 10,
|
|
10397
|
+
background: t.ink,
|
|
10398
|
+
color: t.onInk,
|
|
10399
|
+
fontSize: 13,
|
|
10400
|
+
lineHeight: 1.5,
|
|
10401
|
+
fontWeight: 600,
|
|
10402
|
+
boxShadow: "0 8px 24px rgba(0,0,0,.35)",
|
|
10403
|
+
zIndex: 2147483647
|
|
10404
|
+
},
|
|
10405
|
+
children: toast
|
|
10406
|
+
}
|
|
10407
|
+
),
|
|
10246
10408
|
summary,
|
|
10247
10409
|
roomy ? /* @__PURE__ */ jsxs6("div", { style: { flex: "1 1 auto", minWidth: 0, display: "flex", flexDirection: "column" }, children: [
|
|
10248
10410
|
/* @__PURE__ */ jsxs6(
|
|
@@ -10257,7 +10419,7 @@ function BookingDialog({
|
|
|
10257
10419
|
overflowY: wide && !split ? "auto" : void 0
|
|
10258
10420
|
},
|
|
10259
10421
|
children: [
|
|
10260
|
-
|
|
10422
|
+
details2,
|
|
10261
10423
|
/* @__PURE__ */ jsxs6(
|
|
10262
10424
|
"div",
|
|
10263
10425
|
{
|
|
@@ -10391,6 +10553,7 @@ function Field({
|
|
|
10391
10553
|
type = "text",
|
|
10392
10554
|
autoComplete,
|
|
10393
10555
|
inputMode,
|
|
10556
|
+
maxLength,
|
|
10394
10557
|
error
|
|
10395
10558
|
}) {
|
|
10396
10559
|
return /* @__PURE__ */ jsxs6("label", { style: { display: "block", fontSize: 13, fontWeight: 500, color: t.text }, children: [
|
|
@@ -10402,6 +10565,7 @@ function Field({
|
|
|
10402
10565
|
value,
|
|
10403
10566
|
autoComplete,
|
|
10404
10567
|
inputMode,
|
|
10568
|
+
maxLength,
|
|
10405
10569
|
"aria-invalid": Boolean(error),
|
|
10406
10570
|
onChange: (e) => onChange(e.target.value),
|
|
10407
10571
|
style: {
|
|
@@ -10589,11 +10753,11 @@ function describeRejection(reason) {
|
|
|
10589
10753
|
const source = reason;
|
|
10590
10754
|
const nestedError = source.error;
|
|
10591
10755
|
const message = (_h = (_g = (_f = (_e = (_d = (_c = (_b = readString(source.message)) != null ? _b : readString(nestedError)) != null ? _c : readString(nestedError == null ? void 0 : nestedError.message)) != null ? _d : readScalar(source.code)) != null ? _e : readString(source.name)) != null ? _f : readScalar(source.status)) != null ? _g : readString(source.statusText)) != null ? _h : "";
|
|
10592
|
-
const
|
|
10756
|
+
const details2 = serialize(reason);
|
|
10593
10757
|
return {
|
|
10594
10758
|
message: message || (isEventLike(reason) ? describeEvent(reason) : describeShape(reason)),
|
|
10595
10759
|
stack,
|
|
10596
|
-
details
|
|
10760
|
+
details: details2
|
|
10597
10761
|
};
|
|
10598
10762
|
} catch (e) {
|
|
10599
10763
|
return { message: "" };
|
|
@@ -11435,19 +11599,337 @@ function FeedbackButton({
|
|
|
11435
11599
|
);
|
|
11436
11600
|
}
|
|
11437
11601
|
|
|
11602
|
+
// src/call-issue-dialog.tsx
|
|
11603
|
+
import { useCallback as useCallback4, useEffect as useEffect7, useRef as useRef6, useState as useState8 } from "react";
|
|
11604
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
11605
|
+
var DEFAULT_BASE_URL3 = "https://glitchgrab.dev";
|
|
11606
|
+
var ApiError = class extends Error {
|
|
11607
|
+
constructor(message, status, code) {
|
|
11608
|
+
super(message);
|
|
11609
|
+
this.status = status;
|
|
11610
|
+
this.code = code;
|
|
11611
|
+
}
|
|
11612
|
+
};
|
|
11613
|
+
function formatDuration2(sec) {
|
|
11614
|
+
if (!sec || sec < 1) return "";
|
|
11615
|
+
return `${Math.floor(sec / 60)}:${String(Math.round(sec % 60)).padStart(2, "0")}`;
|
|
11616
|
+
}
|
|
11617
|
+
function readDraft(value) {
|
|
11618
|
+
if (!value || typeof value !== "object") return null;
|
|
11619
|
+
const v = value;
|
|
11620
|
+
if (typeof v.id !== "string" || typeof v.title !== "string") return null;
|
|
11621
|
+
return {
|
|
11622
|
+
id: v.id,
|
|
11623
|
+
title: v.title,
|
|
11624
|
+
body: typeof v.body === "string" ? v.body : "",
|
|
11625
|
+
labels: Array.isArray(v.labels) ? v.labels.filter((l) => typeof l === "string") : [],
|
|
11626
|
+
quotes: Array.isArray(v.quotes) ? v.quotes.filter((q) => !!q && typeof q.text === "string").slice(0, 3) : [],
|
|
11627
|
+
status: typeof v.status === "string" ? v.status : "DRAFT",
|
|
11628
|
+
githubNumber: typeof v.githubNumber === "number" ? v.githubNumber : null,
|
|
11629
|
+
githubUrl: typeof v.githubUrl === "string" ? v.githubUrl : null
|
|
11630
|
+
};
|
|
11631
|
+
}
|
|
11632
|
+
function GlitchgrabCallIssue({ callId, open, onClose, getToken, baseUrl, onFiled }) {
|
|
11633
|
+
var _a, _b;
|
|
11634
|
+
const base = (baseUrl || DEFAULT_BASE_URL3).replace(/\/+$/, "");
|
|
11635
|
+
const tokenRef = useRef6(null);
|
|
11636
|
+
const [loaded, setLoaded] = useState8(null);
|
|
11637
|
+
const [busy, setBusy] = useState8(null);
|
|
11638
|
+
const [error, setError] = useState8(null);
|
|
11639
|
+
const [picked, setPicked] = useState8(/* @__PURE__ */ new Set());
|
|
11640
|
+
const [filed, setFiled] = useState8([]);
|
|
11641
|
+
const [fixing, setFixing] = useState8(null);
|
|
11642
|
+
const [fixText, setFixText] = useState8("");
|
|
11643
|
+
const [fixBusy, setFixBusy] = useState8(false);
|
|
11644
|
+
const dark = typeof window !== "undefined" ? detectDark() : false;
|
|
11645
|
+
const accent = (_a = typeof window !== "undefined" ? detectHostAccent() : null) != null ? _a : { accent: "#3b82f6", accentText: "#fff" };
|
|
11646
|
+
const c = dark ? { bg: "#18181b", pane: "#222226", border: "#3f3f46", text: "#fafafa", muted: "#a1a1aa" } : { bg: "#ffffff", pane: "#f6f6f7", border: "#e4e4e7", text: "#18181b", muted: "#71717a" };
|
|
11647
|
+
const call = useCallback4(
|
|
11648
|
+
async (path, init = {}) => {
|
|
11649
|
+
var _a2, _b2, _c;
|
|
11650
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
11651
|
+
if (!tokenRef.current) tokenRef.current = await getToken(callId);
|
|
11652
|
+
const res = await fetch(`${base}/api/v1/sdk/call-issue/${encodeURIComponent(callId)}${path}`, {
|
|
11653
|
+
method: (_a2 = init.method) != null ? _a2 : "GET",
|
|
11654
|
+
headers: {
|
|
11655
|
+
Authorization: `Bearer ${tokenRef.current}`,
|
|
11656
|
+
...init.body === void 0 ? {} : { "Content-Type": "application/json" }
|
|
11657
|
+
},
|
|
11658
|
+
...init.body === void 0 ? {} : { body: JSON.stringify(init.body) }
|
|
11659
|
+
});
|
|
11660
|
+
const json = await res.json().catch(() => null);
|
|
11661
|
+
if (res.ok && (json == null ? void 0 : json.success)) return json.data;
|
|
11662
|
+
if (res.status === 401 && attempt === 0) {
|
|
11663
|
+
tokenRef.current = null;
|
|
11664
|
+
continue;
|
|
11665
|
+
}
|
|
11666
|
+
throw new ApiError((_b2 = json == null ? void 0 : json.error) != null ? _b2 : `HTTP ${res.status}`, res.status, (_c = json == null ? void 0 : json.code) != null ? _c : null);
|
|
11667
|
+
}
|
|
11668
|
+
throw new ApiError("Could not reach Glitchgrab", 0, null);
|
|
11669
|
+
},
|
|
11670
|
+
[base, callId, getToken]
|
|
11671
|
+
);
|
|
11672
|
+
const apply = useCallback4((data) => {
|
|
11673
|
+
const d = data != null ? data : {};
|
|
11674
|
+
const drafts = (Array.isArray(d.drafts) ? d.drafts : []).map(readDraft).filter((x) => x !== null);
|
|
11675
|
+
const callRaw = d.call;
|
|
11676
|
+
setLoaded((prev) => {
|
|
11677
|
+
var _a2, _b2;
|
|
11678
|
+
return {
|
|
11679
|
+
drafts,
|
|
11680
|
+
canExtract: d.canExtract !== false,
|
|
11681
|
+
extractedAt: typeof d.extractedAt === "string" ? d.extractedAt : (_a2 = prev == null ? void 0 : prev.extractedAt) != null ? _a2 : null,
|
|
11682
|
+
call: callRaw && typeof callRaw.pageUrl === "string" ? {
|
|
11683
|
+
title: typeof callRaw.title === "string" ? callRaw.title : null,
|
|
11684
|
+
at: typeof callRaw.at === "string" ? callRaw.at : "",
|
|
11685
|
+
durationSec: typeof callRaw.durationSec === "number" ? callRaw.durationSec : null,
|
|
11686
|
+
pageUrl: callRaw.pageUrl
|
|
11687
|
+
} : (_b2 = prev == null ? void 0 : prev.call) != null ? _b2 : null
|
|
11688
|
+
};
|
|
11689
|
+
});
|
|
11690
|
+
setPicked(new Set(drafts.filter((x) => x.status === "DRAFT").map((x) => x.id)));
|
|
11691
|
+
}, []);
|
|
11692
|
+
const read = useCallback4(async () => {
|
|
11693
|
+
setBusy("read");
|
|
11694
|
+
setError(null);
|
|
11695
|
+
try {
|
|
11696
|
+
const data = await call("/drafts", { method: "POST" });
|
|
11697
|
+
apply({ ...data, canExtract: true, extractedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
11698
|
+
} catch (e) {
|
|
11699
|
+
setError(e instanceof Error ? e.message : "Could not read this call.");
|
|
11700
|
+
} finally {
|
|
11701
|
+
setBusy(null);
|
|
11702
|
+
}
|
|
11703
|
+
}, [apply, call]);
|
|
11704
|
+
useEffect7(() => {
|
|
11705
|
+
if (!open) return;
|
|
11706
|
+
let cancelled = false;
|
|
11707
|
+
setLoaded(null);
|
|
11708
|
+
setFiled([]);
|
|
11709
|
+
setError(null);
|
|
11710
|
+
setBusy("load");
|
|
11711
|
+
(async () => {
|
|
11712
|
+
try {
|
|
11713
|
+
const data = await call("/drafts");
|
|
11714
|
+
if (cancelled) return;
|
|
11715
|
+
apply(data);
|
|
11716
|
+
const hasDrafts = Array.isArray(data.drafts) && data.drafts.length > 0;
|
|
11717
|
+
if (!hasDrafts && data.canExtract !== false && !data.extractedAt) {
|
|
11718
|
+
setBusy(null);
|
|
11719
|
+
await read();
|
|
11720
|
+
}
|
|
11721
|
+
} catch (e) {
|
|
11722
|
+
if (!cancelled) setError(e instanceof Error ? e.message : "Could not open this call.");
|
|
11723
|
+
} finally {
|
|
11724
|
+
if (!cancelled) setBusy((b) => b === "load" ? null : b);
|
|
11725
|
+
}
|
|
11726
|
+
})();
|
|
11727
|
+
return () => {
|
|
11728
|
+
cancelled = true;
|
|
11729
|
+
};
|
|
11730
|
+
}, [open, callId]);
|
|
11731
|
+
useEffect7(() => {
|
|
11732
|
+
if (!open) return;
|
|
11733
|
+
const onKey = (e) => e.key === "Escape" && onClose();
|
|
11734
|
+
window.addEventListener("keydown", onKey);
|
|
11735
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
11736
|
+
}, [open, onClose]);
|
|
11737
|
+
if (!open) return null;
|
|
11738
|
+
const active = ((_b = loaded == null ? void 0 : loaded.drafts) != null ? _b : []).filter((d) => d.status === "DRAFT");
|
|
11739
|
+
const chosen = active.filter((d) => picked.has(d.id));
|
|
11740
|
+
const discard = async (id) => {
|
|
11741
|
+
try {
|
|
11742
|
+
await call(`/drafts/${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
11743
|
+
setLoaded((l) => l ? { ...l, drafts: l.drafts.filter((d) => d.id !== id) } : l);
|
|
11744
|
+
setPicked((p) => {
|
|
11745
|
+
const next = new Set(p);
|
|
11746
|
+
next.delete(id);
|
|
11747
|
+
return next;
|
|
11748
|
+
});
|
|
11749
|
+
} catch (e) {
|
|
11750
|
+
setError(e instanceof Error ? e.message : "Could not remove it.");
|
|
11751
|
+
}
|
|
11752
|
+
};
|
|
11753
|
+
const correct = async (id) => {
|
|
11754
|
+
if (!fixText.trim()) return;
|
|
11755
|
+
setFixBusy(true);
|
|
11756
|
+
setError(null);
|
|
11757
|
+
try {
|
|
11758
|
+
const data = await call(`/drafts/${encodeURIComponent(id)}/chat`, {
|
|
11759
|
+
method: "POST",
|
|
11760
|
+
body: { message: fixText }
|
|
11761
|
+
});
|
|
11762
|
+
const next = readDraft(data.draft);
|
|
11763
|
+
if (next) setLoaded((l) => l ? { ...l, drafts: l.drafts.map((d) => d.id === id ? { ...d, ...next } : d) } : l);
|
|
11764
|
+
setFixing(null);
|
|
11765
|
+
setFixText("");
|
|
11766
|
+
} catch (e) {
|
|
11767
|
+
setError(e instanceof Error ? e.message : "Could not rewrite it.");
|
|
11768
|
+
} finally {
|
|
11769
|
+
setFixBusy(false);
|
|
11770
|
+
}
|
|
11771
|
+
};
|
|
11772
|
+
const file = async () => {
|
|
11773
|
+
var _a2, _b2, _c, _d, _e;
|
|
11774
|
+
setBusy("file");
|
|
11775
|
+
setError(null);
|
|
11776
|
+
try {
|
|
11777
|
+
const data = await call("/create", { method: "POST", body: { draftIds: chosen.map((d) => d.id) } });
|
|
11778
|
+
const done = [...(_a2 = data.created) != null ? _a2 : [], ...(_b2 = data.already) != null ? _b2 : []];
|
|
11779
|
+
setFiled(done);
|
|
11780
|
+
if (((_c = data.created) != null ? _c : []).length > 0) onFiled == null ? void 0 : onFiled((_d = data.created) != null ? _d : []);
|
|
11781
|
+
if ((_e = data.failed) == null ? void 0 : _e.length) setError(`${data.failed.length} could not be filed: ${data.failed[0].error}`);
|
|
11782
|
+
const doneIds = new Set(done.map((d) => d.id));
|
|
11783
|
+
setLoaded((l) => l ? { ...l, drafts: l.drafts.filter((d) => !doneIds.has(d.id)) } : l);
|
|
11784
|
+
} catch (e) {
|
|
11785
|
+
setError(e instanceof Error ? e.message : "Could not file the issues.");
|
|
11786
|
+
} finally {
|
|
11787
|
+
setBusy(null);
|
|
11788
|
+
}
|
|
11789
|
+
};
|
|
11790
|
+
const button = (primary, disabled) => ({
|
|
11791
|
+
padding: "8px 14px",
|
|
11792
|
+
borderRadius: 8,
|
|
11793
|
+
border: primary ? 0 : `1px solid ${c.border}`,
|
|
11794
|
+
background: primary ? accent.accent : "transparent",
|
|
11795
|
+
color: primary ? accent.accentText : c.text,
|
|
11796
|
+
fontSize: 13,
|
|
11797
|
+
fontWeight: 500,
|
|
11798
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
11799
|
+
opacity: disabled ? 0.55 : 1
|
|
11800
|
+
});
|
|
11801
|
+
return /* @__PURE__ */ jsx11(
|
|
11802
|
+
"div",
|
|
11803
|
+
{
|
|
11804
|
+
role: "dialog",
|
|
11805
|
+
"aria-modal": "true",
|
|
11806
|
+
"aria-label": "Create issues from this call",
|
|
11807
|
+
onClick: (e) => e.target === e.currentTarget && onClose(),
|
|
11808
|
+
style: { position: "fixed", inset: 0, zIndex: 2147483e3, background: "rgba(0,0,0,0.45)", display: "flex", justifyContent: "flex-end" },
|
|
11809
|
+
children: /* @__PURE__ */ jsxs10(
|
|
11810
|
+
"div",
|
|
11811
|
+
{
|
|
11812
|
+
style: {
|
|
11813
|
+
width: "min(560px, 100vw)",
|
|
11814
|
+
height: "100%",
|
|
11815
|
+
background: c.bg,
|
|
11816
|
+
color: c.text,
|
|
11817
|
+
borderLeft: `1px solid ${c.border}`,
|
|
11818
|
+
display: "flex",
|
|
11819
|
+
flexDirection: "column",
|
|
11820
|
+
fontFamily: "inherit",
|
|
11821
|
+
boxSizing: "border-box"
|
|
11822
|
+
},
|
|
11823
|
+
children: [
|
|
11824
|
+
/* @__PURE__ */ jsxs10("div", { style: { padding: "16px 18px", borderBottom: `1px solid ${c.border}`, display: "flex", gap: 12, alignItems: "flex-start" }, children: [
|
|
11825
|
+
/* @__PURE__ */ jsxs10("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
11826
|
+
/* @__PURE__ */ jsx11("div", { style: { fontSize: 15, fontWeight: 600 }, children: "Create issues from this call" }),
|
|
11827
|
+
(loaded == null ? void 0 : loaded.call) && /* @__PURE__ */ jsxs10("div", { style: { fontSize: 12, color: c.muted, marginTop: 4, overflowWrap: "anywhere" }, children: [
|
|
11828
|
+
loaded.call.title ? `${loaded.call.title} \xB7 ` : "",
|
|
11829
|
+
loaded.call.at ? new Date(loaded.call.at).toLocaleString() : "",
|
|
11830
|
+
formatDuration2(loaded.call.durationSec) ? ` \xB7 ${formatDuration2(loaded.call.durationSec)}` : "",
|
|
11831
|
+
" \xB7 ",
|
|
11832
|
+
/* @__PURE__ */ jsx11("a", { href: loaded.call.pageUrl, target: "_blank", rel: "noreferrer", style: { color: accent.accent }, children: "Open in Glitchgrab \u2197" })
|
|
11833
|
+
] })
|
|
11834
|
+
] }),
|
|
11835
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: onClose, "aria-label": "Close", style: { ...button(false, false), padding: "4px 10px" }, children: "\u2715" })
|
|
11836
|
+
] }),
|
|
11837
|
+
/* @__PURE__ */ jsxs10("div", { style: { flex: 1, overflowY: "auto", padding: 18, display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
11838
|
+
error && /* @__PURE__ */ jsx11("div", { role: "alert", style: { padding: "10px 12px", borderRadius: 8, border: "1px solid #ef4444", color: "#ef4444", fontSize: 13 }, children: error }),
|
|
11839
|
+
(busy === "load" || busy === "read") && /* @__PURE__ */ jsx11("div", { style: { color: c.muted, fontSize: 13 }, children: busy === "read" ? "Reading the call\u2026 this takes about 20\u201340 seconds." : "Opening the call\u2026" }),
|
|
11840
|
+
filed.length > 0 && /* @__PURE__ */ jsxs10("div", { style: { padding: 12, borderRadius: 8, background: c.pane, fontSize: 13 }, children: [
|
|
11841
|
+
/* @__PURE__ */ jsxs10("div", { style: { fontWeight: 600, marginBottom: 6 }, children: [
|
|
11842
|
+
"\u2713 Filed ",
|
|
11843
|
+
filed.length === 1 ? "1 issue" : `${filed.length} issues`
|
|
11844
|
+
] }),
|
|
11845
|
+
filed.map((f) => /* @__PURE__ */ jsx11("div", { style: { overflowWrap: "anywhere" }, children: /* @__PURE__ */ jsxs10("a", { href: f.url, target: "_blank", rel: "noreferrer", style: { color: accent.accent }, children: [
|
|
11846
|
+
"#",
|
|
11847
|
+
f.number,
|
|
11848
|
+
" ",
|
|
11849
|
+
f.title,
|
|
11850
|
+
" \u2197"
|
|
11851
|
+
] }) }, f.id)),
|
|
11852
|
+
/* @__PURE__ */ jsx11("div", { style: { color: c.muted, marginTop: 6 }, children: "Each carries the call id, a link to the call and the lines it came from." })
|
|
11853
|
+
] }),
|
|
11854
|
+
!busy && loaded && !loaded.canExtract && /* @__PURE__ */ jsx11("div", { style: { color: c.muted, fontSize: 13 }, children: "This call has no transcript yet. It is ready a few minutes after the call ends." }),
|
|
11855
|
+
!busy && loaded && loaded.canExtract && active.length === 0 && filed.length === 0 && !error && /* @__PURE__ */ jsx11("div", { style: { color: c.muted, fontSize: 13 }, children: "Nothing in this call needs an issue." }),
|
|
11856
|
+
active.map((d, i) => /* @__PURE__ */ jsx11("div", { style: { border: `1px solid ${c.border}`, borderRadius: 10, padding: 12, background: c.pane }, children: /* @__PURE__ */ jsxs10("div", { style: { display: "flex", gap: 10, alignItems: "flex-start" }, children: [
|
|
11857
|
+
/* @__PURE__ */ jsx11(
|
|
11858
|
+
"input",
|
|
11859
|
+
{
|
|
11860
|
+
type: "checkbox",
|
|
11861
|
+
"aria-label": `Select ${d.title}`,
|
|
11862
|
+
checked: picked.has(d.id),
|
|
11863
|
+
onChange: () => setPicked((p) => {
|
|
11864
|
+
const next = new Set(p);
|
|
11865
|
+
if (next.has(d.id)) next.delete(d.id);
|
|
11866
|
+
else next.add(d.id);
|
|
11867
|
+
return next;
|
|
11868
|
+
}),
|
|
11869
|
+
style: { marginTop: 3 }
|
|
11870
|
+
}
|
|
11871
|
+
),
|
|
11872
|
+
/* @__PURE__ */ jsxs10("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
11873
|
+
/* @__PURE__ */ jsxs10("div", { style: { fontSize: 14, fontWeight: 600, overflowWrap: "anywhere" }, children: [
|
|
11874
|
+
i + 1,
|
|
11875
|
+
". ",
|
|
11876
|
+
d.title
|
|
11877
|
+
] }),
|
|
11878
|
+
d.labels.length > 0 && /* @__PURE__ */ jsx11("div", { style: { fontSize: 11, color: c.muted, marginTop: 2 }, children: d.labels.join(" \xB7 ") }),
|
|
11879
|
+
d.quotes.map((q, qi) => /* @__PURE__ */ jsxs10("div", { style: { fontSize: 12, color: c.muted, marginTop: 6, borderLeft: `2px solid ${c.border}`, paddingLeft: 8, overflowWrap: "anywhere" }, children: [
|
|
11880
|
+
q.speaker ? /* @__PURE__ */ jsxs10("b", { children: [
|
|
11881
|
+
q.speaker,
|
|
11882
|
+
": "
|
|
11883
|
+
] }) : null,
|
|
11884
|
+
q.text
|
|
11885
|
+
] }, qi)),
|
|
11886
|
+
fixing === d.id ? /* @__PURE__ */ jsxs10("div", { style: { display: "flex", gap: 6, marginTop: 8 }, children: [
|
|
11887
|
+
/* @__PURE__ */ jsx11(
|
|
11888
|
+
"input",
|
|
11889
|
+
{
|
|
11890
|
+
value: fixText,
|
|
11891
|
+
onChange: (e) => setFixText(e.target.value),
|
|
11892
|
+
onKeyDown: (e) => e.key === "Enter" && !fixBusy && void correct(d.id),
|
|
11893
|
+
placeholder: "attendance here means WhatsApp check-in, not a biometric device",
|
|
11894
|
+
"aria-label": "What should change in this draft",
|
|
11895
|
+
style: { flex: 1, padding: "7px 9px", borderRadius: 8, border: `1px solid ${c.border}`, background: c.bg, color: c.text, fontSize: 12 }
|
|
11896
|
+
}
|
|
11897
|
+
),
|
|
11898
|
+
/* @__PURE__ */ jsx11("button", { type: "button", disabled: fixBusy || !fixText.trim(), onClick: () => void correct(d.id), style: button(true, fixBusy || !fixText.trim()), children: fixBusy ? "Rewriting\u2026" : "Send" })
|
|
11899
|
+
] }) : /* @__PURE__ */ jsxs10("div", { style: { display: "flex", gap: 12, marginTop: 8, fontSize: 12 }, children: [
|
|
11900
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => {
|
|
11901
|
+
setFixing(d.id);
|
|
11902
|
+
setFixText("");
|
|
11903
|
+
}, style: { background: "none", border: 0, padding: 0, color: accent.accent, cursor: "pointer" }, children: "Not what we meant" }),
|
|
11904
|
+
/* @__PURE__ */ jsx11("button", { type: "button", onClick: () => void discard(d.id), style: { background: "none", border: 0, padding: 0, color: c.muted, cursor: "pointer" }, children: "Remove" })
|
|
11905
|
+
] })
|
|
11906
|
+
] })
|
|
11907
|
+
] }) }, d.id))
|
|
11908
|
+
] }),
|
|
11909
|
+
/* @__PURE__ */ jsxs10("div", { style: { padding: "12px 18px", borderTop: `1px solid ${c.border}`, display: "flex", gap: 10, justifyContent: "space-between", alignItems: "center" }, children: [
|
|
11910
|
+
/* @__PURE__ */ jsx11("button", { type: "button", disabled: busy !== null || !(loaded == null ? void 0 : loaded.canExtract), onClick: () => void read(), style: button(false, busy !== null || !(loaded == null ? void 0 : loaded.canExtract)), children: "Read the call again" }),
|
|
11911
|
+
/* @__PURE__ */ jsx11("button", { type: "button", disabled: busy !== null || chosen.length === 0, onClick: () => void file(), style: button(true, busy !== null || chosen.length === 0), children: busy === "file" ? "Creating\u2026" : chosen.length === 1 ? "Create 1 issue" : `Create ${chosen.length} issues` })
|
|
11912
|
+
] })
|
|
11913
|
+
]
|
|
11914
|
+
}
|
|
11915
|
+
)
|
|
11916
|
+
}
|
|
11917
|
+
);
|
|
11918
|
+
}
|
|
11919
|
+
|
|
11438
11920
|
// src/use-reports.ts
|
|
11439
|
-
import { useState as
|
|
11921
|
+
import { useState as useState9, useEffect as useEffect8, useCallback as useCallback5 } from "react";
|
|
11440
11922
|
var BASE_URL = "https://glitchgrab.dev";
|
|
11441
11923
|
function useGlitchgrabReports({
|
|
11442
11924
|
token,
|
|
11443
11925
|
userId,
|
|
11444
11926
|
limit = 100
|
|
11445
11927
|
}) {
|
|
11446
|
-
const [reports, setReports] =
|
|
11447
|
-
const [isLoading, setIsLoading] =
|
|
11448
|
-
const [isFetching, setIsFetching] =
|
|
11449
|
-
const [error, setError] =
|
|
11450
|
-
const fetchReports =
|
|
11928
|
+
const [reports, setReports] = useState9([]);
|
|
11929
|
+
const [isLoading, setIsLoading] = useState9(true);
|
|
11930
|
+
const [isFetching, setIsFetching] = useState9(false);
|
|
11931
|
+
const [error, setError] = useState9(null);
|
|
11932
|
+
const fetchReports = useCallback5(async () => {
|
|
11451
11933
|
var _a, _b;
|
|
11452
11934
|
if (!token || !userId) {
|
|
11453
11935
|
setIsLoading(false);
|
|
@@ -11473,7 +11955,7 @@ function useGlitchgrabReports({
|
|
|
11473
11955
|
setIsFetching(false);
|
|
11474
11956
|
}
|
|
11475
11957
|
}, [token, userId, limit]);
|
|
11476
|
-
|
|
11958
|
+
useEffect8(() => {
|
|
11477
11959
|
fetchReports();
|
|
11478
11960
|
}, [fetchReports]);
|
|
11479
11961
|
return { reports, isLoading, isFetching, error, refetch: fetchReports };
|
|
@@ -11510,9 +11992,9 @@ function useGlitchgrabActions({
|
|
|
11510
11992
|
onSuccess,
|
|
11511
11993
|
onError
|
|
11512
11994
|
}) {
|
|
11513
|
-
const [isPending, setIsPending] =
|
|
11514
|
-
const [error, setError] =
|
|
11515
|
-
const run =
|
|
11995
|
+
const [isPending, setIsPending] = useState9(false);
|
|
11996
|
+
const [error, setError] = useState9(null);
|
|
11997
|
+
const run = useCallback5(
|
|
11516
11998
|
async (reportId, body) => {
|
|
11517
11999
|
setIsPending(true);
|
|
11518
12000
|
setError(null);
|
|
@@ -11576,12 +12058,12 @@ function useGlitchgrabReportThread({
|
|
|
11576
12058
|
reporterEmail
|
|
11577
12059
|
}) {
|
|
11578
12060
|
var _a;
|
|
11579
|
-
const [report, setReport] =
|
|
11580
|
-
const [isLoading, setIsLoading] =
|
|
11581
|
-
const [isFetching, setIsFetching] =
|
|
11582
|
-
const [isPosting, setIsPosting] =
|
|
11583
|
-
const [error, setError] =
|
|
11584
|
-
const refetch =
|
|
12061
|
+
const [report, setReport] = useState9(null);
|
|
12062
|
+
const [isLoading, setIsLoading] = useState9(!!reportId);
|
|
12063
|
+
const [isFetching, setIsFetching] = useState9(false);
|
|
12064
|
+
const [isPosting, setIsPosting] = useState9(false);
|
|
12065
|
+
const [error, setError] = useState9(null);
|
|
12066
|
+
const refetch = useCallback5(async () => {
|
|
11585
12067
|
if (!token || !reportId) {
|
|
11586
12068
|
setReport(null);
|
|
11587
12069
|
setIsLoading(false);
|
|
@@ -11598,10 +12080,10 @@ function useGlitchgrabReportThread({
|
|
|
11598
12080
|
setIsFetching(false);
|
|
11599
12081
|
}
|
|
11600
12082
|
}, [token, reportId]);
|
|
11601
|
-
|
|
12083
|
+
useEffect8(() => {
|
|
11602
12084
|
refetch();
|
|
11603
12085
|
}, [refetch]);
|
|
11604
|
-
const addComment =
|
|
12086
|
+
const addComment = useCallback5(
|
|
11605
12087
|
async (message) => {
|
|
11606
12088
|
if (!token || !reportId || !message.trim()) return false;
|
|
11607
12089
|
setIsPosting(true);
|
|
@@ -11623,8 +12105,8 @@ function useGlitchgrabReportThread({
|
|
|
11623
12105
|
}
|
|
11624
12106
|
|
|
11625
12107
|
// src/use-feedback.ts
|
|
11626
|
-
import { useState as
|
|
11627
|
-
var
|
|
12108
|
+
import { useState as useState10, useEffect as useEffect9, useCallback as useCallback6 } from "react";
|
|
12109
|
+
var DEFAULT_BASE_URL4 = "https://glitchgrab.dev";
|
|
11628
12110
|
function buildUrl({
|
|
11629
12111
|
approvedOnly,
|
|
11630
12112
|
userId,
|
|
@@ -11636,7 +12118,7 @@ function buildUrl({
|
|
|
11636
12118
|
if (approvedOnly) params.set("approved", "true");
|
|
11637
12119
|
if (userId) params.set("reporterPrimaryKey", userId);
|
|
11638
12120
|
if (minRating) params.set("minRating", String(minRating));
|
|
11639
|
-
return `${baseUrl != null ? baseUrl :
|
|
12121
|
+
return `${baseUrl != null ? baseUrl : DEFAULT_BASE_URL4}/api/v1/sdk/feedback?${params.toString()}`;
|
|
11640
12122
|
}
|
|
11641
12123
|
async function fetchGlitchgrabFeedback(query) {
|
|
11642
12124
|
var _a, _b;
|
|
@@ -11649,11 +12131,11 @@ async function fetchGlitchgrabFeedback(query) {
|
|
|
11649
12131
|
}
|
|
11650
12132
|
function useGlitchgrabFeedback(query) {
|
|
11651
12133
|
const { token, approvedOnly, userId, minRating, limit, baseUrl } = query;
|
|
11652
|
-
const [feedback, setFeedback] =
|
|
11653
|
-
const [isLoading, setIsLoading] =
|
|
11654
|
-
const [isFetching, setIsFetching] =
|
|
11655
|
-
const [error, setError] =
|
|
11656
|
-
const load =
|
|
12134
|
+
const [feedback, setFeedback] = useState10([]);
|
|
12135
|
+
const [isLoading, setIsLoading] = useState10(true);
|
|
12136
|
+
const [isFetching, setIsFetching] = useState10(false);
|
|
12137
|
+
const [error, setError] = useState10(null);
|
|
12138
|
+
const load = useCallback6(async () => {
|
|
11657
12139
|
if (!token) {
|
|
11658
12140
|
setIsLoading(false);
|
|
11659
12141
|
return;
|
|
@@ -11677,7 +12159,7 @@ function useGlitchgrabFeedback(query) {
|
|
|
11677
12159
|
setIsFetching(false);
|
|
11678
12160
|
}
|
|
11679
12161
|
}, [token, approvedOnly, userId, minRating, limit, baseUrl]);
|
|
11680
|
-
|
|
12162
|
+
useEffect9(() => {
|
|
11681
12163
|
load();
|
|
11682
12164
|
}, [load]);
|
|
11683
12165
|
return { feedback, isLoading, isFetching, error, refetch: load };
|
|
@@ -11688,6 +12170,7 @@ export {
|
|
|
11688
12170
|
FeedbackButton,
|
|
11689
12171
|
GLITCHGRAB_SHORTCUT2 as GLITCHGRAB_SHORTCUT,
|
|
11690
12172
|
GLITCHGRAB_SHORTCUT_MAC2 as GLITCHGRAB_SHORTCUT_MAC,
|
|
12173
|
+
GlitchgrabCallIssue,
|
|
11691
12174
|
GlitchgrabErrorBoundary,
|
|
11692
12175
|
GlitchgrabProvider,
|
|
11693
12176
|
ReportButton,
|