Add implementation
This commit is contained in:
82
dist/server/ssr/assets/index-CNRWZdhS.js
vendored
Normal file
82
dist/server/ssr/assets/index-CNRWZdhS.js
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { r as reactExports, j as jsxRuntimeExports } from "../index.js";
|
||||
import { u as useRepo } from "./index-BSpyO9eA.js";
|
||||
import { c as createPoll } from "./poll-R5-eIJ_b.js";
|
||||
import "../__vite_rsc_assets_manifest.js";
|
||||
import "node:async_hooks";
|
||||
function HomeClient() {
|
||||
const [title, setTitle] = reactExports.useState("");
|
||||
const [joinId, setJoinId] = reactExports.useState("");
|
||||
const repo = useRepo();
|
||||
const handleCreate = () => {
|
||||
if (!title.trim()) return;
|
||||
const handle = repo.create();
|
||||
handle.change((doc) => {
|
||||
const poll = createPoll(title.trim());
|
||||
doc.title = poll.title;
|
||||
doc.options = poll.options;
|
||||
});
|
||||
window.location.href = `/poll/${handle.documentId}`;
|
||||
};
|
||||
const handleJoin = () => {
|
||||
const id = joinId.trim();
|
||||
if (!id) return;
|
||||
window.location.href = `/poll/${id}`;
|
||||
};
|
||||
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-8", children: [
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx("title", { children: "P2P Poll" }),
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "rounded-lg border border-gray-200 bg-white p-6 shadow-sm", children: [
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "mb-4 text-lg font-semibold", children: "Create a New Poll" }),
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
||||
"input",
|
||||
{
|
||||
type: "text",
|
||||
value: title,
|
||||
onChange: (e) => setTitle(e.target.value),
|
||||
onKeyDown: (e) => e.key === "Enter" && handleCreate(),
|
||||
placeholder: "Enter poll title...",
|
||||
className: "flex-1 rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
||||
"button",
|
||||
{
|
||||
onClick: handleCreate,
|
||||
className: "rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",
|
||||
children: "Create"
|
||||
}
|
||||
)
|
||||
] })
|
||||
] }),
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "rounded-lg border border-gray-200 bg-white p-6 shadow-sm", children: [
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "mb-4 text-lg font-semibold", children: "Join an Existing Poll" }),
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
||||
"input",
|
||||
{
|
||||
type: "text",
|
||||
value: joinId,
|
||||
onChange: (e) => setJoinId(e.target.value),
|
||||
onKeyDown: (e) => e.key === "Enter" && handleJoin(),
|
||||
placeholder: "Paste poll ID or link...",
|
||||
className: "flex-1 rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
||||
"button",
|
||||
{
|
||||
onClick: handleJoin,
|
||||
className: "rounded-md bg-gray-600 px-4 py-2 text-sm font-medium text-white hover:bg-gray-700",
|
||||
children: "Join"
|
||||
}
|
||||
)
|
||||
] })
|
||||
] })
|
||||
] });
|
||||
}
|
||||
const export_5ce7e027532e = {
|
||||
default: HomeClient
|
||||
};
|
||||
export {
|
||||
export_5ce7e027532e
|
||||
};
|
||||
Reference in New Issue
Block a user