From 9bf0cdbbd3e273da1bac7e3f4eb295769f194380 Mon Sep 17 00:00:00 2001
From: Dominik Hebeler <dominik@suma-ev.de>
Date: Thu, 30 May 2024 11:52:21 +0200
Subject: [PATCH] better formating of pp data

---
 pass/public/styles/admin/key-overview.less | 40 +++++++++++++++++-----
 pass/routes/admin/index.js                 |  3 ++
 2 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/pass/public/styles/admin/key-overview.less b/pass/public/styles/admin/key-overview.less
index b688183..a704b95 100644
--- a/pass/public/styles/admin/key-overview.less
+++ b/pass/public/styles/admin/key-overview.less
@@ -1,22 +1,28 @@
 #admin-container {
   display: grid;
   gap: 1rem;
+
   .breadcrumps {
     margin: 0;
   }
+
   #key-info {
     display: grid;
     gap: 0.5rem;
+
     h2 {
       margin: 0;
     }
+
     .charge-success {
       color: green;
     }
+
     #charges {
       display: flex;
       gap: 1rem;
       flex-wrap: wrap;
+
       .charge {
         display: grid;
         gap: 0.5rem;
@@ -25,26 +31,31 @@
         width: max-content;
         padding: 1rem;
         border-radius: 5px;
+
         .charge-amount {
           font-size: 2rem;
         }
       }
     }
   }
+
   form#charge-form {
     display: grid;
     grid-template-columns: repeat(3, auto);
 
     gap: 1rem;
     place-items: center;
+
     .heading,
     .hint,
     .button,
     #errors {
       grid-column: span 3;
     }
+
     @media (max-width: 530px) {
       grid-template-columns: auto;
+
       .heading,
       .hint,
       .button,
@@ -52,25 +63,31 @@
         grid-column: 1;
       }
     }
+
     h3 {
       margin: 0;
     }
+
     #errors {
       list-style-type: none;
       padding: 0;
       color: red;
     }
+
     .button {
       padding: 0.5rem;
       cursor: pointer;
     }
+
     .input-group {
       display: grid;
       place-items: center;
       gap: 0.5rem;
-      > label {
+
+      >label {
         font-weight: bold;
       }
+
       input {
         padding: 0.25rem 0.5rem;
         border-radius: 5px;
@@ -81,29 +98,34 @@
   div#payments {
     display: grid;
     gap: 3rem;
-    > h1 {
+
+    >h1 {
       margin: 0;
       text-align: center;
     }
-    > div.payment {
+
+    >div.payment {
       display: grid;
       gap: 0.5rem;
       grid-template-columns: repeat(5, 1fr);
-      > div {
+
+      >div {
         white-space: nowrap;
       }
-      > details.payment_processor_data {
+
+      >details.payment_processor_data {
         grid-column: span 5;
-        > summary {
+
+        >summary {
           text-align: center;
         }
-        > p {
+
+        >p {
           white-space: pre-wrap;
-          background-color: #f5f5f5;
           border: 1px solid #777;
           padding: 1rem;
         }
       }
     }
   }
-}
+}
\ No newline at end of file
diff --git a/pass/routes/admin/index.js b/pass/routes/admin/index.js
index 1f83af3..aeceb1c 100644
--- a/pass/routes/admin/index.js
+++ b/pass/routes/admin/index.js
@@ -18,6 +18,7 @@ const Receipt = require("../../app/Receipt");
 const Cash = require("../../app/payment_processor/Cash");
 const Key = require("../../app/Key");
 const Paypal = require("../../app/payment_processor/Paypal");
+const Micropayment = require("../../app/payment_processor/Micropayment");
 
 router.use((req, res, next) => {
   let cookie_path = new URL(res.locals.baseDir).pathname.replace(
@@ -394,6 +395,8 @@ router.use("/key/:key", (req, res, next) => {
                 payments[
                   j
                 ].payment_processor_id = `<a href=\"https://${host}/activity/payment/${payments[j].payment_processor_id}\" target=\"_blank\">${payments[j].payment_processor_id}</a>`;
+              } else if (payments[j].payment_processor instanceof Micropayment) {
+                payments[j].payment_processor_data = JSON.stringify(JSON.parse(payments[j].payment_processor_data), null, 4);
               }
               res.locals.payments.push(payments[j]);
             }
-- 
GitLab