From 407d0aeecfe804dd890e75ea71bd29a9c7900f4f Mon Sep 17 00:00:00 2001 From: Tina_Azure <-> Date: Tue, 4 Apr 2023 22:40:27 +0200 Subject: [PATCH] +++ /customer/$freelancer/template/$templateName Route handling the display of a Template And minor fix enabling the root route to handle post --- src/main.cpp | 29 ++++++++++++++++++++- templates/customer_Freelancer_Template.html | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 40dda2f..968b4cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ int main() { /* * Freelancer Profile listing for customers */ - CROW_ROUTE(app, "/") + CROW_ROUTE(app, "/").methods("POST"_method) ([databaseURI]() { pqxx::connection databaseConnection(databaseURI); pqxx::result result = Database::executeStatement_SELECT_FREELANCERS_WITHCOMMISSIONSSTATE(databaseConnection); @@ -79,6 +79,33 @@ int main() { }); + /* + * Page representing a freelancers Template + */ + CROW_ROUTE(app, "/customer//template/").methods("POST"_method) + ([databaseURI](const crow::request& postRequest, string freelancerName, string templateName ) { + int templateID = stoi(Utilities::extractSingleValueFromRequestBody(postRequest.body.c_str(), "templateID")); + + pqxx::connection databaseConnection(databaseURI); + pqxx::result resultTemplate = Database::executePreparedStatement_SELECT_TEMPLATE(databaseConnection, templateID); + + crow::json::wvalue resultJsonTemplate = Database::convertResultRowToJSON(resultTemplate); + + string templateHTML = "customer_Freelancer_Template.html"; + auto page = crow::mustache::load(templateHTML); + + crow::mustache::context ctx(resultJsonTemplate); + return page.render(ctx); + }); + + + + + + + + + diff --git a/templates/customer_Freelancer_Template.html b/templates/customer_Freelancer_Template.html index 202072f..9a39503 100644 --- a/templates/customer_Freelancer_Template.html +++ b/templates/customer_Freelancer_Template.html @@ -48,7 +48,7 @@ -
+