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
19faaabc
Commit
19faaabc
authored
a year ago
by
Madhankumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
seat limit bug fix
parent
1066badb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
12 deletions
+36
-12
db.json
db.json
+25
-0
index.js
src/auth/index.js
+3
-8
index.js
src/components/top-level/login/index.js
+0
-1
index.js
src/components/top-level/seat-limit/index.js
+1
-0
login.js
src/pages/login.js
+5
-2
seat-limit.js
src/pages/seat-limit.js
+2
-1
No files found.
db.json
View file @
19faaabc
...
@@ -15,6 +15,10 @@
...
@@ -15,6 +15,10 @@
{
{
"mobile"
:
"8888888880"
,
"mobile"
:
"8888888880"
,
"id"
:
4
"id"
:
4
},
{
"mobile"
:
"8888888888"
,
"id"
:
5
}
}
],
],
"reservedSeats"
:
[
"reservedSeats"
:
[
...
@@ -32,6 +36,26 @@
...
@@ -32,6 +36,26 @@
"F1"
"F1"
],
],
"id"
:
3
"id"
:
3
},
{
"seats"
:
[
"D1"
,
"D2"
,
"D3"
,
"E1"
],
"id"
:
4
},
{
"seats"
:
[
"A4"
,
"B5"
,
"C5"
,
"D5"
,
"E5"
,
"F5"
],
"id"
:
5
}
}
]
]
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/auth/index.js
View file @
19faaabc
...
@@ -3,18 +3,14 @@ import { useLocation, useNavigate } from "react-router-dom";
...
@@ -3,18 +3,14 @@ import { useLocation, useNavigate } from "react-router-dom";
// import { _Login } from "../pages/login";
// import { _Login } from "../pages/login";
export
function
AuthGuard
({
component
:
Component
,
...
props
})
{
export
function
AuthGuard
({
component
:
Component
,
...
props
})
{
const
isLogged
=
sessionStorage
.
getItem
(
"userId"
)
!=
null
?
true
:
false
;
const
isLogged
=
sessionStorage
.
getItem
(
"userId"
)
!=
null
?
true
:
false
;
console
.
log
(
"didid"
,
isLogged
);
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
const
location
=
useLocation
();
const
location
=
useLocation
();
const
currentPath
=
sessionStorage
.
getItem
(
"currentPath"
);
const
currentPath
=
sessionStorage
.
getItem
(
"currentPath"
);
console
.
log
(
"pod"
,
location
.
pathname
,
currentPath
);
console
.
log
(
"ururur"
,
location
.
pathname
,
currentPath
);
useEffect
(()
=>
{
useEffect
(()
=>
{
console
.
log
(
"yrtrtry"
);
if
(
!
isLogged
)
{
if
(
!
isLogged
)
{
sessionStorage
.
removeItem
(
"userId"
);
sessionStorage
.
clear
();
sessionStorage
.
removeItem
(
"seatLimit"
);
// Redirect to the home page if the user is not logged in
navigate
(
"/"
);
navigate
(
"/"
);
}
else
if
(
isLogged
&&
location
.
pathname
!=
currentPath
)
{
}
else
if
(
isLogged
&&
location
.
pathname
!=
currentPath
)
{
navigate
(
currentPath
);
navigate
(
currentPath
);
...
@@ -23,7 +19,6 @@ export function AuthGuard({ component: Component, ...props }) {
...
@@ -23,7 +19,6 @@ export function AuthGuard({ component: Component, ...props }) {
// If logged in (session has a value), render the protected component
// If logged in (session has a value), render the protected component
if
(
isLogged
&&
location
.
pathname
==
currentPath
)
{
if
(
isLogged
&&
location
.
pathname
==
currentPath
)
{
console
.
log
(
"jjsj"
);
return
<
Component
{...
props
}
/>
;
return
<
Component
{...
props
}
/>
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/components/top-level/login/index.js
View file @
19faaabc
...
@@ -10,7 +10,6 @@ function Login({ onSubmit }) {
...
@@ -10,7 +10,6 @@ function Login({ onSubmit }) {
const
[
iserror
,
setIsError
]
=
useState
(
false
);
const
[
iserror
,
setIsError
]
=
useState
(
false
);
const
handleSubmit
=
(
e
)
=>
{
const
handleSubmit
=
(
e
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
console
.
log
(
"mobile"
,
mobile
.
length
);
if
(
mobile
.
length
<
10
)
{
if
(
mobile
.
length
<
10
)
{
setIsError
(
true
);
setIsError
(
true
);
...
...
This diff is collapsed.
Click to expand it.
src/components/top-level/seat-limit/index.js
View file @
19faaabc
...
@@ -9,6 +9,7 @@ function SeatLimit({ onLimit, ...props }) {
...
@@ -9,6 +9,7 @@ function SeatLimit({ onLimit, ...props }) {
e
.
preventDefault
();
e
.
preventDefault
();
if
(
limit
>
0
)
{
if
(
limit
>
0
)
{
onLimit
({
limit
});
onLimit
({
limit
});
sessionStorage
.
setItem
(
"seatLimit"
,
limit
);
}
else
{
}
else
{
toast
.
info
(
"Please enter atleast 1 seat"
);
toast
.
info
(
"Please enter atleast 1 seat"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/pages/login.js
View file @
19faaabc
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
}
from
"react"
;
import
{
useAppContext
}
from
"../_context"
;
import
{
useAppContext
}
from
"../_context"
;
import
Login
from
"../components/top-level/login"
;
import
Login
from
"../components/top-level/login"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
useNavigate
}
from
"react-router-dom"
;
...
@@ -13,12 +13,15 @@ export function _Login() {
...
@@ -13,12 +13,15 @@ export function _Login() {
const
handleLogin
=
async
({
mobile
})
=>
{
const
handleLogin
=
async
({
mobile
})
=>
{
const
users
=
await
LoginOrRegister
({
mobile
});
const
users
=
await
LoginOrRegister
({
mobile
});
if
(
users
!=
null
)
{
if
(
users
!=
null
)
{
sessionStorage
.
setItem
(
"userId"
,
users
.
id
);
//check seat length for already booked seats for the user
const
userstate
=
userseats
.
filter
((
e
)
=>
const
userstate
=
userseats
.
filter
((
e
)
=>
e
.
id
===
users
.
id
?
true
:
false
e
.
id
===
users
.
id
?
true
:
false
);
);
if
(
userstate
.
length
)
{
if
(
userstate
.
length
)
{
sessionStorage
.
setItem
(
"userId"
,
users
.
id
);
//if store the seat length in session
sessionStorage
.
setItem
(
"seatLimit"
,
userstate
[
0
].
seats
.
length
);
sessionStorage
.
setItem
(
"seatLimit"
,
userstate
[
0
].
seats
.
length
);
//redirect to booking component otherwise it will not redirect if not login
sessionStorage
.
setItem
(
"currentPath"
,
"/booking"
);
sessionStorage
.
setItem
(
"currentPath"
,
"/booking"
);
navigate
(
"/booking"
);
navigate
(
"/booking"
);
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
src/pages/seat-limit.js
View file @
19faaabc
...
@@ -4,7 +4,8 @@ import { useNavigate } from "react-router-dom";
...
@@ -4,7 +4,8 @@ import { useNavigate } from "react-router-dom";
export
function
_seatLimit
()
{
export
function
_seatLimit
()
{
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
const
handleLimit
=
(
e
)
=>
{
const
handleLimit
=
()
=>
{
sessionStorage
.
setItem
(
"currentPath"
,
"/booking"
);
navigate
(
"/booking"
);
navigate
(
"/booking"
);
};
};
return
<
SeatLimit
onLimit
=
{
handleLimit
}
/>
;
return
<
SeatLimit
onLimit
=
{
handleLimit
}
/>
;
...
...
This diff is collapsed.
Click to expand it.
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