Skip to content

Commit

Permalink
Сделал страницу просмотра шереной заметки
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 19, 2024
1 parent 72561fd commit 503c4e6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion public/src/components/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
<Collaborators/>
</div>

<div className={isSubNote ? "hidden" : ""}>
<div className={!isOwner || isSubNote ? "hidden" : ""}>
<Tooltip
hoverTooltip={this.state.selectedNote?.favorite ? "Удалить из избранного" : "В избранное"}
showHoverTooltip={true}
Expand Down
10 changes: 8 additions & 2 deletions public/src/components/SharePanel/SharePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {Img} from "../Image/Image";
import {AppNotesStore, NotesActions} from "../../modules/stores/NotesStore";
import {parseNoteTitle} from "../../modules/utils";
import {AppDispatcher} from "../../modules/dispatcher";
import {AppToasts} from "../../modules/toasts";

export class SharePanel extends ScReact.Component<any, any> {

Expand Down Expand Up @@ -36,6 +37,11 @@ export class SharePanel extends ScReact.Component<any, any> {
social_window.focus();
}

copyNoteURL = async () => {
await navigator.clipboard.writeText(window.location.href)
AppToasts.info("Ссылка на заметку скопирована")
}

render() {
return (
<div className="share_panel">
Expand All @@ -52,8 +58,8 @@ export class SharePanel extends ScReact.Component<any, any> {
<span>Просматривать могут все, у кого есть ссылка</span>
<ToggleButton value={this.props.public} onToggle={this.handleToggle}/>
</div>
<input type="text" disabled className="share_panel__share-link-container__input" value="https://you-note.ru/notes/4a644626-c335-4728-bb82-f63e9844eb74"/>
<Button label="Скопировать"/>
<input type="text" disabled className="share_panel__share-link-container__input" value={window.location.href} />
<Button label="Скопировать" onClick={this.copyNoteURL} />
</div>
<div className="share_panel__social-btns-container">
<h3>Поделиться через соц. сети</h3>
Expand Down
2 changes: 2 additions & 0 deletions public/src/modules/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export class Router extends ScReact.Component<any, routerState> {
}));

page.loader(path).then((props) => {
console.log("123")
console.log(props)
this.setState(s => ({
...s,
currPage: page.page,
Expand Down
11 changes: 9 additions & 2 deletions public/src/pages/Notes/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ export const NotesLoader = async (path:string) => {
// history.pushState(null, '', '/notes');
// resolve({notes: store.notes});

AppRouter.go("/404")
reject()
AppSharedNoteRequests.Get(noteId).then(note => {
console.log(note)
resolve({notes: store.notes, note: note, tags: store.tags});
}).catch(() => {
AppRouter.go("/404")

reject()
});

});
} else {
resolve({notes: store.notes, tags: store.tags});
Expand Down
1 change: 0 additions & 1 deletion public/src/pages/SharedNote/style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@
background: #1b2735
border-radius: 12px
padding: 20px

0 comments on commit 503c4e6

Please sign in to comment.