|
1 | 1 | import React, { useState, useEffect } from 'react';
|
2 | 2 | import { filteredVariantPrice, paddedPrice } from '@/utils/functions/functions';
|
3 |
| -import AddToCart, { IProductRootObject } from './AddToCart.component'; |
| 3 | +import AddToCart, { IProduct, IProductRootObject } from './AddToCart.component'; |
4 | 4 | import LoadingSpinner from '@/components/LoadingSpinner/LoadingSpinner.component';
|
| 5 | +import Button from '@/components/UI/Button.component'; |
5 | 6 |
|
6 |
| -const SingleProduct: React.FC<IProductRootObject> = ({ product }) => { |
| 7 | +interface SingleProductProps { |
| 8 | + product: IProduct; |
| 9 | +} |
| 10 | + |
| 11 | +const SingleProduct: React.FC<SingleProductProps> = ({ product }) => { |
7 | 12 | const [isLoading, setIsLoading] = useState<boolean>(true);
|
8 | 13 | const [selectedVariation, setSelectedVariation] = useState<
|
9 | 14 | number | undefined
|
@@ -34,8 +39,13 @@ const SingleProduct: React.FC<IProductRootObject> = ({ product }) => {
|
34 | 39 | .textContent || '';
|
35 | 40 | }
|
36 | 41 |
|
| 42 | + const handleBuy = () => { |
| 43 | + // Implement buy functionality here |
| 44 | + console.log('Buy button clicked'); |
| 45 | + }; |
| 46 | + |
37 | 47 | return (
|
38 |
| - <section className="bg-white"> |
| 48 | + <section className="bg-white mb-16 sm:mb-24"> |
39 | 49 | {isLoading ? (
|
40 | 50 | <div className="h-56 mt-20">
|
41 | 51 | <p className="text-2xl font-bold text-center">Laster produkt ...</p>
|
@@ -124,15 +134,20 @@ const SingleProduct: React.FC<IProductRootObject> = ({ product }) => {
|
124 | 134 | </select>
|
125 | 135 | </div>
|
126 | 136 | )}
|
127 |
| - <div className="flex justify-center md:justify-start"> |
128 |
| - {product.variations ? ( |
129 |
| - <AddToCart |
130 |
| - product={product} |
131 |
| - variationId={selectedVariation} |
132 |
| - /> |
133 |
| - ) : ( |
134 |
| - <AddToCart product={product} /> |
135 |
| - )} |
| 137 | + <div className="flex flex-col space-y-4 items-center md:items-start"> |
| 138 | + <Button handleButtonClick={handleBuy} color="blue"> |
| 139 | + Kjøp nå |
| 140 | + </Button> |
| 141 | + <div className="w-full md:w-auto"> |
| 142 | + {product.variations ? ( |
| 143 | + <AddToCart |
| 144 | + product={product} |
| 145 | + variationId={selectedVariation} |
| 146 | + /> |
| 147 | + ) : ( |
| 148 | + <AddToCart product={product} /> |
| 149 | + )} |
| 150 | + </div> |
136 | 151 | </div>
|
137 | 152 | </div>
|
138 | 153 | </div>
|
|
0 commit comments