You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

291 lines
7.2 KiB

import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { ShippingAddressOption } from '../../data/checkoutData';
import { tr } from '../../lib/cookies';
import { ROUTES } from '../../lib/routes';
interface AddressCardProps {
item: ShippingAddressOption;
variant: 'checkout' | 'manage';
onSelect?: () => void;
onEdit?: () => void;
onDelete?: () => void;
onChangeAddressClick?: () => void;
}
export const AddressCard: React.FC<AddressCardProps> = ({
item,
variant,
onSelect,
onEdit,
onDelete,
onChangeAddressClick,
}) => {
const navigate = useNavigate();
return (
<div
onClick={onSelect}
style={{
width: '100%',
minHeight: '87px',
padding: '12px',
borderRadius: '15px',
background: item.selected
? 'linear-gradient(180deg, #fff7e9 0%, #fdf9f4 100%)'
: '#ffffff',
border: item.selected ? '1px solid #d78e06' : undefined,
cursor: onSelect ? 'pointer' : 'default',
display: 'flex',
alignItems: 'flex-start',
gap: '14px',
}}
>
{/* Radio Indicator 20x20 */}
<div
style={{
width: '20px',
height: '20px',
borderRadius: '10px',
backgroundColor: item.selected ? '#d78e06' : 'transparent',
border: item.selected ? undefined : '1px solid #dbdbdb',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
transition: 'background-color 180ms ease, border-color 180ms ease',
}}
>
{item.selected && (
<div
className="habib-radio-dot"
style={{
width: '8px',
height: '8px',
borderRadius: '50%',
backgroundColor: '#ffffff',
}}
/>
)}
</div>
{/* Right Content */}
<div
style={{
flex: 1,
minWidth: 0,
display: 'flex',
flexDirection: 'column',
gap: '8px',
}}
>
{/* Top Row */}
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
gap: '8px',
minHeight: variant === 'manage' ? '24px' : '20px',
}}
>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: '12px',
lineHeight: '17px',
color: '#292a2e',
}}
>
{item.name}
</span>
{variant === 'checkout' ? (
<span
onClick={(e) => {
e.stopPropagation();
if (onChangeAddressClick) {
onChangeAddressClick();
} else {
navigate(ROUTES.addresses);
}
}}
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 600,
fontSize: '8.5px',
lineHeight: '12.52px',
color: '#d78e06',
textAlign: 'center',
cursor: 'pointer',
flexShrink: 0,
}}
>
{tr('Change Adress')}
</span>
) : (
<div
style={{
position: 'relative',
width: '84.66px',
height: '24px',
flexShrink: 0,
}}
>
<img
src="/assets/images/icon-address-delete-edit-pair.svg"
alt="Delete or Edit"
style={{
width: '84.66px',
height: '24px',
display: 'block',
}}
/>
{onDelete && (
<button
type="button"
aria-label="Delete Address"
onClick={(e) => {
e.stopPropagation();
onDelete();
}}
style={{
position: 'absolute',
left: 0,
top: 0,
width: '42px',
height: '24px',
cursor: 'pointer',
}}
/>
)}
{onEdit && (
<button
type="button"
aria-label="Edit Address"
onClick={(e) => {
e.stopPropagation();
onEdit();
}}
style={{
position: 'absolute',
right: 0,
top: 0,
width: '42px',
height: '24px',
cursor: 'pointer',
}}
/>
)}
</div>
)}
</div>
{/* Address Text */}
<div
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 400,
fontSize: '12px',
lineHeight: '18px',
color: 'var(--color-text-charcoal)',
wordBreak: 'break-word',
}}
>
{item.address}
</div>
</div>
</div>
);
};
interface AddNewAddressCardProps {
left?: number;
top?: number;
onClick?: () => void;
}
export const AddNewAddressCard: React.FC<AddNewAddressCardProps> = ({ onClick }) => {
return (
<div
onClick={onClick}
style={{
width: '100%',
minHeight: '53px',
padding: '12px',
borderRadius: '15px',
border: '1px solid #d7dbe2',
cursor: onClick ? 'pointer' : 'default',
display: 'flex',
alignItems: 'center',
gap: '14px',
}}
>
<div
style={{
width: '28px',
height: '28px',
borderRadius: '20px',
backgroundColor: '#dbdbdb',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
}}
>
<img
src="/assets/images/icon-plus-gold-16.svg"
alt="+"
style={{
width: '16px',
height: '16px',
}}
/>
</div>
<div
style={{
flex: 1,
minWidth: 0,
display: 'flex',
flexDirection: 'column',
gap: '1px',
}}
>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 700,
fontSize: '12px',
lineHeight: '17px',
color: '#36363c',
}}
>
{tr('Add New adress')}
</span>
<span
style={{
fontFamily: 'var(--font-sans)',
fontWeight: 400,
fontSize: '10px',
lineHeight: '12.9px',
color: '#8b8b8b',
}}
>
{tr('Add New Delivery adress')}
</span>
</div>
<img
src="/assets/images/icon-arrow-right-circle-light.svg"
alt=""
style={{
width: '24px',
height: '24px',
flexShrink: 0,
}}
/>
</div>
);
};