Skip to content

Commit

Permalink
WIP eoris in qr
Browse files Browse the repository at this point in the history
  • Loading branch information
Remco van 't Veer committed Jun 13, 2024
1 parent 12aad98 commit 3e7f578
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
20 changes: 13 additions & 7 deletions src/dil_demo/otm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,22 @@
(filter pred)
(map :entity)))

(defn trip-carrier-eori-list
"Return list of carrier/subcontractors EORIs."
[trip]
(->> (trip-actors trip #(seq (intersection (:roles %)
#{role-carrier
role-subcontractor})))
(map (fn [{:keys [contact-details]}]
(->> contact-details
(filter #(= contact-details-type-eori (:type %)))
(first)
:value)))))

(defn trip-carrier-eori
"Return EORI of last carrier/subcontractor."
[trip]
(let [carriers (trip-actors trip #(seq (intersection (:roles %)
#{role-carrier
role-subcontractor})))]
(->> (-> carriers (last) :contact-details)
(filter #(= contact-details-type-eori (:type %)))
(first)
:value)))
(last (trip-carrier-eori-list trip)))

(defn trip-add-subcontractor! [trip subco-eori]
(update trip :actors
Expand Down
51 changes: 28 additions & 23 deletions src/dil_demo/tms/web.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@
[:li [:a.button.button-secondary {:href (str "outsource-" id)} "Outsource"]])
[:li (w/delete-button (str "trip-" id))]]]])]])

(defn qr-code-dil-demo [{:keys [carrier-eori driver-id-digits license-plate]}]
(w/qr-code (str ":dil-demo:" carrier-eori ":" driver-id-digits ":" license-plate)))
(defn qr-code-dil-demo [trip]
(let [carrier-eori-list (otm/trip-carrier-eori-list trip)
driver-id-digits (otm/trip-driver-id-digits trip)
license-plate (otm/trip-license-plate trip)]
(w/qr-code (str ":dil-demo"
":" (string/join "," carrier-eori-list)
":" driver-id-digits
":" license-plate))))

(defn chauffeur-list-trips [trips {:keys [warehouses]}]
(if (seq trips)
Expand All @@ -71,7 +77,7 @@

(defn chauffeur-trip [trip]
[:div.trip
(qr-code-dil-demo (otm/trip->map trip))
(qr-code-dil-demo trip)
[:div.actions
[:a.button {:href "../chauffeur/"} "Terug naar overzicht"]]])

Expand Down Expand Up @@ -108,13 +114,13 @@
[:blockquote.remarks unload-remarks])]]]))

(defn assign-trip [trip master-data]
(let [{:keys [carrier-eori driver-id-digits license-plate] :as params}
(let [{:keys [carrier-eori driver-id-digits license-plate]}
(otm/trip->map trip)]
[:form {:method "POST"}
(w/anti-forgery-input)

(when (and carrier-eori driver-id-digits license-plate)
(qr-code-dil-demo params))
(qr-code-dil-demo trip))

(trip-details trip master-data)

Expand All @@ -130,26 +136,25 @@
[:a.button {:href "."} "Annuleren"]]]))

(defn assigned-trip [trip {:keys [ishare-log]}]
(let [{:keys [ref] :as params} (otm/trip->map trip)]
[:div
[:section
[:p "Transportopdracht " [:q ref] " toegewezen."]
[:div
[:section
[:p "Transportopdracht " [:q (otm/trip-ref trip)] " toegewezen."]

(qr-code-dil-demo params)
(qr-code-dil-demo trip)

[:div.actions
[:a.button {:href "."} "Terug naar overzicht"]]]
[:details.explanation
[:summary "Uitleg"]
[:ol
[:li
[:h3 "Autoriseer de Chauffeur names de Vervoerder voor de Klantorder vervoerd met Kenteken"]
[:p "API call naar " [:strong "AR van de Vervoerder"] " om een autorisatie te registeren"]
[:ul [:li "Klantorder nr."] [:li "Rijbewijs (laatste 4 cijfers)"] [:li "Kenteken"]]]
[:li
[:h3 "OTM Trip"]
[:pre.json (w/to-json trip)]]
(w/ishare-log-intercept-to-hiccup ishare-log)]]]))
[:div.actions
[:a.button {:href "."} "Terug naar overzicht"]]]
[:details.explanation
[:summary "Uitleg"]
[:ol
[:li
[:h3 "Autoriseer de Chauffeur names de Vervoerder voor de Klantorder vervoerd met Kenteken"]
[:p "API call naar " [:strong "AR van de Vervoerder"] " om een autorisatie te registeren"]
[:ul [:li "Klantorder nr."] [:li "Rijbewijs (laatste 4 cijfers)"] [:li "Kenteken"]]]
[:li
[:h3 "OTM Trip"]
[:pre.json (w/to-json trip)]]
(w/ishare-log-intercept-to-hiccup ishare-log)]]])

(defn outsource-trip [trip {:keys [carriers] :as master-data}]
[:form {:method "POST"}
Expand Down

0 comments on commit 3e7f578

Please sign in to comment.