Skip to content

Commit

Permalink
Merge branch 'release/0.17.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloglacial committed Jul 22, 2024
2 parents 3067d39 + 7362b5c commit 5c1832c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
1 change: 0 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const inter = Inter({ subsets: ['latin'] })
const siteInfo = getSiteInfo()

export async function generateMetadata(): Promise<Metadata> {
const siteInfo = getSiteInfo()
return {
title: `${siteInfo.title} - ${siteInfo.description}`,
description: siteInfo.description,
Expand Down
5 changes: 3 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { PaginationBar, ProductList } from '@/components'
import { PaginationBar, ProductList, VendorsList } from '@/components'
import { getProducts } from '@/services'

export default async function Home() {
const products = await getProducts({ page: 1 })
const allProducts: IProduct[] = products.data
return (
<div className='flex flex-wrap gap-8'>
<div className='flex flex-wrap gap-4 md:gap-8'>
<VendorsList />
<ProductList products={allProducts} />
<PaginationBar page={products.page} totalPages={products.totalPages} />
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export interface AvatarProps {

export const Avatar: FC<AvatarProps> = ({ image }): JSX.Element => {
return (
<div className='avatar__container w-24 aspect-square rounded-full bg-slate-200 overflow-hidden flex items-center justify-center'>
<figure className='avatar__figure relative w-16 h-16'>
<div className='avatar__container w-16 md:w-24 p-2 md:p-4 aspect-square rounded-full bg-slate-200 overflow-hidden flex items-center justify-center'>
<figure className='avatar__figure relative w-full h-full'>
<Image
{...image}
className='avatar__image object-contain'
Expand Down
1 change: 1 addition & 0 deletions components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export * from './searchbar/SearchBar'
export * from './social-bar/SocialBar'
export * from './text/Text'
export * from './tooltip/Tooltip'
export * from './vendors-list/VendorsList'
24 changes: 24 additions & 0 deletions components/vendors-list/VendorsList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { getVendors } from '@/services'
import { Avatar } from '@/components'
import Link from 'next/link'

export const VendorsList = async () => {
const vendors = await getVendors()
return (
<div className='flex flex-wrap gap-4'>
{vendors.data.map((vendor: IVendor) => {
if (!vendor.products?.total) return
return (
<Link key={vendor._id} href={`/loja/${vendor.slug}`}>
<Avatar
image={{
src: vendor.image.src,
alt: vendor.image.alt,
}}
/>
</Link>
)
})}
</div>
)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "desconto-porreta",
"version": "0.16.0",
"version": "0.17.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
5 changes: 0 additions & 5 deletions services/vendor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
interface IgetVendors {
data: IVendor[]
meta: Object
}

export const getVendors = async (): Promise<IPromise> => {
try {
const res = await fetch(`${process.env.API_URL}/api/vendors`, {
Expand Down
3 changes: 3 additions & 0 deletions types/vendor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ interface IVendor {
_id: string
title: string
slug: string
products?: {
total?: number
}
image: {
src: string
alt: string
Expand Down

0 comments on commit 5c1832c

Please sign in to comment.