Skip to content

Commit

Permalink
Display all fields for Appointment
Browse files Browse the repository at this point in the history
  • Loading branch information
ciukstar committed Sep 26, 2023
1 parent da1a3a4 commit 38e9c67
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 51 deletions.
9 changes: 9 additions & 0 deletions messages/en.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Meeting: Meeting
MeetingTime: Meeting time
MeetingLocation: Meeting location
Nullify: Nullify
Reschedule: Reschedule
Calendar: Calendar
BookingCalendar: Booking calendar
Requests: Requests
BookingRequests: Booking requests
NoOffersYet: There are no offers yet
ChoosePhoto: Choose photo
ChooseImage: Choose image
Expand Down
9 changes: 9 additions & 0 deletions messages/fr.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Meeting: Réunion
MeetingTime: Heure de rendez-vous
MeetingLocation: Lieu de la rencontre
Nullify: Annuler
Reschedule: Reprogrammer
Calendar: Calendrier
BookingCalendar: Calendrier des réservations
Requests: Demandes
BookingRequests: Demandes de réservation
NoOffersYet: Il n'y a pas encore d'offres.
ChoosePhoto: Choisir photo
ChooseImage: Choisir image
Expand Down
9 changes: 9 additions & 0 deletions messages/ro.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Meeting: Întâlnire
MeetingTime: Ora întâlnirii
MeetingLocation: Locul de întâlnire
Nullify: Anulează
Reschedule: Reprogramează
Calendar: Calendar
BookingCalendar: Calendar de rezervari
Requests: Solicitări
BookingRequests: Cereri de rezervare
NoOffersYet: Nu există încă oferte
ChoosePhoto: Alege foto
ChooseImage: Alege imagine
Expand Down
9 changes: 9 additions & 0 deletions messages/ru.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Meeting: Встреча
MeetingTime: Время встречи
MeetingLocation: Место встречи
Nullify: Аннулировать
Reschedule: Перенести
Calendar: Календарь
BookingCalendar: Календарь бронирования
Requests: Запросы
BookingRequests: Запросы на бронирование
NoOffersYet: Предложений пока нет
ChoosePhoto: Выбрать фото
ChooseImage: Выбрать изображение
Expand Down
25 changes: 19 additions & 6 deletions src/Handler/Appointments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import Text.Hamlet (Html)
import Text.Shakespeare.I18N (renderMessage)

import Yesod.Auth (maybeAuth, Route (LoginR, LogoutR))
import Yesod.Core (Yesod(defaultLayout), getMessages, getYesod, languages)
import Yesod.Core
( Yesod(defaultLayout), getMessages, getYesod, languages
, preEscapedToMarkup
)
import Yesod.Core.Handler (setUltDestCurrent)
import Yesod.Core.Widget (setTitleI)
import Yesod.Form.Fields (unTextarea)
import Yesod.Persist (Entity (Entity), YesodPersist(runDB))
import Settings (widgetFile)

Expand All @@ -35,27 +39,36 @@ import Foundation
, AppMessage
( MsgMyAppointments, MsgLogin, MsgLogout, MsgPhoto
, MsgLoginToSeeYourAppointments, MsgNoAppointmentsYet
, MsgBookAppointment, MsgAppointment, MsgCancelAppointment
, MsgRescheduleAppointment, MsgSymbolHour, MsgSymbolMinute
, MsgThumbnail
, MsgBookAppointment, MsgAppointment, MsgDuration
, MsgSymbolHour, MsgSymbolMinute
, MsgService, MsgReschedule, MsgCancel
, MsgMeeting, MsgMeetingTime, MsgMeetingLocation
)
)

import Model
( BookId, Book(Book), Offer (Offer), Service (Service), Role (Role)
, Staff (Staff), Thumbnail (Thumbnail), User (User)
, EntityField
( BookOffer, OfferId, BookUser, BookId, OfferService, ServiceId
, BookDay, BookTime, BookRole, RoleId, RoleStaff, StaffId, ThumbnailService
)
, Staff (Staff), Thumbnail (Thumbnail)
, ContentsSection
), Contents (Contents)
)

import Menu (menu)
import Handler.Contacts (section)


getAppointmentR :: BookId -> Handler Html
getAppointmentR bid = do
app <- getYesod
langs <- languages
user <- maybeAuth
location <- runDB $ selectOne $ do
x <- from $ table @Contents
where_ $ x ^. ContentsSection ==. val section
return x
book <- runDB $ selectOne $ do
x :& o :& s :& t :& r :& e <- from $ table @Book
`innerJoin` table @Offer `on` (\(x :& o) -> x ^. BookOffer ==. o ^. OfferId)
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/Contacts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Handler.Contacts (getContactR) where
module Handler.Contacts (getContactR, section) where

import Text.Hamlet (Html)
import Yesod.Auth (maybeAuth, Route (LoginR))
Expand Down
2 changes: 1 addition & 1 deletion src/Menu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
( MsgSourceCode, MsgDocumentation, MsgBrand, MsgContactUs
, MsgAboutUs, MsgMyAppointments, MsgServices, MsgBookAppointment
, MsgWelcome, MsgSalon, MsgUsers, MsgContact, MsgStaff, MsgData
, MsgResources
, MsgResources, MsgRequests, MsgCalendar
)
)

Expand Down
4 changes: 3 additions & 1 deletion templates/appointments/appointment.cassius
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

main
margin-right: 1rem
margin-left: 1rem
margin-left: 1rem
section.mdc-card-wrapper__text-section
margin: 0 1rem
159 changes: 117 additions & 42 deletions templates/appointments/appointment.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,121 @@
<i.material-symbols-outlined>arrow_back
<span.mdc-top-app-bar__title.mdc-theme--text-primary-on-light>
_{MsgAppointment}

<main.mdc-top-app-bar--fixed-adjust>
$maybe (Entity _ (Book _ _ _ date time _ _),Entity _ (Offer _ oname price pref suff _),Entity sid (Service sname _ _ _ _ _),thumbnail,role,staff) <- book
<p #appointmentFullLongTime>
#{show date} #{show time}
<p>
<figure>
<img src=@{ServiceThumbnailR sid} height=56 width=56 alt=_{MsgThumbnail} loading=lazy>
$maybe Entity _ (Thumbnail _ _ _ attrib) <- thumbnail
$maybe attribution <- attrib
^{attribution}
<figcaption>
#{sname}
<p>
#{oname}:
$maybe prefix <- pref
#{prefix}
#{show price}
$maybe _ <- pref
$nothing
$maybe suffix <- suff
#{suffix}

$maybe Entity eid (Staff ename _ _ _ _ _) <- staff
<p>
<figure>
<img src=@{AdminR $ AdmStaffPhotoR eid} width=56 height=56 alt=_{MsgPhoto} loading=lazy>
<figcation>
#{ename}
$maybe Entity _ (Role _ _ rname _) <- role
(#{rname})


<p>
<button.mdc-button.mdc-button--raised type=button>
<span.mdc-button__ripple>
<span.mdc-button__focus-ring>
<span.mdc-button__label>_{MsgRescheduleAppointment}
<p>
<button.mdc-button.mdc-button--raised type=button>
<span.mdc-button__ripple>
<span.mdc-button__focus-ring>
<span.mdc-button__label>_{MsgCancelAppointment}
$maybe (Entity _ (Book _ _ _ date time _ _),Entity _ (Offer _ oname price pref suff _),Entity sid (Service sname _ _ dur _ _),thumbnail,role,staff) <- book

<div.mdc-card>
<div.mdc-card__primary-action>
<div.mdc-card__media.mdc-card__media--16-9 style="background-image:url('@{ServiceThumbnailR sid}')">
$maybe Entity _ (Thumbnail _ _ _ attrib) <- thumbnail
$maybe attribution <- attrib
<div.mdc-card__media-content style="text-align:end;font-size:0.5rem;position:relative;bottom:0;margin-right:4px">
^{attribution}
<div.mdc-card__ripple>

<details.mdc-list.mdc-card-wrapper__text-section open
ontoggle="this.querySelector('summary i.expand').textContent = this.open ? 'expand_less' : 'expand_more'">
<summary.mdc-list-item.mdc-list-item--with-leading-icon.mdc-list-item--with-one-line.mdc-list-item--with-trailing-icon>
<span.mdc-list-item__ripple>
<span.mdc-list-item__start>
<i.material-symbols-outlined>volunteer_activism
<span.mdc-list-item__content>
<div.mdc-list-item__primary-text style="color:var(--mdc-theme-text-hint-on-light)">
_{MsgService}
<span.mdc-list-item__end>
<i.expand.material-symbols-outlined>expand_less
<section.mdc-card-wrapper__text-section>
<div>#{sname}
<div>
<small>
#{oname}:&nbsp;
$maybe prefix <- pref
#{prefix}
#{show price}
$maybe _ <- pref
$nothing
$maybe suffix <- suff
#{suffix}
$maybe duration <- dur
$with translate <- renderMessage app langs
$with pat <- intercalate "" ["%H",translate MsgSymbolHour," %M",translate MsgSymbolMinute]
$with duration <- formatTime defaultTimeLocale (unpack pat) duration
<small>
_{MsgDuration}:&nbsp;#{duration}

<details.mdc-list.mdc-card-wrapper__text-section open
ontoggle="this.querySelector('summary i.expand').textContent = this.open ? 'expand_less' : 'expand_more'">
<summary.mdc-list-item.mdc-list-item--with-leading-icon.mdc-list-item--with-one-line.mdc-list-item--with-trailing-icon>
<span.mdc-list-item__ripple>
<span.mdc-list-item__start>
<i.material-symbols-outlined>schedule
<span.mdc-list-item__content>
<div.mdc-list-item__primary-text style="color:var(--mdc-theme-text-hint-on-light)">
_{MsgMeetingTime}
<span.mdc-list-item__end>
<i.expand.material-symbols-outlined>expand_less
<section.mdc-card-wrapper__text-section #appointmentFullLongTime>
#{show date} #{show time}

<details.mdc-list.mdc-card-wrapper__text-section
ontoggle="this.querySelector('summary i.expand').textContent = this.open ? 'expand_less' : 'expand_more'">
<summary.mdc-list-item.mdc-list-item--with-leading-icon.mdc-list-item--with-one-line.mdc-list-item--with-trailing-icon>
<span.mdc-list-item__ripple>
<span.mdc-list-item__start>
<i.material-symbols-outlined>emoji_people
<span.mdc-list-item__content>
<div.mdc-list-item__primary-text style="color:var(--mdc-theme-text-hint-on-light)">
_{MsgMeeting}
<span.mdc-list-item__end>
<i.expand.material-symbols-outlined>expand_more
$maybe Entity eid (Staff ename _ _ _ _ _) <- staff
<div style="display:flex;flex-direction:row;align-items:flex-start;justify-content:space-around">
$maybe Entity uid (User uname _ _ fname _) <- user
<figure style="margin:0;padding:0;text-align:center">
<img src=@{AccountPhotoR uid} width=56 height=56 style="clip-path:circle(50%)" alt=_{MsgPhoto}
onerror="this.src = '@{PhotoPlaceholderR}'">
<figcaption>
<small>
$maybe fname <- fname
#{fname}
$nothing
#{uname}

<i.material-symbols-outlined style="align-self:center;color:var(--mdc-theme-text-icon-on-background)">
handshake

<figure style="margin:0;padding:0;text-align:center">
<img src=@{AdminR $ AdmStaffPhotoR eid} width=56 height=56 alt=_{MsgPhoto} loading=lazy
style="clip-path:circle(50%)">
<figcaption>
<small>#{ename}
$maybe Entity _ (Role _ _ rname _) <- role
<div>
<small>(#{rname})

$maybe Entity _ (Contents _ content) <- location
<details.mdc-list.mdc-card-wrapper__text-section
ontoggle="this.querySelector('summary i.expand').textContent = this.open ? 'expand_less' : 'expand_more'">
<summary.mdc-list-item.mdc-list-item--with-leading-icon.mdc-list-item--with-one-line.mdc-list-item--with-trailing-icon>
<span.mdc-list-item__ripple>
<span.mdc-list-item__start>
<i.material-symbols-outlined>location_on
<span.mdc-list-item__content>
<div.mdc-list-item__primary-text style="color:var(--mdc-theme-text-hint-on-light)">
_{MsgMeetingLocation}
<span.mdc-list-item__end>
<i.expand.material-symbols-outlined>expand_more
#{preEscapedToMarkup $ unTextarea content}

<div.mdc-card__actions>
<div.mdc-card__action-buttons>
<button.mdc-card__action.mdc-card__action--button.mdc-button.mdc-button--unelevated type=button>
<span.mdc-button__ripple>
<span.mdc-button__focus-ring>
<span.mdc-button__label>_{MsgReschedule}

<button.mdc-card__action.mdc-card__action--button.mdc-button.mdc-button--outlined type=button>
<span.mdc-button__ripple>
<span.mdc-button__focus-ring>
<span.mdc-button__label>_{MsgCancel}
22 changes: 22 additions & 0 deletions templates/menu.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,63 @@
<div.mdc-deprecated-list-group>
<hr.mdc-deprecated-list-divider role=separator>
<nav.mdc-deprecated-list>

<a.mdc-deprecated-list-item href=@{HomeR}
:Just HomeR /= curr:tabindex=-1
:Just HomeR == curr:tabindex=0
:Just HomeR == curr:.mdc-deprecated-list-item--activated>
<span.mdc-deprecated-list-item__ripple>
<i.mdc-deprecated-list-item__graphic.material-symbols-outlined>home
<span.mdc-deprecated-list-item__text>_{MsgWelcome}

<a.mdc-deprecated-list-item href=@{ServicesR}
:Just ServicesR /= curr:tabindex=-1
:Just ServicesR == curr:tabindex=0
:Just ServicesR == curr:.mdc-deprecated-list-item--activated>
<span.mdc-deprecated-list-item__ripple>
<i.mdc-deprecated-list-item__graphic.material-symbols-outlined>volunteer_activism
<span.mdc-deprecated-list-item__text>_{MsgServices}

<a.mdc-deprecated-list-item href=@{BookOffersR}
:Just BookOffersR /= curr:tabindex=-1
:Just BookOffersR == curr:tabindex=0
:Just BookOffersR == curr:.mdc-deprecated-list-item--activated>
<span.mdc-deprecated-list-item__ripple>
<i.mdc-deprecated-list-item__graphic.material-symbols-outlined>book_online
<span.mdc-deprecated-list-item__text>_{MsgBookAppointment}

<a.mdc-deprecated-list-item href=@{AppointmentsR}
:Just AppointmentsR /= curr:tabindex=-1
:Just AppointmentsR == curr:tabindex=0
:Just AppointmentsR == curr:.mdc-deprecated-list-item--activated>
<span.mdc-deprecated-list-item__ripple>
<i.mdc-deprecated-list-item__graphic.material-symbols-outlined>pending_actions
<span.mdc-deprecated-list-item__text>_{MsgMyAppointments}

<a.mdc-deprecated-list-item href=#
:False:tabindex=-1
:False:tabindex=0
:False:.mdc-deprecated-list-item--activated>
<span.mdc-deprecated-list-item__ripple>
<i.mdc-deprecated-list-item__graphic.material-symbols-outlined>event_available
<span.mdc-deprecated-list-item__text>_{MsgRequests}

<a.mdc-deprecated-list-item href=#
:False:tabindex=-1
:False:tabindex=0
:False:.mdc-deprecated-list-item--activated>
<span.mdc-deprecated-list-item__ripple>
<i.mdc-deprecated-list-item__graphic.material-symbols-outlined>calendar_month
<span.mdc-deprecated-list-item__text>_{MsgCalendar}

<a.mdc-deprecated-list-item href=@{AboutUsR}
:Just AboutUsR /= curr:tabindex=-1
:Just AboutUsR == curr:tabindex=0
:Just AboutUsR == curr:.mdc-deprecated-list-item--activated>
<span.mdc-deprecated-list-item__ripple>
<i.mdc-deprecated-list-item__graphic.material-symbols-outlined>info
<span.mdc-deprecated-list-item__text>_{MsgAboutUs}

<a.mdc-deprecated-list-item href=@{ContactR}
:Just ContactR /= curr:tabindex=-1
:Just ContactR == curr:tabindex=0
Expand Down

0 comments on commit 38e9c67

Please sign in to comment.