Skip to content

Commit

Permalink
Handle visiting close survey start page
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramblurr committed May 16, 2024
1 parent db9c4f8 commit 1425bca
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion resources/lang/de.edn
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
"Tut mir leid! Es ist nicht deine Schuld. Bitte kontaktieren Sie Casey und teilen Sie ihm diesen Fehlercode mit:",
:not-found-title "Nicht gefunden",
:not-found-message
"Das Gesuchte wurde nicht gefunden. Wenn Sie der Meinung sind, dass es existieren sollte, wenden Sie sich bitte an ihn und teilen Sie ihm diesen Fehlercode mit:",
"Das Gesuchte wurde nicht gefunden. Wenn Sie der Meinung sind, dass es existieren sollte, wenden Sie sich bitte an Casey und teilen Sie ihm diesen Fehlercode mit:",
:member-unique-phone "Ein Mitglied hat diese Telefonnummer bereits",
:notify "Click to notify Casey",
:member-unique-username
Expand Down
5 changes: 4 additions & 1 deletion resources/lang/en.edn
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
:error {:unknown-title "Something went wrong"
:unknown-message "Sorry about this! It's not your fault. Please contact Casey and tell him this error code:"
:not-found-title "Not Found"
:not-found-message "The thing you were looking for wasn't found. If you think it should exist, please contact and tell him this error code:"
:not-found-message "The thing you were looking for wasn't found. If you think it should exist, please contact Casey and tell him this error code:"
:unauthorized-title "Authentication failed"
:unauthorized-message "Your identity is unknown to the system.. something probably went wrong. Please contact Casey and tell him this error code:"
:go-home "Go Home"
Expand Down Expand Up @@ -531,6 +531,9 @@
:send-notifications "Send Notifications"
:edit-survey "Edit Survey"
:all-done "All Done!"
:already-closed "Already Closed"
:already-closed-hint "This insurance survey is already closed :("
:contact-insurance-team "Please contact the insurance team"
:email-title "SNO Insurance Time!"
:email-p1 "It's time to review your insured instruments/items."
:email-p2 "Or add new ones! It only takes a few minutes."
Expand Down
15 changes: 10 additions & 5 deletions src/clj/app/insurance/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@
(def policy-interceptor {:name ::insurance-policy--interceptor
:enter (fn [ctx]
(let [conn (-> ctx :request :datomic-conn)
db (d/db conn)
policy-id (-> ctx :request :path-params :policy-id)]
(cond-> ctx
policy-id (assoc-in [:request :policy] (q/retrieve-policy db (parse-uuid policy-id))))))})
db (d/db conn)]
(try
(let [policy (q/retrieve-policy db (-> ctx :request :path-params :policy-id parse-uuid))]
(assoc-in ctx [:request :policy] policy))
(catch Exception e
(throw (ex-info "Policy not found" {:app/error-type :app.error.type/not-found
:policy-id (-> ctx :request :path-params :policy-id)
:exception e}))))))})

(def coverage-interceptor {:name ::insurance-coverage--interceptor
:enter (fn [ctx]
(let [coverage-id (-> ctx :request :path-params :coverage-id)]
Expand Down Expand Up @@ -148,13 +153,13 @@
[:instrument-id :uuid]]}
:handler (fn [req] (view/instrument-image-upload-button-handler req))}}]]

(insurance-index)
["" {:app.route/name :app/insurance2
:interceptors [policy-interceptor instrument-interceptor]}
;; (ctmx/make-routes
;; "/insurance-policy-duplicate/"
;; (fn [req]
;; (view/insurance-policy-duplicate req)))
(insurance-index)
["" {:app.route/name :app/instrument.coverage
:interceptors [coverage-interceptor]}
(insurance-coverage-detail)
Expand Down
27 changes: 20 additions & 7 deletions src/clj/app/insurance/views.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2298,16 +2298,29 @@ else if @data-counter as Int is equal to 3 remove .opacity-0 from .stage-3 then
[:ul {:role "list" :class "grid grid-cols-1 gap-x-6 gap-y-8 mb-2"}
(instrument-card req active-report decisions)]]]))

(defn survey-already-closed [{:keys [tr]}]
[:div {:class (ui/cs "mx-auto max-w-2xl overflow-hidden")}
[:div {:class "bg-white min-h-80 mt-8 gap-6 p-6 flex flex-col items-center justify-center"}
[:div {:class "flex items-center justify-center text-sno-orange-500"}
[:h1 {:class "text-3xl font-bold"} (tr [:insurance.survey/already-closed])]]
[:div {:class "flex flex-col items-center"}
[:p {:class "prose"} (tr [:insurance.survey/already-closed-hint])]
[:p {:class "prose"} [:a {:href (urls/link-faq-insurance-team)} (tr [:insurance.survey/contact-insurance-team])]]]
[:div {:class "h-12"}
(ui/link-button :href "/" :size :xlarge :label (tr [:error/go-home]) :priority :white)]]])

(ctmx/defcomponent ^:endpoint survey-start-page [{:keys [db tr] :as req}]
survey-flow-progress
survey-edit-instrument-handler
(let [policy (:policy req)
{:as data :keys [active-report todo-reports total-reports total-todo current-idx new-step?]} (prepare-next-active-report req policy)
{:keys [start-flow] :as flow} (build-survey-flow req)]
(if (= 0 total-todo)
(survey-report-interstitial (util/make-get-request req {:transitioning? true}))
[:div {:id :comp/survey-page}
[:div {:class (ui/cs "flex justify-center items-center mt-10" (when new-step? "steps-new-step"))}
(ui/step-circles total-reports current-idx)]
[:div {:class "survey-panel-fade-in"}
(survey-question-page req flow [] active-report start-flow)]])))
(if (some? active-report)
(if (= 0 total-todo)
(survey-report-interstitial (util/make-get-request req {:transitioning? true}))
[:div {:id :comp/survey-page}
[:div {:class (ui/cs "flex justify-center items-center mt-10" (when new-step? "steps-new-step"))}
(ui/step-circles total-reports current-idx)]
[:div {:class "survey-panel-fade-in"}
(survey-question-page req flow [] active-report start-flow)]])
(survey-already-closed req))))
2 changes: 2 additions & 0 deletions src/clj/app/urls.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
(defn link-insurance-survey-start [policy-id]
(str "/insurance-survey/" policy-id "/"))

(defn link-faq-insurance-team [] "/insurance/#faq10")

(defn link-insurance-add-coverage [policy-id]
(str "/insurance-coverage-create/" policy-id "/"))

Expand Down

0 comments on commit 1425bca

Please sign in to comment.