Skip to content

Commit

Permalink
Merge branch 'main' into abood
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarAnKh authored May 25, 2024
2 parents c8de4ae + d561749 commit 8f225f8
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 66 deletions.
Binary file modified Scriptoria project information/scriptoria backlog.xlsx
Binary file not shown.
4 changes: 2 additions & 2 deletions backend/src/controllers/accountController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createAccount = async (req, res) => {
try {
await user.save();
const { accessToken, refreshToken } = await user.generateAuthToken();
res.cookie('jwt', refreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000, secure: true, sameSite: 'None' });
res.cookie('jwt', refreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 });
res.status(201).send({ user, token: accessToken, refreshToken });
} catch (error) {
res.status(400).send(error);
Expand Down Expand Up @@ -63,7 +63,7 @@ const refreshAccount = async (req, res) => {
);
user.tokens = user.tokens.concat({ token: newRefreshToken });
await user.save();
res.cookie('jwt', newRefreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000, secure: true, sameSite: 'None' });
res.cookie('jwt', newRefreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 });
res.cookie('flag', true);
res.send({ accessToken, userName: user.userName, refreshToken: newRefreshToken, userInfo: user });
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions backend/src/emails/sendMail.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const sendMail = async (email, text, type) => {
};
const htmlToSend = template(replacements)
mailOptions.to = email
mailOptions.subject = "Account recovery"
mailOptions.html = htmlToSend
}
else if (type === 'invitation') {
Expand All @@ -52,6 +53,7 @@ const sendMail = async (email, text, type) => {
link: text
};
const htmlToSend = template(replacements)
mailOptions.subject = "Invitation Link"
mailOptions.to = email
mailOptions.html = htmlToSend
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sriptoria",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:5000",
"proxy": "http://51.16.88.44:5000",
"dependencies": {
"@dicebear/collection": "^8.0.1",
"@dicebear/core": "^8.0.1",
Expand Down
48 changes: 26 additions & 22 deletions frontend/public/locales/ar/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"cancel": "الغاء",
"no-comments": "كن أول المعلقين على هذه القصة",
"write-something": "اكتب شيء ...",
"reply-to" : "الرد على",
"reply-to": "الرد على",
"view-more-replies": "عرض المزيد من الردود",
"view-less-replies": "عرض ردود أقل"
},
Expand Down Expand Up @@ -270,27 +270,31 @@
"Preview": "معاينة",
"Delete": "حذف"
},
"Chats" : {
"chats" : "الدردشات",
"chat-info" : "معلومات الدردشة",
"edit-name" : "تعديل الاسم",
"save" : "حفظ",
"cancel" : "إلغاء",
"members" : "الأعضاء",
"me" : "أنا",
"admin" : "المشرف",
"leave-group" : "مغادرة المجموعة",
"delete-group" : "حذف المجموعة",
"new-chat" : "دردشة جديدة",
"create-group-chat" : "إنشاء دردشة جماعية",
"group-chat-name" : "اسم الدردشة الجماعية",
"group-name-is-required" : "اسم المجموعة مطلوب!",
"choose-group-members" : "اختر أعضاء المجموعة",
"group-is-empty" : "المجموعة فارغة!",
"chat-with-one-person-only" : "الدردشة مع شخص واحد فقط",
"choose-someone-to-chat-with" : "اختر شخصًا للدردشة معه",
"choose-one-person" : "اختر شخصًا واحدًا!",
"start-chating" : "ابدأ الدردشة",
"Chats": {
"chats": "الدردشات",
"chat-info": "معلومات الدردشة",
"edit-name": "تعديل الاسم",
"save": "حفظ",
"cancel": "إلغاء",
"members": "الأعضاء",
"me": "أنا",
"admin": "المشرف",
"leave-group": "مغادرة المجموعة",
"delete-group": "حذف المجموعة",
"new-chat": "دردشة جديدة",
"create-group-chat": "إنشاء دردشة جماعية",
"group-chat-name": "اسم الدردشة الجماعية",
"group-name-is-required": "اسم المجموعة مطلوب!",
"choose-group-members": "اختر أعضاء المجموعة",
"group-is-empty": "المجموعة فارغة!",
"chat-with-one-person-only": "الدردشة مع شخص واحد فقط",
"choose-someone-to-chat-with": "اختر شخصًا للدردشة معه",
"choose-one-person": "اختر شخصًا واحدًا!",
"start-chating": "ابدأ الدردشة",
"write-a-message": "اكتب رسالة"
},
"TeamMembers": {
"Leadership": "فريق القيادة لدينا",
"Developers": "المصممون والمطورون"
}
}
4 changes: 4 additions & 0 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,9 @@
"choose-one-person" : "choose one person !",
"start-chating" : "start chating",
"write-a-message" : "write a message"
},
"TeamMembers":{
"Leadership": "Our leadership team",
"Developers": "Designers & Developers"
}
}
4 changes: 4 additions & 0 deletions frontend/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"choose-one-person" : "¡elige a una persona!",
"start-chating" : "comenzar a chatear",
"write-a-message": "escribir un mensaje"
},
"TeamMembers": {
"Leadership": "Nuestro equipo de liderazgo",
"Developers": "Diseñadores y desarrolladores"
}
}
4 changes: 4 additions & 0 deletions frontend/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"choose-one-person" : "choisissez une personne!",
"start-chating" : "commencer à discuter",
"write-a-message": "écrire un message"
},
"TeamMembers": {
"Leadership": "Notre équipe de direction",
"Developers": "Concepteurs et développeurs"
}
}
4 changes: 4 additions & 0 deletions frontend/public/locales/hin/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"choose-one-person" : "एक व्यक्ति चुनें!",
"start-chating" : "चैटिंग शुरू करें",
"write-a-message": "संदेश लिखें"
},
"TeamMembers": {
"Leadership": "हमारी नेतृत्व टीम",
"Developers": "डिज़ाइनर और डेवलपर"
}
}
4 changes: 4 additions & 0 deletions frontend/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,9 @@
"choose-one-person" : "选择一个人!",
"start-chating" : "开始聊天",
"write-a-message": "写消息"
},
"TeamMembers": {
"Leadership": "我们的领导团队",
"Developers": "设计师和开发人员"
}
}
19 changes: 10 additions & 9 deletions frontend/src/components/chat-app/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import React from 'react'
import { Tooltip } from 'react-tooltip'
import useAuth from '../../hooks/useAuth'

const Message = ({owner, text, time}) => {
const {auth} = useAuth()
const Message = ({ owner, text, time }) => {
const { auth } = useAuth()
const isOwner = owner._id === auth?.userInfo?._id

return (
<div className='row m-1 '>
{isOwner? <></> : <div className='text-secondary text-start'>{owner.userName}</div>}
<div className={`d-flex flex-row justify-content-${isOwner? 'end' : 'start'}`}>
<div className={`text rounded-5 text-break p-2 bg-${isOwner? 'primary' : 'secondary'}`} data-tooltip-id="my-tooltip" data-tooltip-content={time} data-tooltip-place={isOwner? 'left' : 'right'} >
{text}

<div className='row m-1'>
{isOwner ? <></> : <div className='text-secondary text-start'>{owner.userName}</div>}
<div className={`d-flex flex-row justify-content-${isOwner ? 'end' : 'start'}`}>
<div className={`text rounded-5 p-2 text-break bg-${isOwner ? 'primary' : 'secondary'}`} data-tooltip-id="my-tooltip" data-tooltip-content={time} data-tooltip-place={isOwner ? 'left' : 'right'} >
{text}
</div>
<Tooltip id="my-tooltip" />
</div>
</div>
</div>
)
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/placeholder/MyWorkPlaceholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const MyWorkPlaceholder = ({ type }) => {
{
Array(3).fill().map((_, idx) => {
return (
<div className="custom-card-article">
<Skeleton height={280} style={{}} />
<div className="custom-card-article" key={idx}>
<Skeleton height={280} style={{ backgroundColor: "var(--accent-Color)" }} />
<div className="custom-card-data">
<Skeleton />
<Skeleton />
Expand All @@ -28,7 +28,7 @@ const MyWorkPlaceholder = ({ type }) => {
{
Array(3).fill().map((_, idx) => {
return (
<div className="TopCard">
<div className="TopCard" key={idx}>
<Skeleton animation="wave" />
<Skeleton animation="wave" />
<Skeleton animation="wave" />
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/profile-info/ProfileInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const ProfileInfo = (props) => {
setFollowerCount(followerCount);
const folloingCount = await getfollowingCount(_id)
setFollowingCount(folloingCount)
const accountWorks = await getAccountWork(_id, true)
const accountWorks = await getAccountWork(_id, false)
if (accountWorks.state) {
setGetAccountWorks(accountWorks?.stories?.length)
}
Expand Down Expand Up @@ -318,8 +318,8 @@ const ProfileInfo = (props) => {
<div>
<div className="buttons1">
<InfoButton text={t("ProfileInfo.following")} value={followerCount?.followerCount} />
<InfoButton text={t("ProfileInfo.works")} value={getAccountWorks} />
<InfoButton text={t("ProfileInfo.followers")} value={followingCount?.followingsNumber} />
<InfoButton text={t("ProfileInfo.works")} value={getAccountWorks} />
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/story-card/StoryCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ const StoryCard = ({ story, t }) => {
fetchWriters();
fetchRatings();

}, []);
}, [story]);


return(
return (
<div className={`card mb-1`} style={{ width: '95%', height: '100%', margin: '0 10px', minHeight: '200px', backgroundColor: story?.backgroundColor }}>
<div className="row no-gutters">
<div className="col-md-4">
Expand All @@ -61,7 +61,7 @@ const StoryCard = ({ story, t }) => {
))}
</h6>
<div className="d-flex">
<StarRating rating={ratings} />
<StarRating rating={ratings} />
<div className='voters text-white'>{votes} {t("CarouselCards.votes")}</div>
</div>
<p className="card-text description-story text-white">{story?.description}</p>
Expand Down
18 changes: 13 additions & 5 deletions frontend/src/components/story-header/icons/Heart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Heart = ({ num, storyId, setData, t }) => {
const [userId, setUserId] = useState()
const [authorized, setAuthorized] = useState(false)
const [heartIcon, setHeartIcon] = useState('text-white')
const [disable, setDisable] = useState(false)

const ChangeIconColor = () => {
setHeartIcon((originalColor) => (originalColor == "text-white" ? "text-danger" : "text-white"));
Expand All @@ -29,17 +30,17 @@ const Heart = ({ num, storyId, setData, t }) => {
const response = await findAccount({ userName: user });
setUserId(response._id);

if(response.message) {
if (response.message) {
setAuthorized(true)
const liked = await getLike('likes', response._id, storyId)
if(liked.message) {
if (liked.message) {
setHeartIcon('text-danger')
}
} else {
setAuthorized(false)
return
}

} catch (error) {
console.log(error);
}
Expand All @@ -50,8 +51,12 @@ const Heart = ({ num, storyId, setData, t }) => {
}, [])

const handleClick = async () => {
if (disable) {
return;
}
setDisable(true)

if(authorized) {
if (authorized) {

if (heartIcon == "text-danger") {
const updated = await updateDocument('stories', { id: storyId, likes: num - 1 })
Expand All @@ -74,6 +79,9 @@ const Heart = ({ num, storyId, setData, t }) => {
} else {
toast.error(`${t("StoryHeader.must_login")}`);
}
setTimeout(() => {
setDisable(false)
}, 2000)
}


Expand All @@ -85,6 +93,6 @@ const Heart = ({ num, storyId, setData, t }) => {
<h6 className="text-white"> {num}<span className="icon-title"> {t("StoryHeader.Likes")}</span></h6>
</span>
);
}
}

export default Heart;
25 changes: 17 additions & 8 deletions frontend/src/components/story-header/icons/Share.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import toast from "react-hot-toast"
const Share = ({t}) => {
const Share = ({ t }) => {
const shareHandler = async () => {
try {
await navigator.share({
title: document.title,
url: window.location.href
});
} catch (error) {
toast.error("could'nt copy the link.")
if (navigator.share) {
try {
await navigator.share({
title: document.title,
url: window.location.href
});
} catch (error) {
toast.error("Couldn't share the link.");
}
} else {
try {
await navigator.clipboard.writeText(window.location.href);
toast.success("Link copied to clipboard!");
} catch (error) {
toast.error("Couldn't copy the link.");
}
}
};

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/story-overview/WriterCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useAccount from '../../hooks/useAccount';
import { useTranslation } from 'react-i18next';
import { Buffer } from 'buffer';

const WriterCard = ({ handleArrowLeftClick, user , backgroundColor}) => {
const WriterCard = ({ handleArrowLeftClick, user, backgroundColor }) => {

const { t } = useTranslation();

Expand Down Expand Up @@ -81,11 +81,11 @@ const WriterCard = ({ handleArrowLeftClick, user , backgroundColor}) => {
<div className="row textf">
<div className="col-4 text-muted mt-2">
<p className="titleFW">{t("StoryOverview.following")}</p>
<h6 className="numberFW">{followingData}</h6>
<h6 className="numberFW">{followersData}</h6>
</div>
<div className="col-4 text-muted mt-2">
<p className="titleFW">{t("StoryOverview.followers")}</p>
<h6 className="numberFW">{followersData}</h6>
<h6 className="numberFW">{followingData}</h6>
</div>
<div className="col-4 text-muted mt-2">
<p className="titleFW">{t("StoryOverview.works")}</p>
Expand Down Expand Up @@ -114,7 +114,7 @@ const WriterCard = ({ handleArrowLeftClick, user , backgroundColor}) => {
{isFollowingAccount ? `${t("StoryOverview.unfollow")}` : `${t("StoryOverview.follow")}`} <i className="bi bi-person-add"></i>
</button>
</>}
<button className="btn btn-social btnfollowandviewprofile" onClick={() => handleViewProfile(user.userName)} style={{ backgroundColor: backgroundColor }}>{t("StoryOverview.view_profile")}</button>
<button className="btn btn-social btnfollowandviewprofile" onClick={() => handleViewProfile(user.userName)} style={{ backgroundColor: backgroundColor }}>{t("StoryOverview.view_profile")}</button>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 8f225f8

Please sign in to comment.