Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Michal Čížek
flea-market-manager
Commits
ddede32e
Commit
ddede32e
authored
May 18, 2022
by
Lucia Lopuchova
Committed by
cizek
May 18, 2022
Browse files
Show reservations in my reservation tab
parent
f62b4137
Changes
5
Show whitespace changes
Inline
Side-by-side
frontend/src/models/stand-reservation.ts
0 → 100644
View file @
ddede32e
export
type
StandReservation
=
{
standId
:
string
;
itemCategories
:
string
[];
standTypeName
:
string
;
eventName
:
string
;
startDate
:
string
;
}
\ No newline at end of file
frontend/src/modules/stand-reservation/reservation-columns.ts
0 → 100644
View file @
ddede32e
import
{
TableColumn
}
from
"
components/table/types
"
;
import
{
StandReservation
}
from
"
../../models/stand-reservation
"
;
export
const
reservationColumns
:
TableColumn
<
StandReservation
>
[]
=
[
{
key
:
"
standTypeName
"
,
label
:
"
Stand Type
"
,
render
:
({
standTypeName
})
=>
standTypeName
,
},
{
key
:
"
itemCategories
"
,
label
:
"
Item Categories
"
,
render
:
({
itemCategories
})
=>
itemCategories
.
join
(
"
,
"
)
},
{
key
:
"
eventName
"
,
label
:
"
Event
"
,
render
:
({
eventName
})
=>
eventName
},
{
key
:
"
startDate
"
,
label
:
"
Start Date
"
,
render
:
({
startDate
})
=>
startDate
}
];
\ No newline at end of file
frontend/src/modules/stand-reservation/reservation-table.tsx
0 → 100644
View file @
ddede32e
import
{
useNotification
}
from
"
../../context/notification/notification-context
"
;
import
{
useQuery
}
from
"
react-query
"
;
import
{
getUserReservations
}
from
"
./stand-reservation-api
"
;
import
{
Container
}
from
"
@mantine/core
"
;
import
{
Table
}
from
"
components/table/table
"
;
import
{
reservationColumns
}
from
"
./reservation-columns
"
;
interface
Props
{
userId
:
string
;
}
export
const
ReservationTable
=
({
userId
}:
Props
)
=>
{
const
{
showNotification
}
=
useNotification
();
const
{
data
,
isLoading
}
=
useQuery
([
"
userId
"
,
userId
],
()
=>
getUserReservations
(
userId
),
{
onError
:
()
=>
{
showNotification
({
content
:
"
Reservations failed to load
"
,
variant
:
"
error
"
,
});
},
});
return
<
Container
sx
=
{
{
margin
:
"
2rem auto
"
}
}
>
<
Table
title
=
"My reservations"
columns
=
{
reservationColumns
}
rows
=
{
data
}
isLoading
=
{
isLoading
}
/>
</
Container
>
}
\ No newline at end of file
frontend/src/modules/stand-reservation/stand-reservation-api.ts
View file @
ddede32e
...
...
@@ -13,4 +13,4 @@ export const putReservation = ( args: {marketEventId: string, values: Reservatio
axios
.
put
(
`
${
apiUrl
}
/market-events/
${
args
.
marketEventId
}
/reserve-stand`
,
args
.
values
);
export
const
getUserReservations
=
async
(
userId
:
string
)
=>
axios
.
get
(
`
${
apiUrl
}
/list/user/
${
userId
}
`
).
then
((
res
)
=>
res
.
data
)
axios
.
get
(
`
${
apiUrl
}
/
stands/
list/user/
${
userId
}
`
).
then
((
res
)
=>
res
.
data
)
frontend/src/modules/stand-reservation/user-reservations.tsx
View file @
ddede32e
import
{
useAuth
}
from
"
../../context/auth/auth-context
"
;
import
{
NoReservations
}
from
"
./no-reservations
"
;
import
{
ReservationTable
}
from
"
./reservation-table
"
;
export
const
UserReservations
=
()
=>
{
const
{
user
}
=
useAuth
();
if
(
user
===
undefined
||
user
.
userRole
!==
"
SELLER
"
)
return
<
NoReservations
/>
else
return
<
><
/>
else
return
<
ReservationTable
userId
=
{
user
.
id
}
/>
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment