Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Seat-Booking
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Madhankumar
Seat-Booking
Commits
17e1bb4e
Commit
17e1bb4e
authored
Oct 03, 2023
by
Madhankumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix on confirmation
parent
e8d7fd51
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
38 deletions
+50
-38
db.json
db.json
+3
-5
confirmation.module.css
...components/top-level/confirmation/confirmation.module.css
+1
-1
index.js
src/components/top-level/confirmation/index.js
+2
-8
index.js
src/components/top-level/seat-layout/index.js
+4
-10
confirmation.js
src/pages/confirmation.js
+14
-1
seat-layout.js
src/pages/seat-layout.js
+16
-13
seed.js
src/pages/seed.js
+10
-0
No files found.
db.json
View file @
17e1bb4e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"users"
:
[
"users"
:
[
{
{
"mobile"
:
"12345678"
,
"mobile"
:
"12345678"
,
"password"
:
"
test
"
,
"password"
:
"
password
"
,
"id"
:
1
,
"id"
:
1
,
"isLogged"
:
true
"isLogged"
:
true
}
}
...
@@ -11,10 +11,8 @@
...
@@ -11,10 +11,8 @@
{
{
"userId"
:
1
,
"userId"
:
1
,
"seats"
:
[
"seats"
:
[
"C2"
,
"D1"
,
"C3"
,
"D4"
"C4"
,
"C1"
],
],
"id"
:
1
"id"
:
1
}
}
...
...
src/components/top-level/confirmation/confirmation.module.css
View file @
17e1bb4e
.confirmation
{
.confirmation
{
text-align
:
center
;
text-align
:
center
;
padding
:
2rem
;
padding
:
2rem
;
width
:
20
em
;
margin
:
2r
em
;
}
}
.confirmation
img
{
.confirmation
img
{
...
...
src/components/top-level/confirmation/index.js
View file @
17e1bb4e
...
@@ -2,14 +2,8 @@ import Layout from "../../Base/layout";
...
@@ -2,14 +2,8 @@ import Layout from "../../Base/layout";
import
Image
from
"../../../assets/conform.png"
;
import
Image
from
"../../../assets/conform.png"
;
import
style
from
"./confirmation.module.css"
;
import
style
from
"./confirmation.module.css"
;
import
Button
from
"../../Base/button"
;
import
Button
from
"../../Base/button"
;
import
{
useNavigate
}
from
"react-router-dom"
;
function
Confirmation
({
id
,
seatCount
,
seats
})
{
function
Confirmation
({
id
,
seatCount
,
seats
,
...
props
})
{
const
navigate
=
useNavigate
();
const
handleModify
=
(
e
)
=>
{
e
.
preventDefault
();
navigate
(
`/booking/
${
id
}
`
);
};
return
(
return
(
<
Layout
title
=
"Booking Confirmed"
>
<
Layout
title
=
"Booking Confirmed"
>
<
div
className
=
{
style
.
confirmation
}
>
<
div
className
=
{
style
.
confirmation
}
>
...
@@ -19,7 +13,7 @@ function Confirmation({ id, seatCount, seats }) {
...
@@ -19,7 +13,7 @@ function Confirmation({ id, seatCount, seats }) {
Booked Seats:
Booked Seats:
{seats.toString()}
{seats.toString()}
</h4>
</h4>
<Button
onClick={handleModify
}>Modify</Button>
<Button
{...props
}>Modify</Button>
</div>
</div>
</Layout>
</Layout>
);
);
...
...
src/components/top-level/seat-layout/index.js
View file @
17e1bb4e
...
@@ -4,7 +4,6 @@ import Button from "../../Base/button";
...
@@ -4,7 +4,6 @@ import Button from "../../Base/button";
import
styles
from
"./seat-layout.module.css"
;
import
styles
from
"./seat-layout.module.css"
;
import
Seat
from
"../seat"
;
import
Seat
from
"../seat"
;
import
{
useNavigate
}
from
"react-router-dom"
;
function
SeatLayout
({
function
SeatLayout
({
userId
=
1
,
userId
=
1
,
seats
,
seats
,
...
@@ -13,9 +12,7 @@ function SeatLayout({
...
@@ -13,9 +12,7 @@ function SeatLayout({
onClick
,
onClick
,
...
props
...
props
})
{
})
{
const
navigate
=
useNavigate
();
const
[
selectedseat
,
setSelectedSeat
]
=
useState
([...
selectedSeats
]);
const
[
selectedseat
,
setSelectedSeat
]
=
useState
([...
selectedSeats
]);
const
[
confirmation
,
setConfirmation
]
=
useState
(
false
);
const
handleSeats
=
(
seat
)
=>
{
const
handleSeats
=
(
seat
)
=>
{
if
(
!
selectedseat
?.
includes
(
seat
))
{
if
(
!
selectedseat
?.
includes
(
seat
))
{
setSelectedSeat
([...
selectedseat
,
seat
]);
setSelectedSeat
([...
selectedseat
,
seat
]);
...
@@ -30,13 +27,10 @@ function SeatLayout({
...
@@ -30,13 +27,10 @@ function SeatLayout({
e
.
preventDefault
();
e
.
preventDefault
();
//check if already have data then update otherwise create,
//check if already have data then update otherwise create,
//write code
//write code
onClick
({
userId
:
parseInt
(
userId
),
seats
:
selectedseat
});
onClick
({
const
count
=
selectedseat
?.
length
;
userId
:
parseInt
(
userId
),
setTimeout
(()
=>
{
seats
:
selectedseat
,
navigate
(
"/confirmation"
,
{
});
state
:
{
seatCount
:
count
,
seats
:
selectedseat
,
id
:
userId
},
});
},
500
);
};
};
return
(
return
(
...
...
src/pages/confirmation.js
View file @
17e1bb4e
import
Confirmation
from
"../components/top-level/confirmation"
;
import
Confirmation
from
"../components/top-level/confirmation"
;
import
{
useLocation
}
from
"react-router-dom"
;
import
{
useLocation
}
from
"react-router-dom"
;
import
{
useNavigate
}
from
"react-router-dom"
;
export
function
_Confirmation
()
{
export
function
_Confirmation
()
{
const
location
=
useLocation
();
const
location
=
useLocation
();
const
seatCount
=
location
.
state
.
seatCount
;
const
seatCount
=
location
.
state
.
seatCount
;
const
seats
=
location
.
state
.
seats
;
const
seats
=
location
.
state
.
seats
;
const
id
=
location
.
state
.
id
;
const
id
=
location
.
state
.
id
;
return
<
Confirmation
id
=
{
id
}
seatCount
=
{
seatCount
}
seats
=
{
seats
}
/>
;
const
navigate
=
useNavigate
();
const
handleModify
=
(
e
)
=>
{
e
.
preventDefault
();
navigate
(
`/booking/
${
id
}
`
);
};
return
(
<
Confirmation
id
=
{
id
}
seatCount
=
{
seatCount
}
seats
=
{
seats
}
onClick
=
{
handleModify
}
/
>
);
}
}
src/pages/seat-layout.js
View file @
17e1bb4e
...
@@ -2,22 +2,14 @@ import { useEffect, useLayoutEffect, useState } from "react";
...
@@ -2,22 +2,14 @@ import { useEffect, useLayoutEffect, useState } from "react";
import
SeatLayout
from
"../components/top-level/seat-layout"
;
import
SeatLayout
from
"../components/top-level/seat-layout"
;
import
{
useAppContext
}
from
"../_context"
;
import
{
useAppContext
}
from
"../_context"
;
import
{
useParams
}
from
"react-router-dom"
;
import
{
useParams
}
from
"react-router-dom"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
bookingSeats
}
from
"./seed"
;
export
function
_Seatlayout
({
...
props
})
{
export
function
_Seatlayout
({
...
props
})
{
const
{
userseats
,
AddOrUpdateSeats
,
GetAllReservedSeats
}
=
useAppContext
();
const
{
userseats
,
AddOrUpdateSeats
,
GetAllReservedSeats
}
=
useAppContext
();
const
[
reservedSeat
,
setReservedSeat
]
=
useState
([]);
const
[
reservedSeat
,
setReservedSeat
]
=
useState
([]);
const
[
selectedSeat
,
setSelectedSeat
]
=
useState
([]);
const
[
selectedSeat
,
setSelectedSeat
]
=
useState
([]);
const
navigate
=
useNavigate
();
const
{
id
}
=
useParams
();
const
{
id
}
=
useParams
();
const
[
seat
]
=
useState
([
[
0
,
"A1"
,
"A2"
,
"A3"
,
0
,
"A4"
,
"A5"
,
"A6"
,
0
],
[
"B1"
,
"B2"
,
"B3"
,
"B4"
,
0
,
"B5"
,
"B6"
,
"B7"
,
"B8"
],
[
"C1"
,
"C2"
,
"C3"
,
"C4"
,
0
,
"C5"
,
"C6"
,
"C7"
,
"C8"
],
[
"D1"
,
"D2"
,
"D3"
,
"D4"
,
0
,
"D5"
,
"D6"
,
"D7"
,
"D8"
],
[
"E1"
,
"E2"
,
"E3"
,
"E4"
,
0
,
"E5"
,
"E6"
,
"E7"
,
"E8"
],
[
"F1"
,
"F2"
,
"F3"
,
"F4"
,
0
,
"F5"
,
"F6"
,
"F7"
,
"F8"
],
[
"G1"
,
"G2"
,
"G3"
,
"G4"
,
0
,
"G5"
,
"G6"
,
"G7"
,
"G8"
],
[
0
,
"H1"
,
"H2"
,
"H3"
,
0
,
"H4"
,
"H5"
,
"H7"
,
0
],
]);
useLayoutEffect
(()
=>
{
useLayoutEffect
(()
=>
{
GetAllReservedSeats
();
GetAllReservedSeats
();
...
@@ -40,13 +32,24 @@ export function _Seatlayout({ ...props }) {
...
@@ -40,13 +32,24 @@ export function _Seatlayout({ ...props }) {
setSelectedSeat
(
results
);
setSelectedSeat
(
results
);
};
};
const
handleConfirmed
=
async
({
userId
,
seats
})
=>
{
await
AddOrUpdateSeats
({
userId
,
seats
});
const
count
=
seats
?.
length
;
setTimeout
(()
=>
{
navigate
(
"/confirmation"
,
{
state
:
{
seatCount
:
count
??
0
,
seats
:
seats
,
id
},
});
},
500
);
};
return
(
return
(
<
SeatLayout
<
SeatLayout
userId
=
{
id
}
userId
=
{
id
}
seats
=
{
seat
}
seats
=
{
bookingSeats
}
selectedSeats
=
{
selectedSeat
}
selectedSeats
=
{
selectedSeat
}
reservedSeats
=
{
reservedSeat
}
reservedSeats
=
{
reservedSeat
}
onClick
=
{
AddOrUpdateSeats
}
onClick
=
{
handleConfirmed
}
{...
props
}
{...
props
}
/
>
/
>
);
);
...
...
src/pages/seed.js
0 → 100644
View file @
17e1bb4e
export
const
bookingSeats
=
[
[
0
,
"A1"
,
"A2"
,
"A3"
,
0
,
"A4"
,
"A5"
,
"A6"
,
0
],
[
"B1"
,
"B2"
,
"B3"
,
"B4"
,
0
,
"B5"
,
"B6"
,
"B7"
,
"B8"
],
[
"C1"
,
"C2"
,
"C3"
,
"C4"
,
0
,
"C5"
,
"C6"
,
"C7"
,
"C8"
],
[
"D1"
,
"D2"
,
"D3"
,
"D4"
,
0
,
"D5"
,
"D6"
,
"D7"
,
"D8"
],
[
"E1"
,
"E2"
,
"E3"
,
"E4"
,
0
,
"E5"
,
"E6"
,
"E7"
,
"E8"
],
[
"F1"
,
"F2"
,
"F3"
,
"F4"
,
0
,
"F5"
,
"F6"
,
"F7"
,
"F8"
],
[
"G1"
,
"G2"
,
"G3"
,
"G4"
,
0
,
"G5"
,
"G6"
,
"G7"
,
"G8"
],
[
0
,
"H1"
,
"H2"
,
"H3"
,
0
,
"H4"
,
"H5"
,
"H7"
,
0
],
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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