File tree 2 files changed +65
-9
lines changed
2 files changed +65
-9
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ import { useAppDispatch, useAppSelector } from '../../store/store';
8
8
import { fetchSingleProduct } from '../../store/features/product/singleProductSlice' ;
9
9
import { PuffLoader } from 'react-spinners' ;
10
10
import { IProductInitialResponse } from '../../utils/types/store' ;
11
+ import { Meta } from '../Meta' ;
12
+ import { Link } from 'react-router-dom' ;
11
13
12
14
const ProductComponent = ( { productId } : { productId : string } ) => {
13
15
const dispatch = useAppDispatch ( ) ;
@@ -19,13 +21,15 @@ const ProductComponent = ({ productId }: { productId: string }) => {
19
21
20
22
return (
21
23
< >
24
+ < Meta title = { `Product details - ${ productId } ` } />
22
25
{ isLoading ? (
23
26
< div className = "loader" >
24
27
< PuffLoader color = "#ff6d18" size = { 300 } loading = { isLoading } />
25
28
</ div >
26
29
) : isError ? (
27
30
< div className = "error-message" >
28
31
< p > { message || "Something went wrong. Please try again later." } </ p >
32
+ < Link to = "/" className = "btn-link" > View all products</ Link >
29
33
</ div >
30
34
) : (
31
35
product ?
@@ -40,7 +44,10 @@ const ProductComponent = ({ productId }: { productId: string }) => {
40
44
41
45
</ div >
42
46
:
43
- < div > No Product</ div >
47
+ < div className = 'error-message' >
48
+ < p > Product was not found</ p >
49
+ < Link to = "/" className = "btn-link" > View all products</ Link >
50
+ </ div >
44
51
)
45
52
}
46
53
</ >
Original file line number Diff line number Diff line change 2
2
3
3
.product-component {
4
4
padding : 2rem ;
5
- * {
5
+
6
+ * {
6
7
font-size : 16px ;
7
8
}
8
9
328
329
329
330
}
330
331
332
+ .loader {
333
+ display : flex ;
334
+ justify-content : center ;
335
+ align-items : center ;
336
+ height : 60vh ;
337
+ width : 100% ;
338
+ }
339
+
340
+ .error-message {
341
+ display : flex ;
342
+ flex-direction : column ;
343
+ gap : 10px ;
344
+ justify-content : center ;
345
+ align-items : center ;
346
+ width : 100% ;
347
+ height : 60vh ;
348
+
349
+ p {
350
+ font-size : 20px ;
351
+ color : $red-color ;
352
+ }
353
+
354
+ .btn-link {
355
+ border : none ;
356
+ background-color : $primary-color ;
357
+ padding : 1rem 4rem ;
358
+ text-decoration : none ;
359
+ color : $white-color ;
360
+ font-family : $text-family ;
361
+ font-weight : 700 ;
362
+ font-size : 1.2rem ;
363
+ border-radius : 2rem ;
364
+ cursor : pointer ;
365
+ }
366
+
367
+ .btn-link :hover {
368
+ background-color : $white-color ;
369
+ color : $primary-color ;
370
+ border : 1px solid $border-color ;
371
+ box-shadow : 2px 2px 10px rgba (0 , 0 , 0 , 0.5 );
372
+ transition : all 0.3s ease-in-out ;
373
+ }
374
+ }
375
+
331
376
@media (max-width : 600px ) {
332
377
.product-component {
333
- * {
378
+ * {
334
379
font-size : 12px ;
335
380
}
381
+
336
382
.product-container {
337
383
flex-direction : column ;
338
384
padding-bottom : 20px ;
339
- .images-container {
385
+
386
+ .images-container {
340
387
max-height : 300px ;
341
388
min-height : 300px ;
342
389
overflow : hidden ;
343
- .main-image-container {
344
- .main-image {
390
+
391
+ .main-image-container {
392
+ .main-image {
345
393
height : 100% ;
346
394
}
347
395
}
348
396
}
349
397
}
350
- .card-container {
351
- .card-header {
352
- .card-header-title {
398
+
399
+ .card-container {
400
+ .card-header {
401
+ .card-header-title {
353
402
font-size : 5px ;
354
403
}
355
404
}
You can’t perform that action at this time.
0 commit comments