Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header component #22

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ const url = 'https://store.itmarck.com'
export const client = createDirectus(url, { globals: { fetch } })
.with(authentication('json', { storage }))
.with(rest())

export function buildImageUrl(imageId) {
return `${url}/assets/${imageId}`
}
10 changes: 6 additions & 4 deletions src/components/Header/index.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import './Header.css'

function Header() {
function Header(props) {
const { title, subtitle, avatar, onAvatarClick } = props
return (
<section className="Header">
<p className="Header__title">Mi cielito</p>
<p className="Header__title">{title}</p>
<div>
<p className="Header__name">Luis Barboza</p>
<p className="Header__name">{subtitle}</p>
<img
className="Header__img"
src="https://img.freepik.com/foto-gratis/collage-fondo-programacion_23-2149901782.jpg?w=996&t=st=1709668841~exp=1709669441~hmac=115e1de9393fffe964ebf0bd2fc31b12602b03077f87a6fd6306c1103629e657"
src={avatar}
alt=""
onClick={onAvatarClick}
/>
</div>
</section>
Expand Down
9 changes: 8 additions & 1 deletion src/pages/Home/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { buildImageUrl } from '../../api'
import Details from '../../components/Details'
import Dropdown from '../../components/Dropdown'
import Header from '../../components/Header'
import ProductList from '../../components/ProductList'
import Scanner from '../../components/Scanner'
import { useGlobalStore } from '../../store'
import './Home.css'
function Home() {
const { user } = useGlobalStore()
const avatar = buildImageUrl(user?.avatar)
const name = user?.first_name + ' ' + user?.last_name
const title = 'Mi cielo'

return (
<div className="Home">
<Header />
<Header title={title} subtitle={name} avatar={avatar} />
<Dropdown />
<Scanner />
<ProductList />
Expand Down