diff --git a/src/components/HashtagTool/index.js b/src/components/HashtagTool/index.js index cc541dc..70bf7d9 100644 --- a/src/components/HashtagTool/index.js +++ b/src/components/HashtagTool/index.js @@ -6,6 +6,7 @@ import Spinner from '../Spinner'; import TrendingSidebar from './TrendingSideBar'; import Sidebar from './SideBar'; import { ReactComponent as UploadSvg } from '../../Icons/UploadSvg.svg'; +import { ReactComponent as CloseIcon } from '../../Icons/CloseIcon.svg'; const HashTagContext = React.createContext(); @@ -259,6 +260,14 @@ export function HashtagTool() { const { notes, LoadMoreMedia, isLoading, filterTags } = useHashTagContext(); const [newPostModal, setNewPostModal] = useState(false); const [loadingMorePosts, setLoadingMorePosts] = useState(false); + const [showSuccessNotification, setShowSuccessNotification] = + useState(false); + + function handlePostUploadSuccess() { + setShowSuccessNotification(true); + setTimeout(() => setShowSuccessNotification(false), 3000); // Auto-hide after 3 seconds + } + useResetScrollOnFilterChange(filterTags); function showNewPostModal() { @@ -306,8 +315,25 @@ export function HashtagTool() { )} + + {showSuccessNotification && ( +
+
+

+ Post Uploaded Successfully +

+ + setShowSuccessNotification(false) + } + /> +
+
+ )} diff --git a/src/components/Post/newPost.js b/src/components/Post/newPost.js index 6adb279..8d24968 100644 --- a/src/components/Post/newPost.js +++ b/src/components/Post/newPost.js @@ -5,7 +5,7 @@ import { ReactComponent as CloseIcon } from '../../Icons/CloseIcon.svg'; import { ReactComponent as UpwardArrow } from '../../Icons/upwardArrow.svg'; import { ReactComponent as UploadNew } from '../../Icons/uploadNewPost.svg'; -const PostUpload = ({ isOpen, onClose }) => { +const PostUpload = ({ isOpen, onClose, onUploadSuccess }) => { const [link, setLink] = useState(null); const [title, setTitle] = useState(''); const [hashtags, setHashtags] = useState([]); @@ -15,7 +15,7 @@ const PostUpload = ({ isOpen, onClose }) => { const [postStage, setPostStage] = useState(0); const [isUploading, setIsUploading] = useState(false); const [showMaxTagsAlert, setShowMaxTagsAlert] = useState(false); - const [postSuccess, setPostSuccess] = useState(false); + const MAX_TAGS = 3; let alertTimeout = useRef(null); @@ -83,10 +83,11 @@ const PostUpload = ({ isOpen, onClose }) => { ['p', uesrPublicKey], ['category', 'memestrrr'], ], - content: title + ' ' + link, + content: title + ' ' + link + ' ' + hashtags, }; // console.log("event", commentEvent) + console.log('Comment Event: ', commentEvent); commentEvent.id = getEventHash(commentEvent); commentEvent.sig = getSignature(commentEvent, sk.data); @@ -95,10 +96,14 @@ const PostUpload = ({ isOpen, onClose }) => { Promise.resolve(p1).then( value => { console.log('Success', value); - setPostStage(4); // Success! + // Call the callback function passed from the parent component + if (onUploadSuccess) { + onUploadSuccess(); // Call the callback if it's provided + } + onClose(); // Close the upload dialog }, reason => { - console.error('something went wrong', reason); // Error! + console.error('something went wrong', reason); // Error handling }, ); }; @@ -237,268 +242,272 @@ const PostUpload = ({ isOpen, onClose }) => { }, []); return ( -
- - - -
- - -
-
- - -
-
-

- Upload -

+ <> +
+ + + +
+ + +
+
+ + +
+
+

+ Upload +

+
+
- -
- -
-
-
-
- -
- -
-
-
- - -
-
-
- - # - -
+ +
+
+
+
+ +
-
- Upto 3 tags, - seperated with - space. -
- {hashtags.map( - (tag, index) => ( -
- {tag} - -
- ), - )} - - {showMaxTagsAlert && ( -
-
-

- Max - allowed - tags: 3 -

-
-
- )}
-
+
+ -
- -
-
- {!preview && - !isUploading && ( - <> - - -

- PNG, - JPG, - GIF, - MP4 - up - to - 10MB -

- - )} - {isUploading && ( -
-
+
+
+
+ + # +
- )} - {preview && ( -
- +
+
+ Upto 3 tags, + seperated with + space. +
+ {hashtags.map( + ( + tag, + index, + ) => ( +
-
- + className="flex items-center text-wrap gap-1 bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded"> + {tag}
+ ), + )} + + {showMaxTagsAlert && ( +
+
+

+ Max + allowed + tags: + 3 +

+
)}
+ +
+ +
+
+ {!preview && + !isUploading && ( + <> + + +

+ PNG, + JPG, + GIF, + MP4 + up + to + 10MB +

+ + )} + {isUploading && ( +
+
+
+ )} + {preview && ( +
+ Preview +
+ + +
+
+ )} +
+
+
-
- -
- -
- - + +
+ +
+ + +
-
-
-
- {postSuccess && ( -
-
-
- )} -
+
+
+
+ ); };