Skip to content

Commit

Permalink
docs(change documentation): fix the documentation
Browse files Browse the repository at this point in the history
fix the documentation

fix #127
  • Loading branch information
M07am3dM committed Nov 28, 2023
1 parent 6d7e5f3 commit c8a87b9
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 62 deletions.
1 change: 1 addition & 0 deletions public/locales/ar/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"input2": "كلمة السر الجديدة",
"button": "تغير كلمة السر",
"message": "تم تغير كلمة السر بنجاح",
"error": "حدث خطأ أثناء تحديث كلمة المرور",
"wrongPasswordError": "تم إدخال كلمة المرور القديمة بشكل غير صحيح.",
"Loading": " تغيير...",
"authError": "لم يتم تسجيل دخول المستخدم.",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/ar/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"Date": " تاريخ ووقت الموعد :",
"placeholder": "حدد التاريخ والوقت",
"Zone": "وحدة زمنية :",
"text1": "يرجى العلم أن هذا الإجراء سيكلفك تذكرة",
"text2": "بمجرد تأكيد المعالج للموعد!",
"Book": "حجز",
"Unbook": "إلغاء الحجز"
},
Expand Down
1 change: 1 addition & 0 deletions public/locales/ar/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"show": "عرض البطاقات",
"buy": "شراء التذاكر",
"edit": "تعديل",
"editPassword": "تغيير كلمة المرور",
"deleteAccount": "حذف الحساب",
"choose": "اختر ...",
"yes": "نعم",
Expand Down
1 change: 0 additions & 1 deletion public/locales/en/booking.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"step7": {
"header": "Submit Your Appointment",
"paragraph1": "Click Submit if you are sure of all your choices.",
"paragraph2": "Please Be Aware That This Action Will Cost You A Ticket!",
"label1": "Counseling Type:",
"label2": "Marital Status:",
"label3": "First Session:",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"input2": "New password",
"button": "change Password",
"message": "Password updated successfully",
"error": "Error occurs during updating the password",
"wrongPasswordError": "Incorrect old password entered. Please try again.",
"Loading": "Loading...",
"authError": "User is not authenticated.",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"Date": "Appointment Date & Time:",
"placeholder": "Select date and time",
"Zone": "Time Zone:",
"text1": "This Action Will Cost You A Ticket",
"text2": "Once The Appointment Is Confirmed!",
"Book": "Book",
"Unbook": "Unbook"
},
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"female": "Female",
"save": "SAVE",
"edit": "EDIT",
"editPassword": "EDIT PASSWORD",
"deleteAccount": "DELETE ACCOUNT",
"security": "Security",
"payment": "Payment Methods & Tickets",
Expand Down
9 changes: 6 additions & 3 deletions src/components/Dashboards/Links/Therapists.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ const TherapistsMatches = () => {
{`${therapist.bio}`}
</p>
</div>

<div className='lg:flex lg:flex-col lg:gap-y-8 flex flex-col jutsify-center items-center gap-y-8'>
<div className='lg:flex lg:flex-col lg:gap-y-4 flex flex-col jutsify-center items-center gap-y-4'>
<div className='flex flex-col gap-y-2'>
<label className='text-Gray font-atkinson'>
{t("dashboard:therapists.Date")}
Expand Down Expand Up @@ -336,7 +335,11 @@ const TherapistsMatches = () => {
))}
</select>
</div>

<p className='text-center'>
{t("dashboard:therapists.text1")}
<br />
{t("dashboard:therapists.text2")}
</p>
<button
onClick={() =>
handleSubmitAppointment(therapist)
Expand Down
3 changes: 0 additions & 3 deletions src/components/MutiStepBookingForm/BookingStep7.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ const BookingStep7 = ({
value={formData.specification}
/>
</div>
{/* <p className='lg:text-lg font-atkinson text-gray-900'>
{t("step7.paragraph2")}
</p> */}
<div className='my-2 flex items-center'>
<input
id='agreeToTerms'
Expand Down
25 changes: 25 additions & 0 deletions src/context/AuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,33 @@ export function AppWrapper({ children }) {
}
};

const fetchConfirmedAppointments = async () => {
try {
const appointmentsQuery = query(
collection(db, "appointments"),
where("uid", "==", user.uid),
where("appointmentStatus", "==", "ready")
);
const appointmentsSnapshot = await getDocs(appointmentsQuery);

// Iterate through the confirmed appointments and decrement tickets
appointmentsSnapshot.forEach(async (appointmentDoc) => {
const appointmentData = appointmentDoc.data();
const ticketId = appointmentData.ticketId; // Assuming you have a ticketId field in your appointments
const userDocRef = doc(collection(db, "tickets"), user.uid);
await updateDoc(userDocRef, {
[`tickets.${ticketId}.quantity`]:
FieldValue.increment(-1),
});
});
} catch (error) {
console.error("Error fetching confirmed appointments:", error);
}
};

if (user) {
fetchTickets();
fetchConfirmedAppointments();
}
}, [user]);

Expand Down
50 changes: 6 additions & 44 deletions src/pages/edit-password/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from "react";
import {
getAuth,
updatePassword,
reauthenticateWithCredential,
EmailAuthProvider,
Expand All @@ -9,8 +8,7 @@ import { auth } from "@/util/firebase";
import Layout from "@/layout/Layout";
import Input from "@/components/elements/Input";
import Button from "@/components/elements/Button";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { toast } from "react-toastify";
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -49,15 +47,7 @@ function ChangePassword() {

if (!user) {
toast.error(t("password.authError"), {
position: "top-center",
autoClose: 3000,
hideProgressBar: true,
newestOnTop: false,
closeOnClick: true,
rtl: false,
pauseOnFocusLoss: true,
draggable: true,
pauseOnHover: true,
position: toast.POSITION.TOP_CENTER,
});
setLoading(false);

Expand All @@ -78,18 +68,10 @@ function ChangePassword() {

// Show success message
toast.success(t("password.message"), {
position: "top-center",
autoClose: 3000,
hideProgressBar: true,
newestOnTop: false,
closeOnClick: true,
rtl: false,
pauseOnFocusLoss: true,
draggable: true,
pauseOnHover: true,
position: toast.POSITION.TOP_CENTER,
onClose: () => {
// Redirect to the home page after the toast is closed
router.push("/");
router.push("/profile");
},
});
} catch (error) {
Expand All @@ -103,15 +85,7 @@ function ChangePassword() {

// Show error toast
toast.error(message, {
position: "top-center",
autoClose: 3000,
hideProgressBar: true,
newestOnTop: false,
closeOnClick: true,
rtl: false,
pauseOnFocusLoss: true,
draggable: true,
pauseOnHover: true,
position: toast.POSITION.TOP_CENTER,
});
}
};
Expand Down Expand Up @@ -163,11 +137,7 @@ function ChangePassword() {
</div>
)}

<button
type='submit'
//disabled={loading}
onClick={handleSubmit}
>
<button type='submit' onClick={handleSubmit}>
<Button
transition={false}
buttonText={
Expand All @@ -177,17 +147,9 @@ function ChangePassword() {
}
/>
</button>

{/* <button type='submit'>
<Button
transition={false}
buttonText={t("password.button")}
/>
</button> */}
</div>
</form>
</div>
<ToastContainer />
</Layout>
);
}
Expand Down
28 changes: 19 additions & 9 deletions src/pages/profile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { db } from "@/util/firebase";

const User = ({ t }) => {
const router = useRouter();
const language = router.locale;
const searchParams = useSearchParams();
const { totalTickets, cards } = UserAuth();

Expand Down Expand Up @@ -358,7 +359,7 @@ const User = ({ t }) => {
onChange={onChange}
/>
</div>
<div className='flex flex-row justify-center gap-4 my-14 lg:ml-8 lg:rtl:mr-20 md:mr-4 md:ml-4'>
<div className='flex flex-row justify-center text-center gap-4 my-14 lg:ml-8 lg:rtl:mr-20 md:mr-4 md:ml-4'>
<button type='submit'>
<Button
buttonText={t("users:userProfile.save")}
Expand All @@ -368,14 +369,23 @@ const User = ({ t }) => {
type='submit'
/>
</button>

<Button
buttonText={t("users:userProfile.edit")}
disabled={edit}
transition={false}
color='teal'
clickFunction={enableEdit}
/>
<button>
<Button
buttonText={t("users:userProfile.edit")}
disabled={edit}
transition={false}
color='teal'
clickFunction={enableEdit}
/>
</button>
<Link href='./edit-password'>
<Button
rotate={language == "en" ? false : true}
buttonText={t(
"users:userProfile.editPassword"
)}
/>
</Link>
<button onClick={onDeleteAccount}>
<Button
buttonText={t(
Expand Down
18 changes: 16 additions & 2 deletions src/pages/therapists/profile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import ProfileImage from "@/components/ProfileImage";
import { useAuth } from "@/context/AuthContext";
import Layout from "@/layout/Layout";
import { db } from "@/util/firebase";
import Link from "next/link";

const Profile = ({ t }) => {
const router = useRouter();
const language = router.locale;
const searchParams = useSearchParams();

/** state */
Expand Down Expand Up @@ -289,7 +291,7 @@ const Profile = ({ t }) => {
</p>
</div>
</div>
<div className='flex flex-row justify-center gap-5 my-14 lg:ml-8 lg:rtl:mr-20'>
<div className='flex flex-row justify-center text-center gap-5 my-14 lg:ml-8 lg:rtl:mr-20'>
<button type='submit'>
<Button
buttonText={t(
Expand All @@ -308,6 +310,14 @@ const Profile = ({ t }) => {
color='teal'
clickFunction={enableEdit}
/>
<Link href='../edit-password'>
<Button
rotate={language == "en" ? false : true}
buttonText={t(
"users:userProfile.editPassword"
)}
/>
</Link>
</div>
</form>
</div>
Expand All @@ -322,7 +332,11 @@ export default withTranslation("therapists")(Profile);
export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale, ["common", "therapists"])),
...(await serverSideTranslations(locale, [
"common",
"therapists",
"users",
])),
// Will be passed to the page component as props.
},
};
Expand Down

0 comments on commit c8a87b9

Please sign in to comment.