Commit fd7b8c32 authored by Steven's avatar Steven

chore: add copy non-private memo link

parent 660908e4
import copy from "copy-to-clipboard";
import { useState, useEffect, useCallback } from "react"; import { useState, useEffect, useCallback } from "react";
import { editorStateService, memoService, userService } from "../services"; import { editorStateService, memoService, userService } from "../services";
import { useAppSelector } from "../store"; import { useAppSelector } from "../store";
...@@ -109,6 +110,16 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => { ...@@ -109,6 +110,16 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
setMemo(memo); setMemo(memo);
}, []); }, []);
const handleCopyMemoLinkBtnClick = () => {
if (memo.visibility === "PRIVATE") {
toastHelper.error("This memo is private only.");
return;
}
copy(`${window.location.origin}/explore?memoId=${memo.id}`);
toastHelper.success("Copied");
};
const handleEditMemoBtnClick = () => { const handleEditMemoBtnClick = () => {
props.destroy(); props.destroy();
editorStateService.setEditMemoWithId(memo.id); editorStateService.setEditMemoWithId(memo.id);
...@@ -152,6 +163,9 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => { ...@@ -152,6 +163,9 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
<div className="btns-container"> <div className="btns-container">
<Only when={!userService.isVisitorMode()}> <Only when={!userService.isVisitorMode()}>
<> <>
<button className="btn edit-btn" onClick={handleCopyMemoLinkBtnClick}>
<Icon.Link className="icon-img" />
</button>
<button className="btn edit-btn" onClick={handleEditMemoBtnClick}> <button className="btn edit-btn" onClick={handleEditMemoBtnClick}>
<Icon.Edit3 className="icon-img" /> <Icon.Edit3 className="icon-img" />
</button> </button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment