<commit_before>(ns ikea-clojure-cup.regions
  (:require [reagent.core :as reagent :refer [atom]]
            [ajax.core :refer [GET]]
            [reagent-forms.core :refer [bind-fields]]
            [alandipert.storage-atom :refer [local-storage]]
            [ikea-clojure-cup.common :as common]
            [ikea-clojure-cup.bootstrap :as bootstrap]))

(defonce region-state (local-storage (atom {:region nil}) :region))

(defn- fetch-regions
  [region-state]
  (GET "/ikea/regions"
       :handler (fn [resp]
                  (swap! region-state assoc :all-regions resp))))

(defn- region-selector*
  [region-state]
  (if-let [all-regions (seq (:all-regions @region-state))]
    [:form
     [bind-fields
      [bootstrap/input {:id :sel-region :field :list :type "select"}
       (for [region all-regions]
         [:option {:key region :value region} (:name region)])]
      region-state]]
    [:span.loading "Fetching available regions..."]))

(defn- region-selector
  [region-state]
  [(with-meta region-selector* {:component-did-mount (partial fetch-regions region-state)})
   region-state])

(defn- region-confirm
  [region-state]
  [bootstrap/button {:bs-size :lg :bs-style :danger :on-click
                     #(swap! region-state assoc :region (:sel-region @region-state))} "Confirm"])

(defn- region-selection-copy
  [region-state]
  [:div
   [:h3 "Welcome to " common/short-name [:small [:em common/long-name]]]
   [:p "Before you begin, select your closest IKEA region."]])

(defn region-modal
  []
  (when-not (:region @region-state)
     [bootstrap/modal {:auto-focus true
                       :on-hide (fn [& _] (println "Hiding!"))
                       :show true<commit_msg>Fixed linebreak<commit_after>(ns ikea-clojure-cup.regions
  (:require [reagent.core :as reagent :refer [atom]]
            [ajax.core :refer [GET]]
            [reagent-forms.core :refer [bind-fields]]
            [alandipert.storage-atom :refer [local-storage]]
            [ikea-clojure-cup.common :as common]
            [ikea-clojure-cup.bootstrap :as bootstrap]))

(defonce region-state (local-storage (atom {:region nil}) :region))

(defn- fetch-regions
  [region-state]
  (GET "/ikea/regions"
       :handler (fn [resp]
                  (swap! region-state assoc :all-regions resp))))

(defn- region-selector*
  [region-state]
  (if-let [all-regions (seq (:all-regions @region-state))]
    [:form
     [bind-fields
      [bootstrap/input {:id :sel-region :field :list :type "select"}
       (for [region all-regions]
         [:option {:key region :value region} (:name region)])]
      region-state]]
    [:span.loading "Fetching available regions..."]))

(defn- region-selector
  [region-state]
  [(with-meta region-selector* {:component-did-mount (partial fetch-regions region-state)})
   region-state])

(defn- region-confirm
  [region-state]
  [bootstrap/button {:bs-size :lg :bs-style :danger :on-click
                     #(swap! region-state assoc :region (:sel-region @region-state))} "Confirm"])

(defn- region-selection-copy
  [region-state]
  [:div
   [:h3 "Welcome to " common/short-name [:p [:small [:em common/long-name]]]]
   [:p "Before you begin, select your closest IKEA region."]])

(defn region-modal
  []
  (when-not (:region @region-state)
     [bootstrap/modal {:auto-focus true
                       :on-hide (fn [& _] (println "Hiding!"))
                       :show true
{'fraction_non_alphanumeric': 0.16163097682604868, 'fraction_numerical': 0.0005866823115283074, 'mean_word_length': 2.7349397590361444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5310303', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1097, 'n_words': 271}