Skip to content

Commit

Permalink
some correction
Browse files Browse the repository at this point in the history
  • Loading branch information
Herman-Riah19 committed Nov 17, 2023
1 parent cf5b71c commit bea4de9
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 13 deletions.
3 changes: 2 additions & 1 deletion app/Controllers/Http/ProductsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export default class ProductsController {
}

public async show({ inertia, params, auth }: HttpContextContract) {
const product = await Product.findBy('id', params.id)
const productName = params.name.split('_').join(' ')
const product = await Product.findBy('name', productName)
const assetUrl = await Drive.getUrl('./products')

const AllComments = await Comment.all()
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Components/Card/CardPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react'
import {Card, CardContent, CardActionArea, CardMedia, Typography} from '@mui/material'
import { Link } from '@inertiajs/inertia-react'

const CardPost = ({title, slug, content, imageUrl, classes}) => {
const CardPost = ({key, title, slug, content, imageUrl, classes}) => {

return (
<Card sx={classes}>
<Card key={key} sx={classes}>
<CardActionArea>
<Link href={`/post/${slug}`}>
<CardMedia component="img" sx={{height: '120px',overflow: 'hidden'}} image={imageUrl} alt={title}/>
Expand Down
7 changes: 4 additions & 3 deletions resources/js/Components/Card/CardProduct.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ const classes = {
},
};

const CardProduct = ({ product, username, url }) => {
const CardProduct = ({ key, product, username, url }) => {
const productName = product.name.split(' ').join('_')
return (
<Card sx={classes.card}>
<Card key={key} sx={classes.card}>
<CardActionArea>
<Link href={`/product/show/${product.id}`}>
<Link href={`/product/show/${productName}`}>
<CardMedia
component="img"
sx={classes.img}
Expand Down
1 change: 1 addition & 0 deletions resources/js/Components/Card/CardUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const CardUser = ({ user, avatar, profile }) => {
const username = user.username.split(' ').join('_')
return (
<Card
key={user.id}
sx={{
m: '12px',
color: '#000',
Expand Down
14 changes: 12 additions & 2 deletions resources/js/Pages/Home/Collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const Collections = ({ auth, avatarUrl, authenticateProfile, categories, product
<Tab label='All' sx={{ color: '#c7d4e1', textTransform: 'capitalize' }} />
{categories.map(section => (
<Tab
key={section.id}
label={section.name}
sx={{ color: '#c7d4e1', textTransform: 'capitalize' }} />
))}
Expand All @@ -83,7 +84,11 @@ const Collections = ({ auth, avatarUrl, authenticateProfile, categories, product
const user = findUserById(product.user_id)
return (
<Grid item xs={12} sm={6} md={4} lg={3}>
<CardProduct product={product} username={user.username} url={productUrl} />
<CardProduct
key={product.id}
product={product}
username={user.username}
url={productUrl} />
</Grid>
)
})}
Expand All @@ -100,7 +105,11 @@ const Collections = ({ auth, avatarUrl, authenticateProfile, categories, product
const user = findUserById(product.user_id)
return (
<Grid item xs={12} sm={6} md={4} lg={3}>
<CardProduct product={product} username={user.username} url={productUrl} />
<CardProduct
key={product.id}
product={product}
username={user.username}
url={productUrl} />
</Grid>
)
})}
Expand Down Expand Up @@ -139,6 +148,7 @@ const Collections = ({ auth, avatarUrl, authenticateProfile, categories, product
{posts.map(post => (
<SwiperSlide>
<CardPost
key={post.id}
title={post.title}
slug={post.slug}
content={post.description}
Expand Down
10 changes: 6 additions & 4 deletions resources/js/Pages/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function Home({
scrollbar={{ draggable: true }}
>
{categories.map((categ) => (
<SwiperSlide>
<SwiperSlide key={categ.id}>
<CardCategorie
categorie={categ}
categorieUrl={categorieUrl}
Expand Down Expand Up @@ -183,7 +183,7 @@ export default function Home({
scrollbar={{ draggable: true }}
>
{posts.map((post) => (
<SwiperSlide>
<SwiperSlide key={post.id}>
<CardPost
title={post.title}
slug={post.slug}
Expand Down Expand Up @@ -211,7 +211,7 @@ export default function Home({
{users.map((artist) => {
const profile = getProfileByUser(artist);
return (
<SwiperSlide>
<SwiperSlide key={artist.id}>
{artist.role_id != 2 && (
<CardUserProfile
user={artist}
Expand All @@ -232,8 +232,9 @@ export default function Home({
{products.map((product) => {
const user = findUserById(product.user_id);
return (
<Grid item xs={12} sm={5} md={4} lg={3}>
<Grid item xs={12} sm={5} md={4} lg={3} >
<CardProduct
key={product.id}
product={product}
username={user.username}
url={productUrl}
Expand All @@ -256,6 +257,7 @@ export default function Home({
{posts.map((post) => (
<SwiperSlide>
<CardPost
key={post.id}
title={post.title}
slug={post.slug}
content={post.description}
Expand Down
2 changes: 2 additions & 0 deletions resources/js/Pages/Home/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const Search = (props) => {
<Grid container spacing={2}>
<Grid item xs={12} sm={6} md={4} lg={3}>
<CardProduct
key={product.id}
product={product}
username={user.username}
url={productUrl}
Expand All @@ -89,6 +90,7 @@ const Search = (props) => {
{existProducts.map((prod) => (
<Grid key={prod.id} item xs={12} sm={6} md={4} lg={3}>
<CardProduct
key={prod.id}
product={prod}
username={findUserById(prod.user_id).username}
url={productUrl}
Expand Down
1 change: 1 addition & 0 deletions resources/js/Pages/Product/ProductShow.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const ProductShow = ({
return (
<Grid item xs={12} sm={6} md={4} lg={3}>
<CardProduct
key={item.id}
product={item}
username={user.username}
url={assetUrl}
Expand Down
2 changes: 1 addition & 1 deletion start/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Route.group(() => {
Route.post('/create', 'ProductsController.store')
Route.post('/show/:id', 'ProductsController.addComment')
}).middleware('auth')
Route.get('/show/:id', 'ProductsController.show').as('product.show')
Route.get('/show/:name', 'ProductsController.show').as('product.show')
Route.get('/is-liked/:id', 'ProductsController.handleIsLiked').middleware('auth')
Route.get('/download/:id', 'ProductsController.download').as('product.download')
}).prefix('/product')
Expand Down

0 comments on commit bea4de9

Please sign in to comment.