{
+ navigator.clipboard.writeText(props.text);
+ setCopied(true);
+ }}
+ >
+
{props.text}
+
+ {copied === true ? (
+
+ ) : (
+
+ )}
+
+
+ );
+}
+
+export { CopyToClipboard };
diff --git a/src/pages/pubNote.jsx b/src/pages/pubNote.jsx
index 5ed67ca..2a48a34 100644
--- a/src/pages/pubNote.jsx
+++ b/src/pages/pubNote.jsx
@@ -11,7 +11,7 @@ function PubNote() {
let [note, setNote] = useState();
if (!note)
- fetch(`/get-note/${params.id}`)
+ fetch(`/get-note/del/${params.id}`)
.then((data) => {
data
.json()
diff --git a/src/pages/pubNoteSafe.jsx b/src/pages/pubNoteSafe.jsx
new file mode 100644
index 0000000..32b1de8
--- /dev/null
+++ b/src/pages/pubNoteSafe.jsx
@@ -0,0 +1,84 @@
+import ReactMarkdown from "react-markdown";
+import { useState } from "react";
+import { useParams } from "react-router-dom";
+import printDate from "../components/utils";
+import { ChevronDoubleLeftIcon } from "@heroicons/react/24/outline";
+import { Button, IconWithButton } from "../components/button";
+import { CopyToClipboard } from "../components/copytocb";
+
+function PubNoteSafe() {
+ let params = useParams();
+
+ let [note, setNote] = useState();
+
+ if (!note)
+ fetch(`/get-note/safe/${params.id}`)
+ .then((data) => {
+ data
+ .json()
+ .then((data) => {
+ data.code = 1;
+ setNote(data);
+ })
+ .catch(() => {
+ setNote({
+ text: "Такой публичной заметки не сущуествует",
+ name: "Меня не существует",
+ time: Date.now(),
+ code: 0,
+ });
+ });
+ })
+ .catch(() => {
+ setNote({
+ text: "Такой публичной заметки не сущуествует",
+ name: "Меня не существует",
+ time: Date.now(),
+ code: 0,
+ });
+ });
+
+ return (
+
+
+
+ {note?.code === 1 && (
+
+
+
+ Ссылка для отправки публичной заметки. При переходе на эту ссылку,
+ заметка исчезнет.
+
+
+
+
+ )}
+
+
+
+
+ {note?.name || "Загрузка..."}
+
+
+ {printDate(note?.time || Date.now())}
+
+
+
+ {note?.text || "Загрузка..."}
+
+
+
+ );
+}
+
+export default PubNoteSafe;
diff --git a/src/pages/publish.jsx b/src/pages/publish.jsx
index 7d6764b..5e7258a 100644
--- a/src/pages/publish.jsx
+++ b/src/pages/publish.jsx
@@ -27,7 +27,7 @@ function Publish() {
.then((data) => {
localStorage.removeItem("NoteName");
localStorage.removeItem("NoteText");
- navigate(`/pubNotes/${data.id}`, { replace: true });
+ navigate(`/pubNotesSafe/${data.id}`, { replace: true });
})
.catch(() => {
navigate(`/pubError`, { replace: true });