Check types for view

This commit is contained in:
Marcus Kammer 2024-06-02 14:38:27 +02:00
parent 2a314583d6
commit cdb8381dfe
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -1,24 +1,24 @@
(in-package :ml-survey/views) (in-package :ml-survey/views)
(defun survey (survey) (defun survey (id properties)
"Generates the view to show the survey created." "Generates the view to show the survey created."
(let ((id (format nil "~a" (first survey))) (check-type id string)
(properties (first (rest survey)))) (check-type properties list)
(with-page (:title "Surveys") (with-page (:title "Surveys")
(navbar-en) (navbar-en)
(:section :class "container" (:section :class "container"
(:h2 id) (:h2 id)
(:table :class "table" (:table :class "table"
(:thead :class "thead-dark" (:thead :class "thead-dark"
(:tr (:th :scope "col" (:tr (:th :scope "col"
"Key") "Key")
(:th :scope "col" (:th :scope "col"
"Value"))) "Value")))
(:tbody (loop for property in properties (:tbody (loop for property in properties
for key = (car property) for key = (car property)
for value = (cdr property) do for value = (cdr property) do
(:tr (:td key) (:tr (:td key)
(:td (if (string= key "questionnaire") (:td (if (string= key "questionnaire")
(:a :href (concatenate 'string "/survey/" id value) (:a :href (concatenate 'string "/survey/" id value)
value) value)
value)))))))))) value)))))))))