Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 2ff6c536
authored
2024-05-28 11:42:19 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
search bar
1 parent
ca8b65e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
2 deletions
components/layout/Header.js
components/layout/Header.js
View file @
2ff6c53
...
@@ -8,11 +8,15 @@ import { Button, Container, Form, Nav, Navbar } from "react-bootstrap";
...
@@ -8,11 +8,15 @@ import { Button, Container, Form, Nav, Navbar } from "react-bootstrap";
import
{
getCurrentEndUser
,
loadUser
}
from
"../../redux/actions/userActions"
;
import
{
getCurrentEndUser
,
loadUser
}
from
"../../redux/actions/userActions"
;
import
{
useRouter
}
from
"next/router"
;
import
{
useRouter
}
from
"next/router"
;
import
{
getWishlists
}
from
"../../redux/actions/activityAction"
;
import
{
getWishlists
}
from
"../../redux/actions/activityAction"
;
import
{
Typeahead
}
from
"react-bootstrap-typeahead"
;
import
axios
from
"axios"
;
const
Header
=
()
=>
{
const
Header
=
()
=>
{
const
{
loadedUser
}
=
useSelector
(
state
=>
state
.
loadedUser
);
const
{
loadedUser
}
=
useSelector
(
state
=>
state
.
loadedUser
);
const
{
endUser
}
=
useSelector
(
state
=>
state
.
endUser
);
const
{
endUser
}
=
useSelector
(
state
=>
state
.
endUser
);
const
[
open
,
setopen
]
=
useState
(
false
);
const
[
options
,
setoptions
]
=
useState
([]);
console
.
log
(
"options"
,
options
);
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
// console.log("user", loadedUser);
// console.log("user", loadedUser);
const
[
isSticky
,
setIsSticky
]
=
useState
(
false
);
const
[
isSticky
,
setIsSticky
]
=
useState
(
false
);
...
@@ -61,7 +65,59 @@ const Header = () => {
...
@@ -61,7 +65,59 @@ const Header = () => {
<
/Nav
>
<
/Nav
>
<
Form
className
=
"d-flex me-3"
>
<
Form
className
=
"d-flex me-3"
>
<
div
className
=
"header-search"
>
<
div
className
=
"header-search"
>
<
Form
.
Control
type
=
"search"
placeholder
=
"Search"
className
=
"me-2"
aria
-
label
=
"Search"
/>
<
Typeahead
open
=
{
open
}
id
=
"select"
placeholder
=
"Search for products, brands or categories"
onChange
=
{
selected
=>
{
console
.
log
(
"selected"
,
selected
);
// router.push("/listing");
if
(
selected
[
0
]?.
label
.
includes
(
"experience"
))
{
// console.log("jjja");
router
.
push
(
`/activities/
${
selected
[
0
].
id
}
`
);
}
if
(
selected
[
0
]?.
label
.
includes
(
"category"
))
{
router
.
push
(
`/listing?category=
${
selected
[
0
].
id
}
`
);
// dispatch(setActivityFilters({ filters: { category: selected[0].id, subCategories: [] } }));
}
// Handle selections...
}}
onInputChange
=
{
async
e
=>
{
console
.
log
(
e
);
if
(
e
.
length
>
1
)
{
const
config
=
{
headers
:
{
"Content-Type"
:
"application/json"
}
};
const
res
=
await
axios
.
post
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/experience/get-search-response`
,
{
string
:
e
},
config
);
console
.
log
(
"res"
,
res
.
data
);
if
(
res
.
data
.
success
)
{
let
opts
=
res
.
data
.
data
.
categories
?.
map
(
item
=>
{
return
{
id
:
item
.
id
,
label
:
`
${
item
.
name
}
- category`
};
});
console
.
log
(
"here"
,
opts
);
if
(
opts
?.
length
>
0
)
{
const
a
=
res
.
data
.
data
.
activities
?.
map
(
item
=>
{
return
{
id
:
item
.
id
,
label
:
`
${
item
.
name
}
- experience`
};
});
opts
=
[...
opts
,
...
a
];
}
else
{
opts
=
res
.
data
.
data
.
activities
?.
map
(
item
=>
{
return
{
id
:
item
.
id
,
label
:
`
${
item
.
name
}
- experience`
};
});
}
console
.
log
(
"opts"
,
opts
);
setoptions
(
opts
);
setopen
(
true
);
}
}
else
{
setopen
(
false
);
}
}}
options
=
{
options
}
/
>
<
Button
className
=
"search-icon"
variant
=
"outline-success"
>
<
Button
className
=
"search-icon"
variant
=
"outline-success"
>
<
span
className
=
"image-container"
>
<
span
className
=
"image-container"
>
<
Image
layout
=
"fill"
alt
=
""
className
=
"image img-fluid"
src
=
"/images/icons/search-icon.svg"
/>
<
Image
layout
=
"fill"
alt
=
""
className
=
"image img-fluid"
src
=
"/images/icons/search-icon.svg"
/>
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment