Skip to content

Commit

Permalink
Fix 4 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WebMon9099 committed Nov 14, 2024
1 parent ca1e77f commit b032759
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 27 deletions.
8 changes: 0 additions & 8 deletions backend/api/views/appointment.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ def send_invite_email():
avail_htmls.append(start_time + " ~ " + end_time)

if mentee.timezone:
print("timezone", mentee.timezone)
match = re.match(r"UTC([+-]\d{2}):(\d{2})", mentee.timezone)
print("match", match)
if match:
hours_offset = int(match.group(1))
minutes_offset = int(match.group(2))
Expand Down Expand Up @@ -196,9 +194,7 @@ def create_appointment():
date_object = datetime.strptime(time_data.get("start_time"), "%Y-%m-%dT%H:%M:%S%z")
start_time = date_object.strftime(APPT_TIME_FORMAT + " %Z")
if mentee.timezone:
print("timezone", mentee.timezone)
match = re.match(r"UTC([+-]\d{2}):(\d{2})", mentee.timezone)
print("match", match)
if match:
hours_offset = int(match.group(1))
minutes_offset = int(match.group(2))
Expand Down Expand Up @@ -232,9 +228,7 @@ def create_appointment():

if mentor.email_notifications:
if mentor.timezone:
print("timezone", mentor.timezone)
match = re.match(r"UTC([+-]\d{2}):(\d{2})", mentor.timezone)
print("match", match)
if match:
hours_offset = int(match.group(1))
minutes_offset = int(match.group(2))
Expand Down Expand Up @@ -304,9 +298,7 @@ def put_appointment(id):
if mentee.email_notifications:
start_time = appointment.timeslot.start_time.strftime(APPT_TIME_FORMAT + " GMT")
if mentee.timezone:
print("timezone", mentee.timezone)
match = re.match(r"UTC([+-]\d{2}):(\d{2})", mentee.timezone)
print("match", match)
if match:
hours_offset = int(match.group(1))
minutes_offset = int(match.group(2))
Expand Down
17 changes: 12 additions & 5 deletions backend/api/views/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,26 @@ def send_mail_for_event(
):
for recipient in recipients:
if recipient.timezone:
print("timezone", recipient.timezone)
match = re.match(r"UTC([+-]\d{2}):(\d{2})", recipient.timezone)
print("match", match)
if match:
hours_offset = int(match.group(1))
minutes_offset = int(match.group(2))
# Create a timezone with the parsed offset
offset = timezone(timedelta(hours=hours_offset, minutes=minutes_offset))
# Convert the datetime to the target timezone
eventdate.append(
start_datetime.astimezone(offset).strftime("%m-%d-%Y %I:%M%p %Z")

eventdate = (
datetime.strptime(
start_datetime.replace("Z", "+00:00"), "%Y-%m-%dT%H:%M:%S.%f%z"
)
.astimezone(offset)
.strftime("%m-%d-%Y %I:%M%p %Z")
+ " ~ "
+ end_datetime.astimezone(offset).strftime("%m-%d-%Y %I:%M%p %Z")
+ datetime.strptime(
end_datetime.replace("Z", "+00:00"), "%Y-%m-%dT%H:%M:%S.%f%z"
)
.astimezone(offset)
.strftime("%m-%d-%Y %I:%M%p %Z")
)

res, res_msg = send_email(
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/EditProfileModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ function EditProfileModal({ profileData, onSave, role }) {
};

const onSubmit = async (newData) => {
if (!newData.image) {
return;
}
setSaving(true);
if (!newData.edited && !newData.changedImage) {
setOpen(false);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/NavigationHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function NavigationHeader() {
role === ACCOUNT_TYPE.MENTOR ||
role === ACCOUNT_TYPE.PARTNER) && (
<div style={{ color: "red" }}>
Please set time zone in profile page
Please set time zone in <a href="/profile">profile page</a>
</div>
)}
{isMobile && <MenuFoldOutlined onClick={() => dispatch(collapse())} />}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/PartnerProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function PartnerProfileForm({

const onFinish = async (values) => {
setFinishFlag(true);
if (!image) return;
let newData = values;
if (email) {
newData.email = email;
Expand Down
19 changes: 9 additions & 10 deletions frontend/src/components/ProfileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,15 @@ function ProfileContent(props) {
</>
)}
<br />
{props.mentor.timezone && (
<>
<div className="mentor-profile-heading">
<b>{t("common.timezone")}</b>
</div>
<div>{props.mentor.timezone}</div>
<br />
</>
)}
{accountType == ACCOUNT_TYPE.MENTEE && (
<>
{props.mentor.languages && (
Expand Down Expand Up @@ -399,16 +408,6 @@ function ProfileContent(props) {
</div>
</>
)}
{props.mentor.timezone && (
<>
<div className="mentor-profile-heading">
<b>{t("common.timezone")}</b>
</div>
<div>{props.mentor.timezone}</div>
<br />
</>
)}

{props.mentor.video && (
<div className="mentor-profile-heading">
<div className="mentor-profile-heading">
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/pages/BuildProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ function BuildProfile({ location, history, hub_user }) {
}, []);

const onSubmit = async (profileData, image, changedImage) => {
if (!profileData.image) {
messageApi.error({
content: t("common.requiredAvatar"),
duration: 0,
key: "requiredAvatar",
});
return;
}
setLoading(true);
if (!inFirebase && role !== ACCOUNT_TYPE.PARTNER) {
if (userState !== NEW_APPLICATION_STATUS.BUILDPROFILE && !isVerified) {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/pages/MenteeProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ function MenteeProfileForm({

const onFinish = async (values) => {
setFinishFlag(true);
if (!image) return;
let newData = values;
newData.email = email;
newData.role = ACCOUNT_TYPE.MENTEE;
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/pages/MentorProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ function MentorProfileForm({

const onFinish = async (values) => {
setFinishFlag(true);
if (!image) return;
let newData = values;
newData.email = email;
newData.role = ACCOUNT_TYPE.MENTOR;
Expand Down

0 comments on commit b032759

Please sign in to comment.