<commit_before>(ns frontend.components.outer
  (:require [cemerick.url :as url]
            [clojure.set :as set]
            [clojure.string :as str]
            [datascript :as d]
            [frontend.analytics :as analytics]
            [frontend.async :refer [put!]]
            [frontend.auth :as auth]
            [frontend.components.common :as common]
            [frontend.components.doc-viewer :as doc-viewer]
            [frontend.components.document-access :as document-access]
            [frontend.components.landing :as landing]
            [frontend.datascript :as ds]
            [frontend.models.doc :as doc-model]
            [frontend.state :as state]
            [frontend.utils :as utils :include-macros true]
            [frontend.utils.ajax :as ajax]
            [frontend.utils.date :refer (date->bucket)]
            [goog.dom]
            [goog.labs.userAgent.browser :as ua]
            [goog.string :as gstring]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true])
  (:require-macros [sablono.core :refer (html)]
                   [cljs.core.async.macros :as am :refer [go go-loop alt!]])
  (:import [goog.ui IdGenerator]))

(defn early-access [app owner]
  (reify
    om/IInitState (init-state [_] {:company-name ""
                                   :employee-count ""
                                   :use-case ""
                                   :error nil
                                   :submitting? false
                                   :submitted? false})
    om/IDisplayName (display-name [_] "Early Access")
    om/IRenderState
    (render-state [_ {:keys [company-name employee-count use-case submitting? error submitted?]}]
      (let [{:keys [cast! handlers]} (om/get-shared owner)
            disabled? (or submitting? (not (utils/logged-in? owner)))
            submit-form
            (fn [args]
              (go
                (om/update-state! owner (fn [s]
                                          (assoc s :submitting? true :error nil)))
                ;; we wouldn't typically use ajax in a component--it's not advisable in
                ;; this case, but we're short on time
                (let [res (<! (ajax/managed-ajax :post "/api/v1/early-access"))]
                  (if (= :success (:status (utils/inspect res)))
                    (om/update-state! owner (fn [s]
                                              (assoc s
                                                     :submitting? false
                                                     :submitted? true
                                                     :error nil
                                                     :company-name ""
                                                     :employee-count ""
                                                     :use-case "")))
                    (do
                      (om/update-state!
                       owner
                       (fn [s]
                         (assoc s
                                :submitting? false

                                :error
                                [:p "Oops, that didn't work. Here, "
                                 [:a {:href
                                      (str "mailto:<EMAIL>?"
                                           (url/map->query {:subject "Early Access to Precursor"
                                                            :body (str "Company name:\n"
                                                                       company-name
                                                                       "\n\nEmployee count:\n"
                                                                       employee-count
                                                                       "\n\nUse case:\n"
                                                                       use-case)}))}
                                  "send us this email"]
                                 " instead!"])))
                      (put! (om/get-shared owner [:comms :errors]) [:api-error res]))))))]
        (html
         [:div.early-access {:class (get-in app [:navigation-data :type] "team")}
          [:div.content

           [:div.early-access-info
            [:h2.early-access-heading
             "We're excited to show you the team features we're building."]
            [:p.early-access-copy
             "To activate your early access, please "
             (if (utils/logged-in? owner)
               "take a moment to"
               "sign in first and")
             " fill out the following information.
              We'll send you an email confirmation once your account has been granted full access."]
            (when-not (utils/logged-in? owner)
              [:div.calls-to-action
               (om/build common/google-login {:source "Early Access Form"})])]

           ;; need to hook up disabled class
           [:div.early-access-form {:class (str (when disabled? "disabled ")
                                                (when submitting? "submitting ")
                                                (when submitted? "submitted "))}
            [:div.adaptive-placeholder {:tab-index "2"
                                        :ref "company-name"
                                        :data-before "What's your company's name?"
                                        :data-after "Company Name"
                                        :content-editable true
                                        :on-key-down #(when (= "Enter" (.-key %))
                                                        (.preventDefault %)
                                                        ;; If they hit enter, send them to the next input.
                                                        (.focus (om/get-node owner "employee-count")))
                                        :on-input #(om/set-state! owner :company-name (goog.dom/getRawTextContent (.-target %)))}

             company-name]
            [:div.adaptive-placeholder {:tab-index "3"
                                        :ref "employee-count"
                                        :data-before "How many teammates do you have?"
                                        :data-after "Team Size"
                                        :content-editable true
                                        :on-key-down #(when (= "Enter" (.-key %))
                                                        (.preventDefault %)
                                                        ;; If they hit enter, send them to the next input.
                                                        (.focus (om/get-node owner "use-case")))
                                        :on-input #(om/set-state! owner :employee-count (goog.dom/getRawTextContent (.-target %)))}
             employee-count]
            [:div.adaptive-placeholder {:tab-index "4"
                                        :ref "use-case"
                                        :data-before "How will you use Precursor?"
                                        :data-after "Use Case"
                                        :content-editable true
                                        :on-key-down #(when (= "Enter" (.-key %))
                                                        (.preventDefault %)
                                                        ;; If they hit enter, send them to the next input.
                                                        (.focus (om/get-node owner "submit-button"))
                                                        (.click (om/get-node owner "submit-button")))
                                        :on-input #(om/set-state! owner :use-case (goog.dom/getRawTextContent (.-target %)))}
             use-case]
            (when (seq error)
              [:div.error error])
            [:button.early-access-button {:tab-index "5"
                                          :ref "submit-button"
                                          :disabled (or disabled? submitted?)
                                          :on-click #(submit-form {:company-name company-name
                                                                   :employee-count employee-count
                                                                   :use-case use-case})}
             (cond submitting?
                   (html
                    [:span "Request is submitting"
                     [:i.loading-ellipses
                      [:i "."]
                      [:i "."]
                      [:i "."]]])

                   submitted?
                   "Got it! We'll respond soon."

                   :else "Request early access.")]]]])))))

(defn pricing [app owner]
  (reify
    om/IDisplayName (display-name [_] "Pricing Page")
    om/IRender
    (render [_]
      (let [{:keys [cast! handlers]} (om/get-shared owner)]
        (html
          [:div.pricing
           [:div.content
            [:div.pricing-blocks
             [:div.pricing-block
              [:div.pricing-head
               [:h2.pricing-heading.content-copy {:title "Solo—freelancers, self-employed, etc."} "Solo"]]
              [:div.pricing-body
               ;; [:h4.content-copy "$10/mo"]    ; <- hold off until pricing is ready
               [:h4.content-copy "Pricing soon."] ; <- and delete this once it's ready
               [:p.pricing-copy.content-copy
                "Unlimited public docs, private docs, and project repos.<commit_msg>put the error in the button<commit_after>(ns frontend.components.outer
  (:require [cemerick.url :as url]
            [clojure.set :as set]
            [clojure.string :as str]
            [datascript :as d]
            [frontend.analytics :as analytics]
            [frontend.async :refer [put!]]
            [frontend.auth :as auth]
            [frontend.components.common :as common]
            [frontend.components.doc-viewer :as doc-viewer]
            [frontend.components.document-access :as document-access]
            [frontend.components.landing :as landing]
            [frontend.datascript :as ds]
            [frontend.models.doc :as doc-model]
            [frontend.state :as state]
            [frontend.utils :as utils :include-macros true]
            [frontend.utils.ajax :as ajax]
            [frontend.utils.date :refer (date->bucket)]
            [goog.dom]
            [goog.labs.userAgent.browser :as ua]
            [goog.string :as gstring]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true])
  (:require-macros [sablono.core :refer (html)]
                   [cljs.core.async.macros :as am :refer [go go-loop alt!]])
  (:import [goog.ui IdGenerator]))

(defn early-access [app owner]
  (reify
    om/IInitState (init-state [_] {:company-name ""
                                   :employee-count ""
                                   :use-case ""
                                   :error nil
                                   :submitting? false
                                   :submitted? false})
    om/IDisplayName (display-name [_] "Early Access")
    om/IRenderState
    (render-state [_ {:keys [company-name employee-count use-case submitting? error submitted?]}]
      (let [{:keys [cast! handlers]} (om/get-shared owner)
            disabled? (or submitting? (not (utils/logged-in? owner)))
            submit-form
            (fn [args]
              (go
                (om/update-state! owner (fn [s]
                                          (assoc s :submitting? true :error nil)))
                ;; we wouldn't typically use ajax in a component--it's not advisable in
                ;; this case, but we're short on time
                (let [res (<! (ajax/managed-ajax :post "/api/v1/early-access"))]
                  (if (= :success (:status (utils/inspect res)))
                    (om/update-state! owner (fn [s]
                                              (assoc s
                                                     :submitting? false
                                                     :submitted? true
                                                     :error nil
                                                     :company-name ""
                                                     :employee-count ""
                                                     :use-case "")))
                    (do
                      (om/update-state!
                       owner
                       (fn [s]
                         (assoc s
                                :submitting? false

                                :error
                                [:p "Oops, that didn't work. Here, "
                                 [:a {:href
                                      (str "mailto:<EMAIL>?"
                                           (url/map->query {:subject "Early Access to Precursor"
                                                            :body (str "Company name:\n"
                                                                       company-name
                                                                       "\n\nEmployee count:\n"
                                                                       employee-count
                                                                       "\n\nUse case:\n"
                                                                       use-case)}))}
                                  "send us this email"]
                                 " instead!"])))
                      (put! (om/get-shared owner [:comms :errors]) [:api-error res]))))))]
        (html
         [:div.early-access {:class (get-in app [:navigation-data :type] "team")}
          [:div.content

           [:div.early-access-info
            [:h2.early-access-heading
             "We're excited to show you the team features we're building."]
            [:p.early-access-copy
             "To activate your early access, please "
             (if (utils/logged-in? owner)
               "take a moment to"
               "sign in first and")
             " fill out the following information.
              We'll send you an email confirmation once your account has been granted full access."]
            (when-not (utils/logged-in? owner)
              [:div.calls-to-action
               (om/build common/google-login {:source "Early Access Form"})])]

           ;; need to hook up disabled class
           [:div.early-access-form {:class (str (when disabled? "disabled ")
                                                (when submitting? "submitting ")
                                                (when submitted? "submitted "))}
            [:div.adaptive-placeholder {:tab-index "2"
                                        :ref "company-name"
                                        :data-before "What's your company's name?"
                                        :data-after "Company Name"
                                        :content-editable true
                                        :on-key-down #(when (= "Enter" (.-key %))
                                                        (.preventDefault %)
                                                        ;; If they hit enter, send them to the next input.
                                                        (.focus (om/get-node owner "employee-count")))
                                        :on-input #(om/set-state! owner :company-name (goog.dom/getRawTextContent (.-target %)))}

             company-name]
            [:div.adaptive-placeholder {:tab-index "3"
                                        :ref "employee-count"
                                        :data-before "How many teammates do you have?"
                                        :data-after "Team Size"
                                        :content-editable true
                                        :on-key-down #(when (= "Enter" (.-key %))
                                                        (.preventDefault %)
                                                        ;; If they hit enter, send them to the next input.
                                                        (.focus (om/get-node owner "use-case")))
                                        :on-input #(om/set-state! owner :employee-count (goog.dom/getRawTextContent (.-target %)))}
             employee-count]
            [:div.adaptive-placeholder {:tab-index "4"
                                        :ref "use-case"
                                        :data-before "How will you use Precursor?"
                                        :data-after "Use Case"
                                        :content-editable true
                                        :on-key-down #(when (= "Enter" (.-key %))
                                                        (.preventDefault %)
                                                        ;; If they hit enter, send them to the next input.
                                                        (.focus (om/get-node owner "submit-button"))
                                                        (.click (om/get-node owner "submit-button")))
                                        :on-input #(om/set-state! owner :use-case (goog.dom/getRawTextContent (.-target %)))}
             use-case]
            [:button.early-access-button {:tab-index "5"
                                          :ref "submit-button"
                                          :disabled (or disabled? submitted?)
                                          :on-click #(submit-form {:company-name company-name
                                                                   :employee-count employee-count
                                                                   :use-case use-case})}
             (cond submitting?
                   (html
                    [:span "Request is submitting"
                     [:i.loading-ellipses
                      [:i "."]
                      [:i "."]
                      [:i "."]]])

                   submitted?
                   "Got it! We'll respond soon."

                   (seq error)
                   error

                   :else "Request early access.")]]]])))))

(defn pricing [app owner]
  (reify
    om/IDisplayName (display-name [_] "Pricing Page")
    om/IRender
    (render [_]
      (let [{:keys [cast! handlers]} (om/get-shared owner)]
        (html
          [:div.pricing
           [:div.content
            [:div.pricing-blocks
             [:div.pricing-block
              [:div.pricing-head
               [:h2.pricing-heading.content-copy {:title "Solo—freelancers, self-employed, etc."} "Solo"]]
              [:div.pricing-body
               ;; [:h4.content-copy "$10/mo"]    ; <- hold off until pricing is ready
               [:h4.content-copy "Pricing soon."] ; <- and delete this once it's ready
               [:p.pricing-copy.content-copy
                "Unlimited public docs, private docs, and project repos.
{'fraction_non_alphanumeric': 0.10234362711686677, 'fraction_numerical': 0.0011534630105384574, 'mean_word_length': 0.875147463625639, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 202, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '962059', 'n_tokens_mistral': 4316, 'n_tokens_neox': 3993, 'n_words': 1100}