Skip to content

Commit

Permalink
adds toast (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem authored Feb 8, 2024
1 parent eb9191d commit fca5aba
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions apps/builddao/widget/Compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const [showAccountAutocomplete, setShowAccountAutocomplete] = useState(false);
const [mentionsArray, setMentionsArray] = useState([]);
const [mentionInput, setMentionInput] = useState(null);
const [handler, setHandler] = useState("update");
const [showToast, setShowToast] = useState(false);

const [composeKey, setComposeKey] = useState(0);
const memoizedComposeKey = useMemo(() => composeKey, [composeKey]);
Expand Down Expand Up @@ -139,7 +140,9 @@ const postToCustomFeed = ({ feed, text }) => {
onCommit: () => {
setPostContent("");
Storage.privateSet(draftKey, props.template || "");
setComposeKey(generateUID());
setHandler("autocompleteSelected"); // this is a hack to force the iframe to update
setShowToast(true);
},
onCancel: () => {
// console.log(`Cancelled ${feed}: #${postId}`);
Expand Down Expand Up @@ -444,6 +447,7 @@ return (
<TextareaWrapper
className="markdown-editor"
data-value={postContent || ""}
key={memoizedComposeKey}
>
<Widget
src={"buildhub.near/widget/components.MarkdownEditorIframe"}
Expand Down Expand Up @@ -522,5 +526,25 @@ return (
{postBtnText ?? "Post"}
</Button>
</div>
<Widget
src="near/widget/DIG.Toast"
props={{
title: "Post Submitted Successfully",
type: "success",
open: showToast,
onOpenChange: (v) => showToast(v),
trigger: <></>,
action: (
<Button
variant="primary"
style={{ fontSize: 14 }}
onClick={() => showToast(false)}
>
dismiss
</Button>
),
providerProps: { duration: 1000 },
}}
/>
</PostCreator>
);

0 comments on commit fca5aba

Please sign in to comment.