a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

adjusted Are you sures to make them harder to click accidentally

celine 1f47a6b9 f3f37c73

+91 -47
+45 -22
app/lish/[did]/[publication]/dashboard/DraftList.tsx
··· 7 7 import { Menu, MenuItem } from "components/Layout"; 8 8 import { MoreOptionsTiny } from "components/Icons/MoreOptionsTiny"; 9 9 import { deleteDraft } from "./deleteDraft"; 10 + import { DeleteSmall } from "components/Icons/DeleteSmall"; 11 + import { PrimaryKey } from "drizzle-orm/sqlite-core"; 12 + import { ButtonPrimary } from "components/Buttons"; 10 13 11 14 export function DraftList() { 12 15 let { data: pub_data } = usePublicationData(); ··· 67 70 let { mutate } = usePublicationData(); 68 71 let [state, setState] = useState<"normal" | "confirm">("normal"); 69 72 70 - return ( 71 - <MenuItem 72 - onSelect={async (e) => { 73 - if (state === "normal") { 74 - e.preventDefault(); 75 - return setState("confirm"); 76 - } 77 - await mutate((data) => { 78 - if (!data) return data; 79 - return { 80 - ...data, 81 - leaflets_in_publications: data.leaflets_in_publications.filter( 82 - (d) => d.leaflet !== props.id, 83 - ), 84 - }; 85 - }, false); 86 - await deleteDraft(props.id); 87 - }} 88 - > 89 - {state === "normal" ? "Delete Draft" : "Are you sure?"} 90 - </MenuItem> 91 - ); 73 + if (state === "normal") { 74 + return ( 75 + <MenuItem 76 + onSelect={(e) => { 77 + if (state === "normal") { 78 + e.preventDefault(); 79 + return setState("confirm"); 80 + } 81 + }} 82 + > 83 + <DeleteSmall /> 84 + Delete Draft 85 + </MenuItem> 86 + ); 87 + } 88 + if (state === "confirm") { 89 + return ( 90 + <div className="flex flex-col items-center font-bold text-secondary px-2 py-1"> 91 + Are you sure? 92 + <div className="text-sm text-tertiary font-normal"> 93 + This action cannot be undone! 94 + </div> 95 + <ButtonPrimary 96 + className="mt-2" 97 + onClick={async () => { 98 + await mutate((data) => { 99 + if (!data) return data; 100 + return { 101 + ...data, 102 + leaflets_in_publications: data.leaflets_in_publications.filter( 103 + (d) => d.leaflet !== props.id, 104 + ), 105 + }; 106 + }, false); 107 + await deleteDraft(props.id); 108 + }} 109 + > 110 + Delete 111 + </ButtonPrimary> 112 + </div> 113 + ); 114 + } 92 115 }
+46 -25
app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx
··· 12 12 import { MoreOptionsTiny } from "components/Icons/MoreOptionsTiny"; 13 13 import { deletePost } from "./deletePost"; 14 14 import { mutate } from "swr"; 15 + import { Button } from "react-aria-components"; 16 + import { ButtonPrimary } from "components/Buttons"; 15 17 16 18 export function PublishedPostsList() { 17 19 let { data: publication } = usePublicationData(); ··· 110 112 111 113 function DeletePost(props: { document_uri: string }) { 112 114 let { mutate } = usePublicationData(); 113 - let [confirm, setConfirm] = useState(false); 114 - return ( 115 - <MenuItem 116 - onSelect={async (e) => { 117 - if (!confirm) { 115 + let [state, setState] = useState<"normal" | "confirm">("normal"); 116 + 117 + if (state === "normal") { 118 + return ( 119 + <MenuItem 120 + onSelect={async (e) => { 118 121 e.preventDefault(); 119 - setConfirm(true); 122 + setState("confirm"); 120 123 return; 121 - } 122 - await mutate((data) => { 123 - if (!data) return data; 124 - return { 125 - ...data, 126 - leaflets_in_publications: data.leaflets_in_publications.filter( 127 - (l) => l.doc !== props.document_uri, 128 - ), 129 - documents_in_publications: data.documents_in_publications.filter( 130 - (d) => d.documents?.uri !== props.document_uri, 131 - ), 132 - }; 133 - }, false); 134 - await deletePost(props.document_uri); 135 - }} 136 - > 137 - {!confirm ? "Delete Post" : "Are you sure?"} 138 - </MenuItem> 139 - ); 124 + }} 125 + > 126 + Delete Post 127 + </MenuItem> 128 + ); 129 + } 130 + if (state === "confirm") { 131 + return ( 132 + <div className="flex flex-col items-center font-bold text-secondary px-2 py-1"> 133 + Are you sure? 134 + <div className="text-sm text-tertiary font-normal"> 135 + This action cannot be undone! 136 + </div> 137 + <ButtonPrimary 138 + className="mt-2" 139 + onClick={async () => { 140 + await mutate((data) => { 141 + if (!data) return data; 142 + return { 143 + ...data, 144 + leaflets_in_publications: data.leaflets_in_publications.filter( 145 + (l) => l.doc !== props.document_uri, 146 + ), 147 + documents_in_publications: 148 + data.documents_in_publications.filter( 149 + (d) => d.documents?.uri !== props.document_uri, 150 + ), 151 + }; 152 + }, false); 153 + await deletePost(props.document_uri); 154 + }} 155 + > 156 + Delete 157 + </ButtonPrimary> 158 + </div> 159 + ); 160 + } 140 161 }