pull/208/head
larteyoh 8 months ago
parent 76e981a9e3
commit 101502e4d6

@ -96,7 +96,7 @@ GridView {
}
onClicked: {
navBar.uncheckAllButtons() // Uncheck all navigational buttons
pageStack.pushPageWithProperties("qrc:/qml/pages/ProductPage.qml", { "model": modelData })
pageStack.pushPageWithProperties("qrc:/qml/pages/ProductPage.qml", { "model": modelData, "starModel": starsRect.product_ratings_model })
}
cursorShape: Qt.PointingHandCursor
}

@ -16,6 +16,7 @@ Page {
color: "transparent"
}
property var model: null
property var starModel: null
function openSellerPage() {
pageStack.pushPageWithProperties("qrc:/qml/pages/ProfilePage.qml", {"productModel": productPage.model})
}
@ -202,8 +203,8 @@ Page {
Row {
id: starsRow
//spacing: 5
property real avg_stars: Backend.getProductAverageStars(productPage.model.listing_uuid)
property int star_ratings_count: Backend.getProductStarCount(productPage.model.listing_uuid)
property real avg_stars: Backend.getProductAverageStars(productPage.starModel)
property int star_ratings_count: Backend.getProductStarCount(productPage.starModel)
//Component.onCompleted: console.log("avg stars", starsRow.avg_stars)
Repeater {
model: 5
@ -421,6 +422,7 @@ Page {
property string color: "#53469f"
property string lightColor: "#6c60b9"
property string darkColor: "#483d8b"
enabled: false
background: Rectangle {
color: parent.hovered ? (parent.down ? rateProductButton.darkColor : rateProductButton.lightColor) : rateProductButton.color
border.color: rateProductButton.darkColor

@ -75,6 +75,7 @@ public:
friend class Seller;
friend class Order;
friend class Serializer;
friend class Backend;
private:
std::string id;
std::string owner_id;

@ -118,6 +118,19 @@ void neroshop::Mapper::add(const std::string& key, const std::string& value) {
std::string order_id = json["id"].get<std::string>();
order_ids[order_id].push_back(key);
}
/*// Map seller_ids to orders
if(json.contains("items") && json["items"].is_array()) {
const auto& order_items = json["items"];
for (const auto& item : order_items) {
assert(item.is_object());
if (item.contains("seller_id") && item["seller_id"].is_string()) {
std::string seller_id = item["seller_id"].get<std::string>();
order_recipients[seller_id].push_back(key);
std::cout << "seller_id (" << seller_id << ") has been mapped to order key (" << key << ")\n";
}
}
}*/
}
//-----------------------------------------------
if(metadata == "product_rating") {

@ -195,11 +195,11 @@ std::pair<std::string, std::string/*std::vector<uint8_t>*/> neroshop::Serializer
json_object["items"].push_back(order_item_obj); // order_items // TODO: encrypt order items
}
json_object["metadata"] = "order";
nlohmann::json settings_json = nlohmann::json::parse(neroshop::load_json(), nullptr, false);
if(settings_json.is_discarded()) {
nlohmann::json settings = nlohmann::json::parse(neroshop::load_json(), nullptr, false);
if(settings.is_discarded()) {
json_object["expiration_date"] = neroshop::timestamp::get_utc_timestamp_after_duration(2, "year"); // default: 2 years
} else {
std::string expires_in = settings_json["data_expiration"]["order"].get<std::string>();
std::string expires_in = settings["data_expiration"]["order"].get<std::string>();
std::regex pattern("(\\d+) (\\w+)"); // Regular expression to match number followed by text
std::smatch match;
if (std::regex_search(expires_in, match, pattern)) {

@ -490,12 +490,11 @@ void neroshop::User::send_message(const std::string& recipient_id, const std::st
data["recipient_id"] = recipient_id;
data["timestamp"] = neroshop::timestamp::get_current_utc_timestamp();
data["metadata"] = "message";
nlohmann::json settings_json = nlohmann::json::parse(neroshop::load_json(), nullptr, false);
if(settings_json.is_discarded()) {
nlohmann::json settings = nlohmann::json::parse(neroshop::load_json(), nullptr, false);
if(settings.is_discarded()) {
data["expiration_date"] = neroshop::timestamp::get_utc_timestamp_after_duration(30, "day"); // default: 30 days
} else {
nlohmann::json message_expiration = settings_json["data_expiration"]["message"].get<std::string>();
std::string expires_in = message_expiration.dump();
std::string expires_in = settings["data_expiration"]["message"].get<std::string>();
if(neroshop::string::contains(expires_in, "Never")) return;
std::regex pattern("(\\d+) (\\w+)"); // Regular expression to match number followed by text
std::smatch match;

@ -1774,6 +1774,8 @@ QVariantList neroshop::Backend::registerUser(WalletController* wallet_controller
QString cart_uuid = QUuid::createUuid().toString();
cart_uuid = cart_uuid.remove("{").remove("}"); // remove brackets
database->execute_params("INSERT INTO cart (uuid, user_id) VALUES ($1, $2)", { cart_uuid.toStdString(), user_controller->_user->get_id() });
// Set cart id
user_controller->_user->get_cart()->set_id(cart_uuid.toStdString());
//---------------------------------------------
emit user_controller->userChanged();
emit user_controller->userLogged();

Loading…
Cancel
Save