Skip to content

Commit

Permalink
Merge branch 'develop' into 127-fix-bugs-messages-and-alerts-when-the…
Browse files Browse the repository at this point in the history
…-user-log-in-and-make-adjustments
  • Loading branch information
M07am3dM authored Nov 28, 2023
2 parents c8a87b9 + 103d81b commit 77ce0df
Show file tree
Hide file tree
Showing 29 changed files with 1,236 additions and 789 deletions.
Binary file modified public/Images/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/Images/17.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/Images/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/Images/30.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/Images/Contact.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/Images/therapist.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion public/locales/ar/blog.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"reaction_saved": "تمّ إضافة تفاعلك بنجاح",
"comment_added": "تمّ إضافة تعليقك بنجاح",
"required": "هذا الحقل مطلوب",
"related_posts": "مقالات مقترحة"
"related_posts": "مقالات مقترحة",
"recent": "أحدث مقالاتنا",
"recent_blogs_paragraph": "استكشف أحدث الأفكار في مجال الصحة العقلية من خلال أحدث مقالاتنا. من استراتيجيات التعامل مع القلق إلى نصائح لتعزيز التّأقلم, تتعمّق مدوّنتنا في تعقيدات الصّحة العقليّة. ابق على اطلاع وتمكين بينما نتنقل في المشهد المتطوّر للصّحة العقلية، ونقدّم وجهات نظر قيّمة ونصائح عمليّة ."
}
5 changes: 3 additions & 2 deletions public/locales/ar/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"birthdate": "تاريخ الميلاد",
"login": "دخول",
"signup": "تسجيل",
"or": "أو"
"or": "أو",
"error": "البريد الاليكتروني قيد الاستخدام"
},
"signupthank": {
"thankyou": "شكراً لك",
Expand Down Expand Up @@ -134,7 +135,7 @@
"noCardsMessage": "ليس لديك أي بطاقات محفوظة، انقر فوق الزر أدناه لإضافة بطاقة جديدة"
},
"team": {
"title": "نحن فريق المطورين ، نتشرف بلقائك!!"
"title": "تعرّف على فريق المطوّرين"
},
"password": {
"input1": "كلمة السر القديمة",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/ar/login.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"email_in_use": "البريد الإلكتروني قيد الاستخدام بالفعل، حاول تسجيل الدخول",
"account_created": "تم إنشاء الحساب بنجاح.. تم تسجيل دخولك",
"invalid": "الرجاء التّحقق من معلومات تسجيل الدخول"
}
4 changes: 3 additions & 1 deletion public/locales/en/blog.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"comment_added": "Your comment was added successfully",
"reaction_saved": "Your reaction was saved successfully",
"required": "This field is required",
"related_posts": "Suggested Articles"
"related_posts": "Suggested Articles",
"recent": "Our Most Recent Articles",
"recent_blogs_paragraph": "Explore the latest insights in mental health with our most recent articles. From strategies to cope with anxiety to tips for fostering resilience, our blog delves into the intricacies of mental well-being. Stay informed and empowered as we navigate the evolving landscape of mental health, providing valuable perspectives and practical advice for a healthier mind."
}
5 changes: 3 additions & 2 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"birthdate": "Birth Date",
"login": "Log in",
"signup": "Sign up",
"or": "Or"
"or": "Or",
"error": "Email already in use"
},
"signupthank": {
"thankyou": "THANK YOU!",
Expand Down Expand Up @@ -133,7 +134,7 @@
"noCardsMessage": "You have no saved cards, click the button below to add new card"
},
"team": {
"title": "We are a team of developers, Nice to meet you!!"
"title": "Meet the developers team"
},
"password": {
"input1": "Old password ",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/en/login.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"email_in_use": "Email already in use, try logging",
"account_created": "Account created successfully.. logging you in",
"invalid": "Invalid login credentials"
}
68 changes: 60 additions & 8 deletions src/components/Cards/ChatCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const ChatCard = () => {
const [chatMessages, setChatMessages] = useState([]);
const [chatUserId, setChatUserId] = useState([]);
const [chatTherapistid, setChatTherapistid] = useState([]);
const [otherChatUser, setOtherChatUser] = useState({});
const [otherChatUserPhoto, setOtherChatUserPhoto] = useState([]);
const { user } = useAuth();
const bottomEl = useRef(null);

Expand Down Expand Up @@ -109,6 +111,56 @@ const ChatCard = () => {
fetchChat();
}, []);

////////////////////////////////////////////
const test = async (isTherapist) => {
try {
let otherUser;
let documentName;
if (isTherapist) {
otherUser = chatUserId;
documentName = "users";
} else {
otherUser = chatTherapistid;
documentName = "therapists";
}

const userInformationCollection = collection(db, documentName);
const userInformationQuery = query(
userInformationCollection,
where("uid", "==", otherUser)
);

const querySnapshot = await getDocs(userInformationQuery);
const userInformations = querySnapshot.docs.map((doc) => ({
...doc.data(),
}));

return userInformations; // Return the result
} catch (error) {
console.error("Error fetching userinfo:", error);
}
};

useEffect(() => {
const testuser = async () => {
try {
const isTherapist = user.isTherapist;
const result = await test(isTherapist);

result[0].fullname
? setOtherChatUser(result[0].fullname)
: setOtherChatUser(
result[0].firstname + " " + result[0].lastname
);
setOtherChatUserPhoto(result[0].photoURL);
} catch (error) {
console.error("Error fetching userinfo:", error);
}
};

testuser();
}, [chatUserId]);

const submitHandler = async (e) => {
e.preventDefault();
try {
Expand Down Expand Up @@ -177,18 +229,14 @@ const ChatCard = () => {
<div>
{user && appointments ? (
isChatOpen ? (
<div className='fixed flex flex-col bottom-0 sm:right-0 sm:h-[460px] sm:rounded-t-xl sm:mr-5 sm:w-[325px] outline outline-2 outline-gray-100 w-full h-[90%]'>
<div className='fixed flex flex-col bottom-0 sm:right-0 sm:h-[460px] sm:rounded-t-xl sm:mr-5 sm:w-[325px] outline outline-2 outline-gray-100 w-full h-[90%] z-50'>
<div
className='bg-gray-100 border-b flex justify-between p-4 sm:h-[10%] h-[5%] place-items-center rounded-t-md cursor-pointer'
onClick={() => {
setIsChatOpen(false);
}}
>
<p className='font-medium'>
{user.uid === chatUserId
? "Your Therapist"
: "Your Patient"}
</p>
<p className='font-medium'>{otherChatUser}</p>
<svg
className='w-3 h-3'
aria-hidden='true'
Expand Down Expand Up @@ -260,13 +308,17 @@ const ChatCard = () => {
onClick={() => {
setIsChatOpen(true);
}}
className='fixed bottom-0 right-0 w-[60px] h-[60px] rounded-full cursor-pointer mb-6 mr-2'
>
<Image
src='/profile.png'
src={
otherChatUserPhoto
? otherChatUserPhoto
: "/profile.png"
}
width={200}
height={200}
alt='Profile'
className='fixed bottom-0 right-0 w-[60px] h-[60px] rounded-full cursor-pointer mb-6 mr-2 object-cover z-50'
/>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Cards/TeamCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TeamCard = ({ name, role, imgUrl, github, linkedIn }) => (
/>
</div>

<div className='relative pt-48 text-center mt-8'>
<div className='relative pt-48 text-center mt-8 rtl:mt-20'>
{/* Increased margin-top for even more padding */}
<h3 className='text-xl font-bold'>{name}</h3>
<p className='text-gray-600'>{role}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`renders correctly 1`] = `
/>
</div>
<div
className="relative pt-48 text-center mt-8"
className="relative pt-48 text-center mt-8 rtl:mt-20"
>
<h3
className="text-xl font-bold"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/RecentBlogsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const RecentBlogsSection = ({ posts }) => {

const settings = {
dots: true,
arrows: true,
arrows: false,
infinite: true,
slidesToShow: 3,
slidesToScroll: 1,
Expand Down
6 changes: 5 additions & 1 deletion src/components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ export default function Navbar() {
className='text-3xl relative'
onClick={toggleDropdown}
>
<TbUserCircle />
<img
src={user.photoURL}
alt='Profile'
className='w-8 object-cover h-8 rounded-full'
/>
</div>
<div className='absolute outline-none'>
{isDropdownOpen && <UserDropdown />}
Expand Down
35 changes: 4 additions & 31 deletions src/components/Navbar/__test__/__snapshots__/Navbar.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -255,37 +255,10 @@ exports[`renders correctly 1`] = `
className="text-3xl relative"
onClick={[Function]}
>
<svg
fill="none"
height="1em"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
style={
Object {
"color": undefined,
}
}
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M0 0h24v24H0z"
fill="none"
stroke="none"
/>
<path
d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"
/>
<path
d="M12 10m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"
/>
<path
d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855"
/>
</svg>
<img
alt="Profile"
className="w-8 object-cover h-8 rounded-full"
/>
</div>
<div
className="absolute outline-none"
Expand Down
6 changes: 3 additions & 3 deletions src/components/Profile/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default function Input({
isDisabled = false,
}) {
return (
<div className='flex flex-col md:flex-row w-full'>
<div className='flex justify-between items-start'>
<div className='grid grid-cols-1 md:grid-cols-3 w-full'>
<div className='flex justify-between items-start '>
<label
htmlFor={name}
className='md:mb-2 mb-2 w-max text-xl font-medium leading-7 text-gray-900'
Expand All @@ -24,7 +24,7 @@ export default function Input({
</label>
</div>

<div className='flex flex-col w-full'>
<div className='flex flex-col w-full col-span-2 '>
<input
{...register}
type={type}
Expand Down
20 changes: 9 additions & 11 deletions src/components/ProfileImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { storage } from "@/util/firebase";
const ProfileImage = () => {
const { t } = useTranslation("therapists");
const [uploading, setUploading] = useState(false);
const { user, updateProfilePhoto } = useAuth();
const { user, updateProfilePhoto, setUser } = useAuth();
const [ProfileImage, setProfileImage] = useState("");
const handleUpload = async (e) => {
const file = e.target.files[0];
Expand All @@ -24,15 +24,16 @@ const ProfileImage = () => {
const imageRef = ref(storage, `${path}/${imageName}`);
try {
await uploadBytes(imageRef, file);
setUploading(true);
const profileImageRef = ref(storage, `${path}${imageName}`);
const downloadURL = await getDownloadURL(profileImageRef);
updateProfilePhoto(downloadURL);
setProfileImage(downloadURL);
setUser({ ...user, photoURL: downloadURL });
localStorage.setItem(`profile_${user.uid}`, downloadURL);
} catch (error) {
console.log(error);
}
setUploading(true);
const profileImageRef = ref(storage, `${path}${imageName}`);
const downloadURL = await getDownloadURL(profileImageRef);
updateProfilePhoto(downloadURL);
setProfileImage(downloadURL);
localStorage.setItem(`profile_${user.uid}`, downloadURL);
} catch (error) {
console.error(error);
} finally {
Expand All @@ -47,10 +48,7 @@ const ProfileImage = () => {
src={
uploading
? Spinner
: localStorage.getItem(`profile_${user.uid}`) ??
user.photoURL ??
ProfileImage ??
Profile
: user.photoURL ?? ProfileImage ?? Profile
}
alt='profile preview'
width={400}
Expand Down
Loading

0 comments on commit 77ce0df

Please sign in to comment.