jacekschae/learn-reagent-course-files

upsert-gig inserts nil id

dmrq70 opened this issue · 4 comments

I'm getting an error in the browser console for duplicate keys, I believe it's because in upsert-gig, id is only set to random-uuid inside the map but the key for the assoc remains nil.

I think it should something like:

upsert-gig (fn [{:keys [id title desc price img sold-out]}]
                     (let [id (or id (str "gig-" (random-uuid)))]
                       (swap! state/gigs assoc id {:id id
                                                   :title (str/trim title)
                                                   :desc (str/trim desc)
                                                   :img (str/trim img)
                                                   :price (js/parseInt price)
                                                   :sold-out sold-out}))
                       (toggle-modal {:active false :gig {}}))

Hey there,
It's fixed in following videos, early catch 👍

Enjoy the course!

@dmrq70 can we close this now?

Sorry, only checked in one or two of the following 'increments'.

@dmrq70 no problem at all.