Skip to content

Commit

Permalink
Merge pull request #115 from Macktireh/refactoring
Browse files Browse the repository at this point in the history
Follow-up page title correction and refactoring
  • Loading branch information
Macktireh authored Oct 28, 2023
2 parents 0f92743 + a66759b commit 6223c52
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 31 deletions.
6 changes: 5 additions & 1 deletion src/components/homePrivate/ModalAddNewTweet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const ModalAddNewTweet: React.FC = () => {
handleClose={handleClosePopup}
/>
<div
className={propsContext?.emojiPostState.chosenEmojiPost ? "modal-container addTweet addTweetHeight" : "modal-container addTweet"}
className={
propsContext?.emojiPostState.chosenEmojiPost
? "modal-container addTweet addTweetHeight"
: "modal-container addTweet"
}
// style={{ height: propsContext?.emojiPostState.chosenEmojiPost ? "600px" : "" }}
>
<div className="modal-header">
Expand Down
20 changes: 11 additions & 9 deletions src/components/homePrivate/PopupDeletePost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ const PopupDeletePost = () => {
};

return (
<Popup
popupActive={
propsContext?.popupDeletePost.popupActiveDeletePost ? propsContext.popupDeletePost.popupActiveDeletePost : false
}
popupTitle="Vous êtes sûr de vouloir supprimer ?"
popupBtnText="Oui Supprimer"
handleDiscard={handleDelete}
handleClose={handleClosePopup}
/>
<Popup
popupActive={
propsContext?.popupDeletePost.popupActiveDeletePost
? propsContext.popupDeletePost.popupActiveDeletePost
: false
}
popupTitle="Vous êtes sûr de vouloir supprimer ?"
popupBtnText="Oui Supprimer"
handleDiscard={handleDelete}
handleClose={handleClosePopup}
/>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/homePrivate/PopupPostOptionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const PopupPostOrCommentOptionCard: React.FC<propsTypes> = ({ type, currentUser,
propsContext.popupDeletePost.setPopupActiveDeletePost();
}
};

const handleEditingComment = async (public_id: string) => {
if (propsContext) {
propsContext.commentPublicIdState.setCommentPublicId(public_id);
propsContext.isEditCommentState.setIsEditingComment();
propsContext.modalComment.setModalActiveComment();
}
};

const handleConfirmDeleteComment = async (public_id: string) => {
if (propsContext) {
propsContext.commentPublicIdState.setCommentPublicId(public_id);
Expand Down
8 changes: 4 additions & 4 deletions src/components/homePrivate/SectionHeaderTweet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ const SectionHeaderTweet: React.FC<propsTypes> = ({ page, title, subtitle, curre
)}
<div className="center">
{page === privateRoutes.explore.name ? (
<InputSearch suggestion={true} />
<InputSearch suggestion={true} />
) : (
<div className={page === privateRoutes.explore.name ? "centent notif" : "centent"}>
<strong>{title}</strong>
{(page === privateRoutes.profile.name || page === privateRoutes.bookmarks.name || page === privateRoutes.lists.name) && (
<span>{subtitle}</span>
)}
{(page === privateRoutes.profile.name ||
page === privateRoutes.bookmarks.name ||
page === privateRoutes.lists.name) && <span>{subtitle}</span>}
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/navbar/ButtonAddTweet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import IconSVG from "@/widgets/IconSVG";
import { useTweetComment } from "@/context/TweetCommentProvider";

type PropsTypes = { nameClass: string }
type PropsTypes = { nameClass: string };

const ButtonAddTweet: React.FC<PropsTypes> = ({ nameClass }) => {
const propsContext = useTweetComment();
Expand Down
6 changes: 4 additions & 2 deletions src/components/notification/CardNotif.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ const CardNotif: React.FC<propsTypes> = ({ currentUser, notification, fromUser }
if (notification) {
switch (notification.typeNotif) {
case notificationType.following:
navigate(`${pathLinkProfile(currentUser?.pseudo as string)}/${privateRoutes.followers.name}`)
navigate(`${pathLinkProfile(currentUser?.pseudo as string)}/${privateRoutes.followers.name}`);
break;
case notificationType.addPost:
notification && navigate(pathLinkPostDetail(fromUser.pseudo, notification.postPublicId));
break;
default:
notification && currentUser && navigate(pathLinkPostDetail(currentUser.pseudo, notification.postPublicId));
notification &&
currentUser &&
navigate(pathLinkPostDetail(currentUser.pseudo, notification.postPublicId));
}
}
};
Expand Down
23 changes: 13 additions & 10 deletions src/components/postDetails/PopupDeleteComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ const PopupDeleteComment = () => {
const propsContext = useTweetComment();

const handleClosePopup = () => {
propsContext?.popupDeleteComment.setPopupActiveDeleteComment && propsContext.popupDeleteComment.setPopupActiveDeleteComment();
propsContext?.popupDeleteComment.setPopupActiveDeleteComment &&
propsContext.popupDeleteComment.setPopupActiveDeleteComment();
};

const handleDelete = () => {
propsContext && propsContext.handleDeleteComment();
};

return (
<Popup
popupActive={
propsContext?.popupDeleteComment.popupActiveDeleteComment ? propsContext.popupDeleteComment.popupActiveDeleteComment : false
}
popupTitle="Vous êtes sûr de vouloir supprimer ?"
popupBtnText="Oui Supprimer"
handleDiscard={handleDelete}
handleClose={handleClosePopup}
/>
<Popup
popupActive={
propsContext?.popupDeleteComment.popupActiveDeleteComment
? propsContext.popupDeleteComment.popupActiveDeleteComment
: false
}
popupTitle="Vous êtes sûr de vouloir supprimer ?"
popupBtnText="Oui Supprimer"
handleDiscard={handleDelete}
handleClose={handleClosePopup}
/>
);
};

Expand Down
3 changes: 2 additions & 1 deletion src/context/NotificationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const NotificationProvider = ({ children }: React.PropsWithChildren) => {
if (!clientRef.current) {
let client: WebSocket;
if (localStorage.getItem("access")) {
client = new WebSocket(urlWebSocketNotification + "?token=" + localStorage.getItem("access"));
// client = new WebSocket(urlWebSocketNotification + "?token=" + localStorage.getItem("access"));
client = new WebSocket(urlWebSocketNotification);
} else {
client = new WebSocket(urlWebSocketNotification + "?token=none");
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/private/Follow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Follow: React.FC<propsTypes> = ({
};

React.useEffect(() => {
document.title = `${title} ${currentUser?.user.first_name} ${currentUser?.user.last_name} (@${currentUser?.pseudo}) | Clone Twitter`;
document.title = `${title} ${another?.user.first_name} ${another?.user.last_name} (@${another?.pseudo}) | Clone Twitter`;

setActiveTab(followActive);
if (!flag.current) {
Expand Down

0 comments on commit 6223c52

Please sign in to comment.