diff --git a/frontend/admin-panel/src/pages/Products.tsx b/frontend/admin-panel/src/pages/Products.tsx
index e2db20a..8c390e3 100644
--- a/frontend/admin-panel/src/pages/Products.tsx
+++ b/frontend/admin-panel/src/pages/Products.tsx
@@ -172,6 +172,7 @@ export default function Products() {
await api.post('/admin/products', finalPayload);
}
setIsModalOpen(false);
+ setImageErrors({});
fetchData();
} catch (error) {
console.error('Save failed', error);
@@ -183,6 +184,7 @@ export default function Products() {
if (!window.confirm('آیا از حذف این محصول مطمئن هستید؟')) return;
try {
await api.delete(`/admin/products/${id}`);
+ setImageErrors({});
fetchData();
} catch (error) {
console.error('Delete failed', error);
@@ -261,12 +263,14 @@ export default function Products() {
{product.imageUrl && !imageErrors[product.id] ? (
- setImageErrors(prev => ({ ...prev, [product.id]: true }))}
- className="w-12 h-12 rounded-xl object-cover border border-gray-200"
- />
+
+ }) setImageErrors(prev => ({ ...prev, [product.id]: true }))}
+ className="max-w-full max-h-full object-contain object-center"
+ />
+
) : (
diff --git a/frontend/application/components/CheckoutPage.tsx b/frontend/application/components/CheckoutPage.tsx
index d103778..0554692 100644
--- a/frontend/application/components/CheckoutPage.tsx
+++ b/frontend/application/components/CheckoutPage.tsx
@@ -29,7 +29,7 @@ export default function CheckoutPage() {
const router = useRouter();
const { items, getTotal, getSubtotal, getDiscount, isSubscribed, charityDonation, setCharityDonation, addOrder, clearCart } = useCartStore();
const { getActivePet, updatePet } = usePetStore();
- const { profile, updateProfile } = useUserStore();
+ const { profile, isLoggedIn, updateProfile } = useUserStore();
const [step, setStep] = useState(1);
const [loading, setLoading] = useState(false);
const [useRoundUp, setUseRoundUp] = useState(false);
@@ -48,15 +48,17 @@ export default function CheckoutPage() {
productService.getProducts({ limit: 999 }).then(res => setDbProducts(res.data));
// Set default selected address if logged in
- if (profile.addresses && profile.addresses.length > 0) {
+ if (isLoggedIn && profile.addresses && profile.addresses.length > 0) {
const def = profile.addresses.find(a => a.isDefault) || profile.addresses[0];
setSelectedAddressId(def.id);
- } else if (profile.firstName) {
+ } else if (isLoggedIn && profile.firstName) {
// Pre-fill profile info for manual fields
setManualName(`${profile.firstName} ${profile.lastName}`.trim());
setManualPhone(profile.mobile || '');
+ } else {
+ setSelectedAddressId('');
}
- }, [profile]);
+ }, [profile, isLoggedIn]);
const subtotal = getSubtotal();
const roundedAmount = Math.ceil(subtotal / 10000) * 10000;
@@ -210,7 +212,7 @@ export default function CheckoutPage() {
اطلاعات ارسال
- {profile.addresses && profile.addresses.length > 0 && !showNewAddressForm ? (
+ {isLoggedIn && profile.addresses && profile.addresses.length > 0 && !showNewAddressForm ? (
انتخاب از بین آدرسهای ذخیرهشده شما:
diff --git a/frontend/application/lib/services/orderService.ts b/frontend/application/lib/services/orderService.ts
index f976f57..816c3a9 100644
--- a/frontend/application/lib/services/orderService.ts
+++ b/frontend/application/lib/services/orderService.ts
@@ -38,6 +38,12 @@ export class OrderService {
*/
public async createOrder(orderData: {
petId?: string;
+ couponCode?: string;
+ prescriptionUrl?: string;
+ charityDonation?: number;
+ isRefill?: boolean;
+ refillIntervalDays?: number;
+ shippingAddress?: string;
items: { productId: string; quantity: number }[];
}): Promise {
try {
|