freshyo/apps/web-ui/.output/server/_ssr/me.complaints-CUIcnKsp.mjs
2026-05-10 19:44:26 +05:30

100 lines
4.4 KiB
JavaScript

import { o as __toESM } from "../_runtime.mjs";
import { h as require_react, m as require_jsx_runtime } from "../_libs/react+tanstack__react-query.mjs";
import { f as Plus, h as MessageSquare } from "../_libs/lucide-react.mjs";
import { a as p, i as MyButton, s as MyTouchableOpacity, t as AppContainer } from "./src-u_N1opJl.mjs";
import { n as trpc } from "./trpc-client-CQOIB5UU.mjs";
//#region node_modules/.nitro/vite/services/ssr/assets/me.complaints-CUIcnKsp.js
var import_react = /* @__PURE__ */ __toESM(require_react());
var import_jsx_runtime = require_jsx_runtime();
function ComplaintsPage() {
const { data } = trpc.user.complaint.getAll.useQuery();
const raiseMutation = trpc.user.complaint.raise.useMutation();
const utils = trpc.useUtils();
const [showForm, setShowForm] = (0, import_react.useState)(false);
const [body, setBody] = (0, import_react.useState)("");
const complaints = data?.data || [];
const handleSubmit = () => {
if (!body.trim()) return;
raiseMutation.mutate({ body: body.trim() }, { onSuccess: () => {
setBody("");
setShowForm(false);
utils.user.complaint.getAll.invalidate();
} });
};
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AppContainer, { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
className: "mb-4 flex items-center justify-between",
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
weight: "bold",
className: "text-xl",
children: "Help & Complaints"
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(MyTouchableOpacity, {
onClick: () => setShowForm(!showForm),
className: "flex items-center gap-1 text-brand-600",
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Plus, { className: "h-4 w-4" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
className: "text-sm",
children: "New"
})]
})]
}),
showForm && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
className: "mb-6 rounded-xl border border-gray-100 bg-white p-4 shadow-sm",
children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
weight: "semibold",
className: "mb-3",
children: "Raise a Complaint"
}),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
className: "mb-3 min-h-24 w-full rounded-lg border border-gray-200 p-3 text-sm",
value: body,
onChange: (e) => setBody(e.target.value),
placeholder: "Describe your issue...",
rows: 4
}),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyButton, {
onClick: handleSubmit,
disabled: raiseMutation.isPending || !body.trim(),
textContent: raiseMutation.isPending ? "Submitting..." : "Submit"
})
]
}),
complaints.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
className: "flex flex-col items-center gap-4 py-20",
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageSquare, { className: "h-12 w-12 text-gray-300" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
className: "text-gray-500",
children: "No complaints yet"
})]
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
className: "flex flex-col gap-3",
children: complaints.map((complaint) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
className: "rounded-xl border border-gray-100 bg-white p-4 shadow-sm",
children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
className: "mb-2 flex items-center justify-between",
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
className: `rounded-full px-2 py-0.5 text-xs font-medium ${complaint.status === "resolved" ? "bg-green-100 text-green-700" : "bg-yellow-100 text-yellow-700"}`,
children: complaint.status || "pending"
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
className: "text-xs text-gray-400",
children: complaint.createdAt ? new Date(complaint.createdAt).toLocaleDateString() : ""
})]
}),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
className: "text-sm text-gray-700",
children: complaint.body
}),
complaint.adminResponse && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
className: "mt-2 rounded-lg bg-blue-50 p-2",
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(p, {
className: "text-xs text-blue-600",
children: ["Response: ", complaint.adminResponse]
})
})
]
}, complaint.id))
})
] });
}
//#endregion
export { ComplaintsPage as component };