fixed some errors
This commit is contained in:
@@ -155,7 +155,7 @@ export default function OrderSummary({
|
||||
}`}
|
||||
/>
|
||||
{showValidation && name.trim() === "" && (
|
||||
<p className="text-xs text-red-500 mt-1">Bu alan zorunludur</p>
|
||||
<p className="text-xs text-red-500 mt-1">{t("requiredField")}</p>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
@@ -172,7 +172,7 @@ export default function OrderSummary({
|
||||
}`}
|
||||
/>
|
||||
{showValidation && lastName.trim() === "" && (
|
||||
<p className="text-xs text-red-500 mt-1">Bu alan zorunludur</p>
|
||||
<p className="text-xs text-red-500 mt-1">{t("requiredField")}</p>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
@@ -190,7 +190,7 @@ export default function OrderSummary({
|
||||
/>
|
||||
{showValidation && !isPhoneValid && (
|
||||
<p className="text-xs text-red-500 mt-1">
|
||||
Telefon 8 rakamdan oluşmalıdır
|
||||
{t("requiredField")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
@@ -226,7 +226,7 @@ export default function OrderSummary({
|
||||
))}
|
||||
</div>
|
||||
{showValidation && !paymentType && (
|
||||
<p className="text-xs text-red-500 mt-1">Ödeme türü seçiniz</p>
|
||||
<p className="text-xs text-red-500 mt-1">{t("requiredField")}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -264,7 +264,7 @@ export default function OrderSummary({
|
||||
))}
|
||||
</RadioGroup>
|
||||
{showValidation && !selectedRegion && (
|
||||
<p className="text-xs text-red-500 mt-1">Bölge seçiniz</p>
|
||||
<p className="text-xs text-red-500 mt-1">{t("requiredField")}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -294,7 +294,7 @@ export default function OrderSummary({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{showValidation && !selectedProvince && (
|
||||
<p className="text-xs text-red-500 mt-1">Adres seçiniz</p>
|
||||
<p className="text-xs text-red-500 mt-1">{t("requiredField")}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -382,7 +382,7 @@ export default function ProductCard({
|
||||
) : (
|
||||
<>
|
||||
<ShoppingCart className="h-4 w-4" />
|
||||
{t("checkout")}
|
||||
{t("add_to_cart")}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
@@ -111,7 +111,7 @@ export function ProductInfoCard({
|
||||
</Card>
|
||||
|
||||
{description && (
|
||||
<Card className="p-4 rounded-xl border-gray-200">
|
||||
<Card className="p-4 rounded-xl border-gray-200 gap-2">
|
||||
<h3 className="text-xl font-semibold mb-3">
|
||||
{t("product_description")}
|
||||
</h3>
|
||||
|
||||
@@ -119,6 +119,24 @@ export default function ProductPageContent({ slug }: ProductDetailProps) {
|
||||
[product]
|
||||
);
|
||||
|
||||
const transformedRelatedProducts = useMemo(() => {
|
||||
if (!relatedProducts) return [];
|
||||
return relatedProducts.map((p) => ({
|
||||
id: p.id,
|
||||
slug: p.slug,
|
||||
name: p.name,
|
||||
price_amount: p.price_amount,
|
||||
old_price_amount: p.old_price_amount ?? undefined,
|
||||
struct_price_text: `${p.price_amount} TMT`,
|
||||
discount: null,
|
||||
discount_text: null,
|
||||
stock: p.stock,
|
||||
media: p.media,
|
||||
labels: [],
|
||||
price_color: undefined,
|
||||
}));
|
||||
}, [relatedProducts]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!product?.id || isInitialized) return;
|
||||
|
||||
@@ -246,7 +264,7 @@ export default function ProductPageContent({ slug }: ProductDetailProps) {
|
||||
}
|
||||
} catch (error) {
|
||||
setLocalQuantity(cartItem?.product_quantity || 1);
|
||||
toast.error("Failed to update quantity", {
|
||||
toast.error(t("failed_to_update_quantity"), {
|
||||
description: "Please try again",
|
||||
});
|
||||
|
||||
@@ -438,10 +456,10 @@ export default function ProductPageContent({ slug }: ProductDetailProps) {
|
||||
/>
|
||||
|
||||
<ProductInfoCard
|
||||
brandName={product.brand?.name}
|
||||
brandName={product.brand?.name ?? undefined}
|
||||
stock={product.stock}
|
||||
barcode={product.barcode}
|
||||
colour={product.colour}
|
||||
colour={product.colour ?? undefined}
|
||||
properties={product.properties}
|
||||
description={product.description}
|
||||
averageRating={averageRating}
|
||||
@@ -451,7 +469,7 @@ export default function ProductPageContent({ slug }: ProductDetailProps) {
|
||||
|
||||
<ProductPurchaseCard
|
||||
price={product.price_amount}
|
||||
oldPrice={product.old_price_amount}
|
||||
oldPrice={product.old_price_amount ?? undefined}
|
||||
isInCart={isInCart}
|
||||
localQuantity={localQuantity}
|
||||
availableStock={availableStock}
|
||||
@@ -475,7 +493,7 @@ export default function ProductPageContent({ slug }: ProductDetailProps) {
|
||||
onWriteReview={() => setShowReviewModal(true)}
|
||||
/>
|
||||
|
||||
<RelatedProductsSection products={relatedProducts || []} />
|
||||
<RelatedProductsSection products={transformedRelatedProducts} />
|
||||
</div>
|
||||
|
||||
<StockLimitModal
|
||||
|
||||
@@ -45,9 +45,7 @@ export function ProductPurchaseCard({
|
||||
<div className="flex justify-between items-start mb-6">
|
||||
<span className="text-lg text-gray-500">{t("price")}:</span>
|
||||
<div className="flex flex-col items-end">
|
||||
<span className="text-3xl font-bold text-primary">
|
||||
{price} TMT
|
||||
</span>
|
||||
<span className="text-3xl font-bold text-primary">{price} TMT</span>
|
||||
{oldPrice && parseFloat(oldPrice) > 0 && (
|
||||
<span className="text-lg text-gray-400 line-through">
|
||||
{oldPrice} TMT
|
||||
@@ -102,6 +100,7 @@ export function ProductPurchaseCard({
|
||||
<Plus className="h-5 w-5" />
|
||||
</Button>
|
||||
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
@@ -123,24 +122,43 @@ export function ProductPurchaseCard({
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={onAddToCart}
|
||||
disabled={isSyncing || productStock === 0}
|
||||
className="w-full rounded-lg text-lg font-bold bg-[#005bff] hover:bg-[#0041c4] cursor-pointer"
|
||||
>
|
||||
{isSyncing ? (
|
||||
<>
|
||||
|
||||
{t("adding")}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<ShoppingCart className="mr-2 h-5 w-5" />
|
||||
{productStock === 0 ? t("out_of_stock") : t("add_to_cart")}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={onAddToCart}
|
||||
disabled={isSyncing || productStock === 0}
|
||||
className="flex-1 rounded-lg text-lg font-bold bg-[#005bff] hover:bg-[#0041c4] cursor-pointer"
|
||||
>
|
||||
{isSyncing ? (
|
||||
<>{t("adding")}</>
|
||||
) : (
|
||||
<>
|
||||
<ShoppingCart className="mr-2 h-5 w-5" />
|
||||
{productStock === 0 ? t("out_of_stock") : t("add_to_cart")}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={onToggleFavorite}
|
||||
className={`rounded-lg h-12 w-12 transition-all border cursor-pointer ${
|
||||
isFavorite
|
||||
? "bg-[#F0F8FF] border-blue-300 hover:bg-blue-100"
|
||||
: "hover:bg-gray-50"
|
||||
}`}
|
||||
>
|
||||
<Heart
|
||||
className={`h-6! w-6! transition-all ${
|
||||
isFavorite
|
||||
? "fill-[#005bff] text-[#005bff]"
|
||||
: "text-[#005bff]"
|
||||
}`}
|
||||
/>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
@@ -158,11 +176,15 @@ export function ProductPurchaseCard({
|
||||
<h4 className="text-lg font-bold">{channelName}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<Button variant="outline" size="lg" className="w-full cursor-pointer rounded-lg">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="lg"
|
||||
className="w-full cursor-pointer rounded-lg"
|
||||
>
|
||||
{t("write_to_store")}
|
||||
</Button>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export default function ClientProfilePage(props: ProfilePageProps) {
|
||||
|
||||
const handleSave = useCallback(async () => {
|
||||
if (!formData.name.trim()) {
|
||||
toast.error(t("name_required") || "Name is required");
|
||||
toast.error(t("requiredField") || "Name is required");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user