fix: add CreatedTime field to cart items and sort by timestamp (#5066)

This commit is contained in:
Yang Luo
2026-02-13 10:36:20 +08:00
parent 80b4c0b1a7
commit 6a90d21941
4 changed files with 10 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ type Order struct {
type ProductInfo struct {
Owner string `json:"owner"`
Name string `json:"name"`
CreatedTime string `json:"createdTime,omitempty"`
DisplayName string `json:"displayName"`
Image string `json:"image,omitempty"`
Detail string `json:"detail,omitempty"`

View File

@@ -445,6 +445,7 @@ class CartListPage extends BaseListPage {
}
return {
...pRes.data,
createdTime: item.createdTime,
pricingName: item.pricingName,
planName: item.planName,
quantity: item.quantity,
@@ -482,6 +483,10 @@ class CartListPage extends BaseListPage {
const comparison = aValue > bValue ? 1 : -1;
return params.sortOrder === "ascend" ? comparison : -comparison;
});
} else {
sortedData.sort((a, b) => {
return b.createdTime - a.createdTime;
});
}
this.setState({

View File

@@ -14,6 +14,7 @@
import React from "react";
import {Button, Descriptions, Divider, InputNumber, Radio, Space, Spin, Typography} from "antd";
import moment from "moment";
import i18next from "i18next";
import * as ProductBackend from "./backend/ProductBackend";
import * as PlanBackend from "./backend/PlanBackend";
@@ -207,6 +208,7 @@ class ProductBuyPage extends React.Component {
} else {
const newProductInfo = {
name: product.name,
createdTime: moment().format(),
price: cartPrice,
currency: product.currency,
pricingName: pricingName,

View File

@@ -14,6 +14,7 @@
import React from "react";
import {Button, Card, Col, Row, Tag, Typography} from "antd";
import moment from "moment";
import * as Setting from "./Setting";
import * as ProductBackend from "./backend/ProductBackend";
import * as UserBackend from "./backend/UserBackend";
@@ -140,6 +141,7 @@ class ProductStorePage extends React.Component {
} else {
const newCartProductInfo = {
name: product.name,
createdTime: moment().format(),
currency: product.currency,
pricingName: "",
planName: "",