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 503c4e6 commit 4974728
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion public/src/components/Collaborators/Collaborators.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ScReact} from "@veglem/screact";
import "./Collaborators.sass"
import {AppNotesStore, NotesStoreState} from "../../modules/stores/NotesStore";
import {imagesUlr} from "../../modules/api";
import {imagesUlr} from "../../utils/consts";

export class Collaborators extends ScReact.Component<any, any> {
state = {
Expand Down
2 changes: 1 addition & 1 deletion public/src/components/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export class NoteEditor extends ScReact.Component<NoteEditorProps, NoteEditorTyp
showHoverTooltip={false}
icon="link.svg"
label="Поделиться"
content={<SharePanel public={this.state.selectedNote?.public} />}
content={<SharePanel note={this.state.selectedNote} />}
/> : ""
}
</div>
Expand Down
3 changes: 1 addition & 2 deletions public/src/components/ProfileAvatar/ProfileAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {ScReact} from '@veglem/screact';
import {Img} from '../Image/Image';
import {imagesUlr} from '../../modules/api';
import {AppToasts} from '../../modules/toasts';
import {AppDispatcher} from '../../modules/dispatcher';
import {AppUserStore, UserActions, UserStoreState} from '../../modules/stores/UserStore';
import './ProfileAvatar.sass';
import {AvatarUploadLoader} from '../AvatarUplodaLoader/AvatarUploadLoader';
import {crop} from '../../modules/utils';
import {MAX_AVATAR_SIZE} from '../../utils/consts';
import {imagesUlr, MAX_AVATAR_SIZE} from '../../utils/consts';

type ProfileAvatarState = {
uploadAnimation: boolean,
Expand Down
7 changes: 5 additions & 2 deletions public/src/components/SharePanel/SharePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {AppNotesStore, NotesActions} from "../../modules/stores/NotesStore";
import {parseNoteTitle} from "../../modules/utils";
import {AppDispatcher} from "../../modules/dispatcher";
import {AppToasts} from "../../modules/toasts";
import {baseUrl} from "../../utils/consts";

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

Expand Down Expand Up @@ -43,6 +44,8 @@ export class SharePanel extends ScReact.Component<any, any> {
}

render() {
const noteUrl = baseUrl + "/notes/" + this.props.note?.id

return (
<div className="share_panel">
<div className="share_panel__invite-people-container">
Expand All @@ -56,9 +59,9 @@ export class SharePanel extends ScReact.Component<any, any> {
<h3>Поделиться ссылкой</h3>
<div className="share_panel__share-link-container__center-container">
<span>Просматривать могут все, у кого есть ссылка</span>
<ToggleButton value={this.props.public} onToggle={this.handleToggle}/>
<ToggleButton value={this.props.note?.public} onToggle={this.handleToggle}/>
</div>
<input type="text" disabled className="share_panel__share-link-container__input" value={window.location.href} />
<input type="text" disabled className="share_panel__share-link-container__input" value={noteUrl} />
<Button label="Скопировать" onClick={this.copyNoteURL} />
</div>
<div className="share_panel__social-btns-container">
Expand Down
10 changes: 3 additions & 7 deletions public/src/modules/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import {
UserRegisterCredentialsType,
UserUpdatePasswordCredentialsType
} from './stores/UserStore';
import {isDebug} from "../utils/consts";

const baseUrl = isDebug ? 'http://localhost:8080/api' : 'https://you-note.ru/api';

export const imagesUlr = isDebug ? 'http://localhost/images/' : 'https://you-note.ru/images/';
import {baseUrl} from "../utils/consts";

enum RequestMethods {
POST = 'POST',
Expand Down Expand Up @@ -701,10 +697,10 @@ class NoteRequests {
}

class SharedNoteRequests {
private baseUrl = '/shared';
private baseUrl = '/shared/note/';

Get = async (id: string) => {
const response = await fetch(baseUrl + this.baseUrl + '/' + id);
const response = await fetch(baseUrl + this.baseUrl + id);

if (response.status === 200) {
const data = await response.json()
Expand Down
2 changes: 0 additions & 2 deletions public/src/modules/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ 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
1 change: 0 additions & 1 deletion public/src/pages/Notes/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const NotesLoader = async (path:string) => {
const noteId = window.location.pathname.split('/').at(-1);

AppSharedNoteRequests.Get(noteId).then(note => {
console.log(note)
AppRouter.openSharedNotePage(note)
}).catch(() => {
AppRouter.go("/")
Expand Down
6 changes: 6 additions & 0 deletions public/src/utils/consts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export const isDebug = process.env.NODE_ENV === 'development';


export const baseUrl = isDebug ? 'http://localhost:8080/api' : 'https://you-note.ru/api';

export const imagesUlr = isDebug ? 'http://localhost/images/' : 'https://you-note.ru/images/';


const MEGABYTE_SIZE = 1024 * 1024;
export const MAX_AVATAR_SIZE = 5 * MEGABYTE_SIZE;
export const MAX_ATTACH_SIZE = 30 * MEGABYTE_SIZE;
Expand Down

0 comments on commit 4974728

Please sign in to comment.