CSR-886: remove superfluous data elements, change date from object to string

This commit is contained in:
Adam Caouette 2023-06-01 10:59:13 -04:00
parent 2f45b92a8d
commit 6a6b37d5e7
2 changed files with 11 additions and 33 deletions

View file

@ -31,8 +31,8 @@
<div class="grid-item caption"><span class="sr-only">Saturday</span>S</div> <div class="grid-item caption"><span class="sr-only">Saturday</span>S</div>
<div <div
v-for="date in month.dates" v-for="date in month.dates"
:key="date.inputValue.dateString" :key="date.inputValue"
:id="date.inputValue.dateString" :id="date.inputValue"
class="grid-item radio-wrapper" class="grid-item radio-wrapper"
:class="[ :class="[
date.dateNum === 1 ? 'first-day-' + month.startDateDayIndex : '', date.dateNum === 1 ? 'first-day-' + month.startDateDayIndex : '',
@ -476,12 +476,6 @@ export default {
"-" + "-" +
forceTwoDigitString(i); forceTwoDigitString(i);
const thisDate = {
year: yearNum,
month: monthIndex,
date: i,
dateString: dateString,
};
if (offset === 0 && i === this.todayDateNum) { if (offset === 0 && i === this.todayDateNum) {
dayClasses += "current-day"; dayClasses += "current-day";
} }
@ -502,11 +496,9 @@ export default {
const dateObject = { const dateObject = {
dateNum: i, dateNum: i,
dayClasses: dayClasses, dayClasses: dayClasses,
inputValue: thisDate, inputValue: dateString,
isSelectable: isSelectable:
this.selectableDatesData.findIndex( this.selectableDatesData.findIndex((date) => date.date === dateString) > -1
(date) => date.dateString === dateString
) > -1
? true ? true
: false, : false,
}; };
@ -555,8 +547,8 @@ export default {
if (monthToShow) { if (monthToShow) {
// make new API call with this month's start and end dates // make new API call with this month's start and end dates
await this.updateSelectableDates( await this.updateSelectableDates(
monthToShow.dates[monthStartDateNum].inputValue.dateString, monthToShow.dates[monthStartDateNum].inputValue,
monthToShow.dates[monthToShow.dates.length - 1].inputValue.dateString monthToShow.dates[monthToShow.dates.length - 1].inputValue
); );
this.isLoading = false; this.isLoading = false;
this.hideSomeDaysForInitialView = false; // if hid days on initial partial view, this will reveal those days this.hideSomeDaysForInitialView = false; // if hid days on initial partial view, this will reveal those days
@ -576,13 +568,13 @@ export default {
); );
moreSelectableDates.days.forEach((selectableDate) => { moreSelectableDates.days.forEach((selectableDate) => {
const index = this.selectableDatesData.findIndex( const index = this.selectableDatesData.findIndex(
(obj) => obj.dateString === selectableDate.dateString (dateObj) => dateObj.date === selectableDate.date
); );
if (index === -1) this.selectableDatesData.push(selectableDate); if (index === -1) this.selectableDatesData.push(selectableDate.date);
this.months.forEach((month) => { this.months.forEach((month) => {
// TODO: avoid checking all calendar date; maybe only ones between monthStart and monthEnd as defined above? // TODO: avoid checking all calendar dates; maybe only ones between monthStart and monthEnd as defined above?
month.dates.forEach((date) => { month.dates.forEach((date) => {
if (date.inputValue.dateString === selectableDate.dateString) { if (date.inputValue === selectableDate.date) {
date["isSelectable"] = true; date["isSelectable"] = true;
} }
}); });
@ -853,7 +845,6 @@ export default {
.btn-link { .btn-link {
font-weight: 500; font-weight: 500;
text-underline-offset: 4px; text-underline-offset: 4px;
box-shadow: none !important; // TODO: FIX THIS
position: absolute; position: absolute;
top: 90%; top: 90%;
} }

View file

@ -107,20 +107,7 @@ const getAvailableDates = async (startDate, endDate, appointmentType, providerNu
); );
} }
const newShopTimeSlots = newTimeSlotsResponse.data; return newTimeSlotsResponse.data;
return convertApiResponse(newShopTimeSlots);
};
const convertApiResponse = (responseData) => {
// DATA CONVERSION
responseData?.days.forEach((date) => {
const dateString = date.date;
date.dateString = dateString;
const dateStringPieces = dateString.split("-");
date.year = Number(dateStringPieces[0]);
date.month = Number(dateStringPieces[1]);
date.date = Number(dateStringPieces[2]);
});
return responseData;
}; };
export default { export default {