mirror of
https://github.com/artegoser/AnoPaper.git
synced 2024-11-24 21:06:21 +03:00
feat: publish local notes
This commit is contained in:
parent
f8365ce2ee
commit
3963e435e8
2 changed files with 54 additions and 38 deletions
|
@ -18,6 +18,7 @@
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
ChevronDoubleLeftIcon,
|
ChevronDoubleLeftIcon,
|
||||||
|
ChevronDoubleRightIcon,
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
|
@ -93,6 +94,12 @@ function NotePage() {
|
||||||
setEdit(!edit);
|
setEdit(!edit);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<ButtonWithIcon
|
||||||
|
className="mt-4"
|
||||||
|
text={locals.Publish}
|
||||||
|
icon={ChevronDoubleRightIcon}
|
||||||
|
href={`/notes/publish?local_id=${params.id}`}
|
||||||
|
/>
|
||||||
{!edit && (
|
{!edit && (
|
||||||
<ButtonWithIcon
|
<ButtonWithIcon
|
||||||
className="mt-4"
|
className="mt-4"
|
||||||
|
|
|
@ -17,20 +17,30 @@
|
||||||
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { useSearchParams } from "react-router-dom";
|
||||||
|
|
||||||
function Publish() {
|
function Publish() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
let done = false;
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!done) {
|
|
||||||
done = true;
|
|
||||||
|
|
||||||
let err = false;
|
let err = false;
|
||||||
const note = {
|
|
||||||
|
let note;
|
||||||
|
|
||||||
|
if (searchParams.get("local_id")) {
|
||||||
|
let localNote =
|
||||||
|
localStorage.getObj("Notes")[searchParams.get("local_id")];
|
||||||
|
note = {
|
||||||
|
name: localNote.name,
|
||||||
|
text: localNote.text,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
note = {
|
||||||
name: localStorage.getItem("NoteName"),
|
name: localStorage.getItem("NoteName"),
|
||||||
text: localStorage.getItem("NoteText"),
|
text: localStorage.getItem("NoteText"),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!note.name) {
|
if (!note.name) {
|
||||||
err = locals.PubErrorMsgNoName;
|
err = locals.PubErrorMsgNoName;
|
||||||
|
@ -63,8 +73,7 @@ function Publish() {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
navigate(`/pubError`, { replace: true });
|
navigate(`/pubError`, { replace: true });
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}, []);
|
|
||||||
|
|
||||||
return <div />;
|
return <div />;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue