set address as default
This commit is contained in:
@@ -4,6 +4,7 @@ import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import Button from '@/components/button/PrimaryButton';
|
||||
import { useGetFoods } from '@/app/[name]/(Main)/hooks/useMenuData';
|
||||
import type { Food } from '@/app/[name]/(Main)/types/Types';
|
||||
import { useCart } from '../hook/useCart';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Add, Minus } from 'iconsax-react';
|
||||
@@ -26,7 +27,7 @@ const CartSummary = ({ description = '', onDescriptionChange }: CartSummaryProps
|
||||
.map(([id]) =>
|
||||
foods.find((foodItem) => String(foodItem.id) === String(id))
|
||||
)
|
||||
.filter((food) => Boolean(food));
|
||||
.filter((food): food is Food => Boolean(food));
|
||||
}, [foods, items]);
|
||||
|
||||
const totalPrice = React.useMemo(() => {
|
||||
|
||||
@@ -15,6 +15,7 @@ import useToggle from '@/hooks/helpers/useToggle';
|
||||
type Props = object
|
||||
|
||||
function UserAddressesPage({ }: Props) {
|
||||
|
||||
const { data: addressesResponse, isLoading } = useGetAddresses();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
@@ -101,7 +102,7 @@ function UserAddressesPage({ }: Props) {
|
||||
addresses.map((address) => (
|
||||
<div
|
||||
key={address.id}
|
||||
className={`bg-container rounded-container w-full shadow-xl px-4 py-4 flex flex-col justify-between ${address.isDefault ? 'ring-2 ring-primary' : ''}`}
|
||||
className={`bg-container rounded-container w-full shadow-xl px-4 py-4 flex flex-col justify-between ${address.isDefault ? 'border border-primary' : ''}`}
|
||||
>
|
||||
<div className="flex justify-between items-start mb-2">
|
||||
<h2 className='text-sm font-medium'>{address.title}</h2>
|
||||
|
||||
@@ -27,6 +27,6 @@ export const deleteAddress = async (id: string) => {
|
||||
};
|
||||
|
||||
export const setDefaultAddress = async (id: string) => {
|
||||
const { data } = await api.patch(`/public/user/addresses/${id}/set-default`);
|
||||
const { data } = await api.patch(`/public/user/addresses/${id}/default`);
|
||||
return data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user