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