mirror of
https://github.com/artegoser/AnoPaper.git
synced 2024-11-05 20:43:57 +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 {
|
||||
ChevronDoubleLeftIcon,
|
||||
ChevronDoubleRightIcon,
|
||||
PencilIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
|
@ -93,6 +94,12 @@ function NotePage() {
|
|||
setEdit(!edit);
|
||||
}}
|
||||
/>
|
||||
<ButtonWithIcon
|
||||
className="mt-4"
|
||||
text={locals.Publish}
|
||||
icon={ChevronDoubleRightIcon}
|
||||
href={`/notes/publish?local_id=${params.id}`}
|
||||
/>
|
||||
{!edit && (
|
||||
<ButtonWithIcon
|
||||
className="mt-4"
|
||||
|
|
|
@ -17,20 +17,30 @@
|
|||
|
||||
import { useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useSearchParams } from "react-router-dom";
|
||||
|
||||
function Publish() {
|
||||
const navigate = useNavigate();
|
||||
let done = false;
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
useEffect(() => {
|
||||
if (!done) {
|
||||
done = true;
|
||||
|
||||
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"),
|
||||
text: localStorage.getItem("NoteText"),
|
||||
};
|
||||
}
|
||||
|
||||
if (!note.name) {
|
||||
err = locals.PubErrorMsgNoName;
|
||||
|
@ -63,8 +73,7 @@ function Publish() {
|
|||
.catch(() => {
|
||||
navigate(`/pubError`, { replace: true });
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
});
|
||||
|
||||
return <div />;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue