fix: support chat elevated only on PDP, rx button opens modal instantly, and hide pet badge when not logged in
Deploy Canina / deploy (push) Failing after 21s
Deploy Canina / deploy (push) Failing after 21s
This commit is contained in:
1 parent
b54338f91f
commit
6a37f2f4c7
3 files changed
+14
-7
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { useUserStore } from "../lib/store/userStore";
|
||||
"use client";
|
||||
import React, { useState, useMemo, useEffect, useCallback } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
@@ -87,7 +88,8 @@ export const ArchiveProductCard: React.FC<{ product: Product }> = ({ product })
|
||||
const { addItem } = useCartStore();
|
||||
const cartItem = useCartStore((s) => s.items.find(i => i.product.id === product.id));
|
||||
const [isAdding, setIsAdding] = useState(false);
|
||||
const activePet = usePetStore(state => state.pets.find(p => p.id === state.activePetId) || null);
|
||||
const isLoggedIn = useUserStore(s => s.isLoggedIn);
|
||||
const activePet = usePetStore(state => (isLoggedIn ? (state.pets.find(p => p.id === state.activePetId) || null) : null));
|
||||
const { showPrices, allowCart, showPreorderBtn } = useCatalogMode();
|
||||
const productUrl = `/shop/${product.slug || product.id}`;
|
||||
|
||||
@@ -132,8 +134,8 @@ export const ArchiveProductCard: React.FC<{ product: Product }> = ({ product })
|
||||
{/* SpecialBadge moved below image to avoid covering product photo */}
|
||||
|
||||
{compatibility && (
|
||||
<div className={`absolute top-14 right-4 z-10 text-3xs font-black uppercase tracking-widest px-3 py-1 rounded-full shadow-md flex items-center gap-1 ${compatibility.type === 'alert' ? 'bg-amber-100 text-amber-700' :
|
||||
compatibility.type === 'success' ? 'bg-green-100 text-green-700' : 'bg-medical-gray-100 text-medical-gray-600'
|
||||
<div className={`absolute top-4 right-4 z-10 text-3xs font-black uppercase tracking-widest px-2.5 py-1 rounded-full shadow-md flex items-center gap-1 backdrop-blur-xs ${compatibility.type === 'alert' ? 'bg-amber-500/90 text-white' :
|
||||
compatibility.type === 'success' ? 'bg-emerald-600/90 text-white' : 'bg-canina-blue/90 text-white'
|
||||
}`}>
|
||||
{compatibility.type === 'alert' ? (
|
||||
forBoth ? (
|
||||
@@ -276,7 +278,8 @@ const ArchiveProductListItem: React.FC<{ product: Product }> = ({ product }) =>
|
||||
const { addItem } = useCartStore();
|
||||
const cartItem = useCartStore((s) => s.items.find(i => i.product.id === product.id));
|
||||
const [isAdding, setIsAdding] = useState(false);
|
||||
const activePet = usePetStore(state => state.pets.find(p => p.id === state.activePetId) || null);
|
||||
const isLoggedIn = useUserStore(s => s.isLoggedIn);
|
||||
const activePet = usePetStore(state => (isLoggedIn ? (state.pets.find(p => p.id === state.activePetId) || null) : null));
|
||||
const productUrl = `/shop/${product.slug || product.id}`;
|
||||
|
||||
const handleAddToCart = (e: React.MouseEvent) => {
|
||||
|
||||
@@ -249,11 +249,12 @@ export default function Header({
|
||||
|
||||
{/* Left Action Buttons */}
|
||||
<div className="flex items-center gap-1.5 sm:gap-3 shrink-0">
|
||||
{/* Prescription Upload Button (Desktop & Mobile) */}
|
||||
{/* Prescription Upload Button (Desktop & Mobile) - Opens Prescription Modal */}
|
||||
{isPrescriptionEnabled && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
window.location.href = "/prescriptions";
|
||||
setIsPrescriptionModalOpen(true);
|
||||
}}
|
||||
className="flex items-center gap-1.5 px-2.5 sm:px-3 py-2 bg-emerald-50 text-emerald-700 border border-emerald-200 hover:bg-emerald-100 rounded-xl text-[11px] sm:text-xs font-black transition-all shadow-xs cursor-pointer"
|
||||
title="ثبت نسخه دامپزشک"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use client';
|
||||
import { FormEvent, useEffect, useRef, useState } from 'react';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
type PersistedMessage = { role: 'user' | 'assistant'; content: string };
|
||||
|
||||
@@ -42,6 +43,8 @@ export default function SupportChat() {
|
||||
const pending = useRef<AbortController | null>(null);
|
||||
const chatScrollRef = useRef<HTMLDivElement | null>(null);
|
||||
const historyKey = useRef('');
|
||||
const pathname = usePathname();
|
||||
const isPdpPage = pathname?.startsWith('/shop/') && pathname !== '/shop';
|
||||
|
||||
useEffect(() => {
|
||||
identity.current = token();
|
||||
@@ -194,7 +197,7 @@ export default function SupportChat() {
|
||||
if (!config?.enabled) return configError ? <span role="status" className="sr-only">تنظیمات پشتیبان هوشمند در دسترس نیست.</span> : null;
|
||||
const botIcon = { chat: '💬', paw: '🐾', bot: '🤖' }[config.icon];
|
||||
return (
|
||||
<aside dir="rtl" className="fixed bottom-24 sm:bottom-6 left-4 sm:left-6 z-30 max-w-[calc(100vw-2.5rem)] font-vazir select-none pb-[env(safe-area-inset-bottom,0px)]">
|
||||
<aside dir="rtl" className={`fixed ${isPdpPage ? "bottom-[138px]" : "bottom-24"} sm:bottom-6 left-4 sm:left-6 z-30 max-w-[calc(100vw-2.5rem)] font-vazir select-none pb-[env(safe-area-inset-bottom,0px)]`}>
|
||||
{/* Floating Launcher Button */}
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user