Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
TiannaLopes committed Oct 9, 2024
1 parent fc94721 commit b34229a
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions src/components/AppointmentForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,48 @@ export default {
const description = ref('');
const message = ref('');
/**
* Creates an appointment in the Outlook calendar.
* @async
* @function createAppointment
* @returns {Promise<void>} - A promise that resolves when the appointment is created.
*/
const createAppointment = async () => {
if (!props.isAuthenticated) {
message.value = 'Please log in to create an appointment.';
return;
}
/**
* Creates an appointment in the Outlook calendar.
* @async
* @function createAppointment
* @returns {Promise<void>} - A promise that resolves when the appointment is created.
*/
const createAppointment = async () => {
if (!props.isAuthenticated) {
message.value = 'Please log in to create an appointment.';
return;
}
try {
const token = localStorage.getItem('accessToken');
if (!token) {
message.value = 'Access token is missing. Please log in again.';
return;
}
try {
const token = localStorage.getItem('accessToken');
if (!token) {
message.value = 'Access token is missing. Please log in again.';
return;
}
const response = await axios.post('http://localhost:3000/appointments', {
accessToken: token,
title: title.value,
startTime: startTime.value,
endTime: endTime.value,
description: description.value,
});
const response = await axios.post(
'http://localhost:3000/appointments',
{
accessToken: token,
title: title.value,
startTime: startTime.value,
endTime: endTime.value,
description: description.value,
}
);
if (response.status === 201) {
message.value = 'Appointment created successfully!';
title.value = '';
startTime.value = '';
endTime.value = '';
description.value = '';
}
} catch (error) {
console.error('Error creating appointment:', error);
message.value = 'Failed to create appointment. Please try again.';
}
};
if (response.status === 201) {
message.value = 'Appointment created successfully!';
title.value = '';
startTime.value = '';
endTime.value = '';
description.value = '';
}
} catch (error) {
console.error('Error creating appointment:', error);
message.value = 'Failed to create appointment. Please try again.';
}
};
return {
title,
Expand Down

0 comments on commit b34229a

Please sign in to comment.