forked from casdoor/casdoor
fix: add CreatedTime field to cart items and sort by timestamp (#5066)
This commit is contained in:
@@ -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"`
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: "",
|
||||
|
||||
Reference in New Issue
Block a user