a tool for shared writing and social publishing
at update/delete-blocks 75 lines 2.1 kB view raw
1import { Fact, useReplicache } from "src/replicache"; 2import { ButtonPrimary } from "components/Buttons"; 3import { CloseTiny } from "components/Icons/CloseTiny"; 4import { deleteBlock } from "src/utils/deleteBlock"; 5 6export const AreYouSure = (props: { 7 entityID: string[] | string; 8 onClick?: () => void; 9 closeAreYouSure: () => void; 10 type: Fact<"block/type">["data"]["value"] | undefined; 11 compact?: boolean; 12}) => { 13 let entities = [props.entityID].flat(); 14 let { rep } = useReplicache(); 15 16 return ( 17 <div 18 className={` 19 w-full 20 flex items-center justify-center 21 ${ 22 !props.compact && 23 `bg-border-light border-2 border-border rounded-lg 24 ${ 25 props.type === "card" 26 ? "h-[104px]" 27 : props.type === "mailbox" 28 ? "h-[92px]" 29 : "h-full" 30 }` 31 }`} 32 > 33 <div 34 className={`flex h-fit justify-center items-center font-bold text-secondary ${props.compact ? "flex-row gap-2 justify-between w-full " : "flex-col py-2 gap-1"}`} 35 > 36 <div className="text-center w-fit"> 37 Delete{" "} 38 {entities.length > 1 ? ( 39 "Blocks" 40 ) : props.type === "card" ? ( 41 <span>Page</span> 42 ) : props.type === "mailbox" ? ( 43 <span>Mailbox and Posts</span> 44 ) : ( 45 <span>Block</span> 46 )} 47 ?{" "} 48 </div> 49 <div className="flex gap-2"> 50 <ButtonPrimary 51 autoFocus 52 compact 53 onClick={async (e) => { 54 e.stopPropagation(); 55 if (rep) await deleteBlock(entities, rep); 56 }} 57 > 58 Delete 59 </ButtonPrimary> 60 <button 61 className="text-accent-1" 62 onClick={() => props.closeAreYouSure()} 63 > 64 {props.compact ? ( 65 <CloseTiny className="mx-2 shrink-0" /> 66 ) : ( 67 "Nevermind" 68 )} 69 </button> 70 </div> 71 </div> 72 </div> 73 ); 74}; 75