Skip to content

Commit

Permalink
complete get reversed days in month
Browse files Browse the repository at this point in the history
  • Loading branch information
ErfiDev committed Dec 10, 2021
1 parent 4f6d4cb commit 92a9cbe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,14 @@ func (r Repository) AdminReservationCelendar(res http.ResponseWriter, req *http.
return
}

data["reservations"] = getResByMonth
timeBetweens := utils.ReturnBetweenDates(getResByMonth)
toHumanTimeSlice := []string{}
for _, value := range timeBetweens {
humanTime := value.Format("02")
toHumanTimeSlice = append(toHumanTimeSlice, humanTime)
}
removeDuplicate := utils.DeleteDuplicateValues(toHumanTimeSlice)
data["times"] = removeDuplicate

utils.RenderTemplate(res, req, "admin-res-celendar.page.gohtml", &models.TmpData{
StringMap: stringMap,
Expand Down Expand Up @@ -749,7 +756,6 @@ func (r Repository) AdminReservationCelendar(res http.ResponseWriter, req *http.
return
}

data["reservations"] = getResByMonth
timeBetweens := utils.ReturnBetweenDates(getResByMonth)
toHumanTimeSlice := []string{}
for _, value := range timeBetweens {
Expand Down
10 changes: 5 additions & 5 deletions views/admin-res-celendar.page.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

</div>

{{range $index , $value := index .Data "reservations"}}
{{$value.FirstName}}
{{end}}

{{range $index , $value := index .Data "times"}}
{{$value}}
{{end}}
Expand All @@ -33,7 +29,11 @@
for (let i = 1; i < daysInMonth+1; i++) {
let child = document.createElement("div");
child.classList.add("celendar-child");
child.innerHTML = i;
if (i < 10) {
child.innerHTML = `0${i}`;
} else {
child.innerHTML = i;
}
parentElm.appendChild(child);
}
}
Expand Down

0 comments on commit 92a9cbe

Please sign in to comment.