loyalty points
This commit is contained in:
@@ -267,7 +267,8 @@ public class AuthController {
|
|||||||
user.getRole().name(),
|
user.getRole().name(),
|
||||||
customerId,
|
customerId,
|
||||||
primaryStore != null ? primaryStore.getStoreId() : null,
|
primaryStore != null ? primaryStore.getStoreId() : null,
|
||||||
primaryStore != null ? primaryStore.getStoreName() : null
|
primaryStore != null ? primaryStore.getStoreName() : null,
|
||||||
|
user.getLoyaltyPoints()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,12 @@ public class UserInfoResponse {
|
|||||||
private Long customerId;
|
private Long customerId;
|
||||||
private Long storeId;
|
private Long storeId;
|
||||||
private String storeName;
|
private String storeName;
|
||||||
|
private Integer loyaltyPoints;
|
||||||
|
|
||||||
public UserInfoResponse() {
|
public UserInfoResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfoResponse(Long id, String username, String firstName, String lastName, String email, String fullName, String phone, String avatarUrl, String role, Long customerId, Long storeId, String storeName) {
|
public UserInfoResponse(Long id, String username, String firstName, String lastName, String email, String fullName, String phone, String avatarUrl, String role, Long customerId, Long storeId, String storeName, Integer loyaltyPoints) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.firstName = firstName;
|
this.firstName = firstName;
|
||||||
@@ -32,6 +33,7 @@ public class UserInfoResponse {
|
|||||||
this.customerId = customerId;
|
this.customerId = customerId;
|
||||||
this.storeId = storeId;
|
this.storeId = storeId;
|
||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
|
this.loyaltyPoints = loyaltyPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@@ -131,6 +133,14 @@ public class UserInfoResponse {
|
|||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getLoyaltyPoints() {
|
||||||
|
return loyaltyPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoyaltyPoints(Integer loyaltyPoints) {
|
||||||
|
this.loyaltyPoints = loyaltyPoints;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ function PaymentForm({ clientSecret, totalAmount, onSuccess, onCancel }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function CartPage() {
|
export default function CartPage() {
|
||||||
const { user, loading: authLoading } = useAuth();
|
const { user, loading: authLoading, refreshUser } = useAuth();
|
||||||
const {
|
const {
|
||||||
cart,
|
cart,
|
||||||
cartLoading,
|
cartLoading,
|
||||||
@@ -373,6 +373,12 @@ export default function CartPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{user?.role === "CUSTOMER" && (
|
||||||
|
<div className="cart-points-estimate">
|
||||||
|
⭐ Earn <strong>{Math.floor(parseFloat(cart.totalAmount ?? 0))}</strong> loyalty point{Math.floor(parseFloat(cart.totalAmount ?? 0)) !== 1 ? "s" : ""} with this purchase
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="cart-coupon-section">
|
<div className="cart-coupon-section">
|
||||||
{cart.couponCode && (
|
{cart.couponCode && (
|
||||||
<div className="cart-coupon-applied">
|
<div className="cart-coupon-applied">
|
||||||
@@ -444,6 +450,7 @@ export default function CartPage() {
|
|||||||
onSuccess={() => {
|
onSuccess={() => {
|
||||||
setClientSecret(null);
|
setClientSecret(null);
|
||||||
setConfirmed(true);
|
setConfirmed(true);
|
||||||
|
refreshUser().catch(() => {});
|
||||||
}}
|
}}
|
||||||
onCancel={async () => {
|
onCancel={async () => {
|
||||||
await cancelCheckout().catch(() => {});
|
await cancelCheckout().catch(() => {});
|
||||||
|
|||||||
@@ -2413,6 +2413,16 @@ body {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cart-points-estimate {
|
||||||
|
background: #fffbeb;
|
||||||
|
border: 1px solid #fde68a;
|
||||||
|
color: #92400e;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0.5rem 0.85rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.cart-coupon-section {
|
.cart-coupon-section {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -396,6 +396,7 @@ export default function ProfilePage() {
|
|||||||
{label: "Email", value: user.email},
|
{label: "Email", value: user.email},
|
||||||
{label: "Phone", value: user.phone || "N/A"},
|
{label: "Phone", value: user.phone || "N/A"},
|
||||||
...(user.storeName ? [{ label: "Store", value: user.storeName }] : []),
|
...(user.storeName ? [{ label: "Store", value: user.storeName }] : []),
|
||||||
|
...(user.role === "CUSTOMER" ? [{ label: "Loyalty Points", value: user.loyaltyPoints ?? 0 }] : []),
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user