Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.56 KB | None | 0 0
  1. (ns wh.company.edit.views
  2. (:require
  3. [clojure.string :as str]
  4. [goog.string :as gstring]
  5. [re-frame.core :refer [dispatch]]
  6. [reagent.core :as r]
  7. [wh.common.cost :as cost]
  8. [wh.common.data :as data :refer [package-data billing-data]]
  9. [wh.common.logo]
  10. [wh.common.text :refer [pluralize]]
  11. [wh.common.upload :as upload]
  12. [wh.company.components.forms.views :refer [rich-text-field]]
  13. [wh.company.edit.db :as edit]
  14. [wh.company.edit.events :as events]
  15. [wh.company.edit.subs :as subs]
  16. [wh.company.payment.db :as payment-db]
  17. [wh.company.payment.views :as payment]
  18. [wh.company.views :refer [double->dollars int->dollars]]
  19. [wh.components.common :refer [link]]
  20. [wh.components.ellipsis.views :refer [ellipsis]]
  21. [wh.components.forms.views :as f :refer [labelled-checkbox field-container select-field text-field select-input logo-field]]
  22. [wh.components.github :as github]
  23. [wh.components.icons :refer [icon]]
  24. [wh.components.overlay.views :refer [popup-wrapper]]
  25. [wh.components.selector :refer [selector]]
  26. [wh.db :as db]
  27. [wh.routes :as routes]
  28. [wh.subs :refer [<sub error-sub-key]]
  29. [wh.user.subs :as user-subs]
  30. [wh.util :as util]
  31. [wh.verticals :as verticals]))
  32.  
  33. (defn field [k & {:as args}]
  34. (merge
  35. {:id (db/key->id k)
  36. :value (<sub [(keyword "wh.company.edit.subs" (name k))])
  37. :on-change [(keyword "wh.company.edit.events" (str "edit-" (name k)))]
  38. :on-blur #(dispatch [::events/check k])}
  39. (when-let [error (<sub [(error-sub-key k)])]
  40. {:error error
  41. :validate (get-in edit/fields [k :validate])
  42. :dirty? true})
  43. args))
  44.  
  45. (defn manager-pod
  46. [admin?]
  47. (let [{:keys [name email]} (<sub [::subs/manager-name-and-email])]
  48. [:div.pod.company-edit__manager-pod
  49. [:span (if admin? "WorksHub manager details:" "Your WorksHub manager:")]
  50. [:div.company-edit__manager-pod__details
  51. [:h1 (or name "Pending")]
  52. [:span (or email "No manager is currently assigned")]]
  53. (if admin?
  54. [:form.wh-formx.wh-formx__layout
  55. [text-field nil (field ::edit/manager
  56. :label [:span "Assign manager:"]
  57. :placeholder "Type to search Managers"
  58. :suggestions (<sub [::subs/manager-suggestions])
  59. :on-select-suggestion [::events/select-manager])]]
  60. (when email
  61. [:a.company-edit__manager-pod__contact
  62. {:href (if email (str "mailto:" email) "#")
  63. :id "company-edit__manager-pod__contact"}
  64. "Get in touch"]))]))
  65.  
  66. (defn invoices-pod
  67. [admin?]
  68. (let [invoices (<sub [::subs/invoices])]
  69. (when-not (empty? invoices)
  70. [:div.pod.company-edit__invoices-pod
  71. [:span (if admin? "Company invoices:" "Your most recent invoices:")]
  72. [:div
  73. [:table.table.is-bordered
  74. [:thead
  75. [:tr
  76. [:th "Date"]
  77. [:th "Amount"]]]
  78. [:tbody
  79. (for [{:keys [date url amount] :as i} invoices]
  80. ^{:key url}
  81. [:tr
  82. {:class (when-not amount "skeleton")}
  83. [:th (if (not amount)
  84. [:span]
  85. [:a.a--underlined (when url {:href url :target "_blank" :rel "noopener"}) date])]
  86. [:td
  87. [:span
  88. (double->dollars amount)]]])]]]
  89. [:div.company-edit__invoices-pod__contact
  90. [:span "Can't find what you need?"]
  91. [:a.a--underlined
  92. {:id "company-edit__invoices-pod__email"}
  93. "Just drop us an email"]]])))
  94.  
  95. (defn admin-pod
  96. []
  97. (let [pou (<sub [::subs/paid-offline-until])
  98. pou-loading? (<sub [::subs/paid-offline-until-loading?])
  99. pou-error (<sub [::subs/paid-offline-until-error])
  100. id "company-edit__paid-offline-pod__input"
  101. disabled? (<sub [::subs/disabled?])]
  102. [:div.pod.company-edit__admin-pod
  103. [:h2 "Offline Payment"]
  104. [:p "If the company has paid outside of the platform, this should indicate the date their subscription will terminate."]
  105. (if (str/blank? pou)
  106. [:i [:h3 "Not set"]]
  107. [:h3 pou])
  108. (when (<sub [:wh.user/super-admin?])
  109. [:form.wh-formx
  110. {:on-submit #(let [v (.-value (.getElementById js/document id))]
  111. (when-not (str/blank? v)
  112. (dispatch (vec (concat [::events/save-paid-offline-until] (map js/parseInt (str/split v #"\-"))))))
  113. (.preventDefault %))}
  114. [:label {:for id} "Set date:"]
  115. [:div.is-flex
  116. [:input {:type "date" :id id :disabled pou-loading?}]
  117. [:button.button.button--inverted
  118. {:class (when pou-loading? "button--loading")}
  119. "Save"]]])
  120. (when pou-error
  121. [:span.is-error (str/capitalize pou-error) "!"])
  122. (when (<sub [:wh.user/super-admin?])
  123. [:div
  124. [:h2 "Super Admin Controls"]
  125. (if disabled?
  126. [:p "Enabling the company will reinstate permissions and approve all associated users."]
  127. [:p "Disabling the company will remove all permissions, unpublish all the company jobs and reject all associated users."])
  128. (if disabled?
  129. [:button.button
  130. {:class (when (<sub [::subs/disable-loading?]) "button--loading button--inverted")
  131. :on-click #(when (js/confirm (str "Are you sure you want to enable " (<sub [::subs/name]) "?"))
  132. (dispatch [::events/disable false]))}
  133. "Enable Company"]
  134. [:button.button.button--inverted
  135. {:class (when (<sub [::subs/disable-loading?]) "button--loading")
  136. :on-click #(when (js/confirm (str "Are you sure you want to disable " (<sub [::subs/name]) "?"))
  137. (dispatch [::events/disable true]))}
  138. "Disable Company"])])]))
  139.  
  140. (defn company-details
  141. [edit? admin?]
  142. [:form.wh-formx.wh-formx__layout
  143. [:h2 "Company details"]
  144. [:fieldset
  145. (when-not edit?
  146. [:div.columns.is-mobile.company-edit__name-and-logo
  147. [:div.column.is-narrow
  148. [logo-field (field ::edit/logo
  149. :loading? (<sub [::subs/logo-uploading?])
  150. :on-select-file (upload/handler
  151. :launch [:wh.common.logo/logo-upload]
  152. :on-upload-start [::events/logo-upload-start]
  153. :on-success [::events/logo-upload-success]
  154. :on-failure [::events/logo-upload-failure]))]]
  155. [:div.column
  156. [text-field nil (field ::edit/name
  157. :label [:span "* Company name"]
  158. :suggestions (<sub [::subs/suggestions])
  159. :on-select-suggestion [::events/select-suggestion])]]])
  160.  
  161. (when-not edit?
  162. [rich-text-field (field ::edit/description-html
  163. :placeholder "Tell our community all about your company and how great it is to work for you…"
  164. :class "company-edit__description"
  165. :label [:span "* Company introduction"])])
  166. (when admin? [select-field nil (field ::edit/vertical
  167. :label [:span "Vertical"]
  168. :options verticals/future-job-verticals)])
  169. (when admin? [labelled-checkbox nil (field ::edit/auto-approve
  170. :class "company-edit__checkbox"
  171. :label [:span "Automatically approve candidates?"])])
  172.  
  173. [:div.is-flex.company-edit__field-footer
  174. (let [saving? (<sub [::subs/saving?])]
  175. [:button.button.button--small.company-edit__save-details
  176. {:on-click #(do (.preventDefault %)
  177. (dispatch [::events/save-company]))
  178. :class (str (when edit? "button--inverted ")
  179. (when saving? "button--inverted button--loading"))}
  180. (when-not saving? (if edit? "Save" "Create"))])
  181. (when-let [error (<sub [::subs/error])]
  182. (f/error-component error { :id "company-edit-error-desktop"}))]]])
  183.  
  184. (defn users
  185. [admin?]
  186. [:form.wh-formx.wh-formx__layout
  187. [:h2 "Users & notifications"]
  188. [:p "Below is a list of your authorised account users. Grant access to new users by entering their name and email below."]
  189. (when-let [users (not-empty (<sub [::subs/users]))]
  190. (let [notifs (<sub [::subs/user-notifications])]
  191. [:table.company-edit__users
  192. [:tbody
  193. [:tr.company-edit__user-header
  194. [:th.company-edit__user-header--name "Name"]
  195. [:th.company-edit__user-header--email "Email"]
  196. [:th.company-edit__user-header--notify "Notify"]
  197. (when admin? [:th.company-edit__user-header--admin ""])]
  198. (for [{:keys [email name id]} users]
  199. [:tr.company-edit__user
  200. {:key email}
  201. [:td.company-edit__user--name name]
  202. [:td.company-edit__user--email email]
  203. [:td.company-edit__user--notify [labelled-checkbox nil
  204. {:label ""
  205. :id (str "notify_" id)
  206. :value (contains? notifs email)
  207. :label-class "is-pulled-right"
  208. :class "is-pulled-right"
  209. :on-change [::events/toggle-user-notification email]}]]
  210. (when admin? [:td.company-edit__user--admin
  211. [icon "close"
  212. :on-click #(dispatch [::events/remove-user id])]])])]]))
  213. [:fieldset
  214. [text-field nil (field ::edit/new-user-name
  215. :label [:span "* Name"])]
  216. [text-field nil (field ::edit/new-user-email
  217. :label [:span "* Email"])]
  218. [:div.is-flex.company-edit__field-footer
  219. (let [saving? (<sub [::subs/user-adding?])]
  220. [:button.button.button--small.button--inverted.company-edit__add-user
  221. {:on-click #(do (.preventDefault %)
  222. (dispatch [::events/add-new-user]))
  223. :class (str (when saving? "button--inverted button--loading"))}
  224. (when-not saving? "Add User")])
  225. (when-let [error (<sub [::subs/user-error])]
  226. (f/error-component error {:id "company-edit-user-error-desktop"}))]]])
  227.  
  228. (defn integrations []
  229. [:div.wh-formx.wh-formx__layout
  230. (when (<sub [::subs/some-integrations-not-connected?])
  231. [:div
  232. [:h2 "Available Integrations"]
  233. [:p "Connect your WorksHub account to Slack or Greenhouse to receive application notifications via these channels"]
  234. [:div.company-edit__integrations
  235. (when-not (<sub [::subs/slack-connected?])
  236. [:a {:href (when-not (<sub [:user/admin?])
  237. (routes/path :oauth-slack))}
  238. [:button.button.company-edit__integration
  239. (merge
  240. {:id "company-edit__integration--slack"}
  241. (when (<sub [:user/admin?])
  242. {:on-click #(do (.preventDefault %)
  243. (dispatch [::events/toggle-integration-popup true]))}))
  244. [:img {:src "/images/company/slack.svg"}]]])
  245. (when-not (<sub [::subs/greenhouse-connected?])
  246. [:a {:href (when (and (not (<sub [:user/admin?]))
  247. (<sub [:wh.user/can-use-integrations?]))
  248. (routes/path :oauth-greenhouse))}
  249. [:button.button.company-edit__integration
  250. (merge
  251. {:id "company-edit__integration--greenhouse"}
  252. (when (<sub [:user/admin?])
  253. {:on-click #(do (.preventDefault %)
  254. (dispatch [::events/toggle-integration-popup true]))})
  255. (when (and (not (<sub [:user/admin?]))
  256. (not (<sub [:wh.user/can-use-integrations?])))
  257. {:on-click #(do (.preventDefault %)
  258. (dispatch [::events/upgrade]))}))
  259. [:img {:src "/images/company/greenhouse.svg"}]]])
  260. (when (and (not (<sub [:user/admin?]))
  261. (not (<sub [:user/company-connected-github?])))
  262. [github/install-github-app
  263. {:id "company-edit__integration--github"}])]])
  264. (when (<sub [::subs/some-integrations-connected?])
  265. (let [deleting (<sub [::subs/deleting-integration?])]
  266. [:div.company-edit__connected-integrations
  267. [:h2 "Connected Integrations"]
  268. (when (<sub [::subs/slack-connected?])
  269. [:div.company-edit__connected-integration
  270. [:img {:alt "Slack" :title "Slack" :src "/images/company/slack-icon.svg"}]
  271. [:button.button.button--small.button--inverted.company-edit__add-user
  272. {:on-click #(do (.preventDefault %)
  273. (dispatch [::events/delete-integration :slack]))
  274. :class (str (when deleting "button--inverted button--loading"))}
  275. (when-not deleting "Delete Integration")]])
  276. (when (<sub [::subs/greenhouse-connected?])
  277. [:div.company-edit__connected-integration
  278. [:img {:alt "Greenhouse" :title "Greenhouse" :src "/images/company/greenhouse-icon.svg"}]
  279. [:button.button.button--small.button--inverted.company-edit__add-user
  280. {:on-click #(do (.preventDefault %)
  281. (dispatch [::events/delete-integration :greenhouse]))
  282. :class (str (when deleting "button--inverted button--loading"))}
  283. (when-not deleting "Delete Integration")]
  284. (when (<sub [:user/admin?])
  285. [:span "Company manager will be set as referrer/source for each candidate."])])
  286. (when (<sub [:user/company-connected-github?])
  287. [:div.company-edit__connected-integration
  288. [:img {:alt "GitHub" :title "GitHub" :src "/images/company/github-icon.svg"}]
  289. [link "Manage issues" :manage-issues :class "button button--small button--inverted"]])]))])
  290.  
  291. (defn integration-popup []
  292. [:div.is-full-panel-overlay
  293. [:div.company-edit__integration-placeholder.has-text-centered
  294. [:div
  295. [:h1 "Admins cannot connect integrations"]
  296. [:p "Only company users can connect integrations"]
  297. [:button.button.button--small
  298. {:on-click #(dispatch [::events/toggle-integration-popup false])}
  299. "Back"]]]])
  300.  
  301. (defn cancel-plan-dialog
  302. []
  303. [popup-wrapper
  304. {:id :cancel-plan
  305. :codi? false
  306. :on-close #(dispatch [::events/show-cancel-plan-dialog false])}
  307. (let [exp (<sub [::subs/payment-expires])]
  308. (if (<sub [:user/admin?])
  309. [:div
  310. [:h1 "When would you like to cancel this subscription?"]
  311. [:p "The company will be moved to the Unselected package and all jobs will be unpublished."]
  312. [:button.button
  313. {:disabled exp
  314. :on-click #(dispatch [::events/cancel-plan false])}
  315. "At the end of the period"]
  316. [:button.button.button--inverted
  317. {:on-click #(dispatch [::events/cancel-plan true])}
  318. "Immediately"]]
  319. [:div
  320. [:h1 "Are you sure you want to cancel your subscription?"]
  321. [:p "Your active subscription will be cancelled and all your jobs will be taken offline."]
  322. [:button.button.button--inverted
  323. {:on-click #(dispatch [::events/cancel-plan true])}
  324. "Cancel immediately"]
  325. [:button.button
  326. {:on-click #(dispatch [::events/show-cancel-plan-dialog false])}
  327. "Don't cancel"]]))])
  328.  
  329. (defn card-data
  330. [{:keys [last-4-digits brand expiry] :as card}]
  331. [:div.card-data
  332. {:class (when (nil? card) "skeleton")}
  333. [:div.card-data__brand
  334. (if brand
  335. [:img {:src (str "/cards/" (str/replace (str/lower-case brand) #"\s" "") ".png")}]
  336. [:div.empty])]
  337. [:div.card-data__info
  338. [:div
  339. [:span brand " (ends " last-4-digits ")"]]
  340. [:div
  341. [:span (gstring/format "Expires %02d/%d " (:month expiry) (:year expiry))]]]])
  342.  
  343. (defn status-button [{:keys [prefix] :as args}]
  344. (let [make-sub #(keyword (namespace ::subs/here) (str (name prefix) "-" %))]
  345. (f/status-button
  346. (assoc args
  347. :enabled? (<sub [(make-sub "button-enabled?")])
  348. :waiting? (<sub [(make-sub "button-waiting?")])
  349. :status (<sub [(make-sub "status")])))))
  350.  
  351. (defmulti billing-paragraph identity)
  352. (defmethod billing-paragraph :default [_]
  353. "You are currently being billed on a monthly basis but you could save more by switching to six-monthly billing \uD83D\uDCB0")
  354. (defmethod billing-paragraph :one [_]
  355. "You are currently being billed on a monthly basis but you could save more by switching to six-monthly billing \uD83D\uDCB0")
  356. (defmethod billing-paragraph :three [_]
  357. "You are currently being billed on a quarterly basis but you could save more by switching to six-monthly billing \uD83D\uDCB0")
  358. (defmethod billing-paragraph :six [_]
  359. "You're on the most cost-effective billing plan!")
  360.  
  361. (defn payment-details
  362. [edit? admin?]
  363. (let [{:keys [card billing-period] :as payment} (<sub [::subs/payment])
  364. package (<sub [::subs/package-kw])
  365. event [::events/update-card-details]]
  366. [:div.company-edit__payment-details
  367. (when card
  368. [:div.company-edit__payment-details__card-details
  369. [:h2 "Payment Details"]
  370. [card-data card]
  371. (when payment
  372. [:div
  373. [:p "If you'd like to update your card details, please re-enter them below:"]
  374. [payment/card-form {:id :company-settings-update
  375. :terms? false
  376. :event event}]
  377. [status-button
  378. {:id "update-card-details"
  379. :prefix ::update-card-details
  380. :on-click #(when-let [el (.getElementById js/document "stripe-card-form")]
  381. (payment/submit-stripe-form! :company-settings-update event))
  382. :class "button--inverted"
  383. :text "Update Payment Details"}]])])
  384. (when (<sub [::subs/has-subscription?])
  385. [:div
  386. [:div.company-edit__payment-details__billing-and-pricing
  387. [:h2 "Change billing period"]
  388. [:div
  389. [:p (billing-paragraph billing-period)]
  390. [link
  391. [:button.button "Change billing period"]
  392. :payment-setup
  393. :step :pay-confirm
  394. :query-params {:billing billing-period
  395. :package package
  396. :existing-billing billing-period
  397. :breakdown false}]]]
  398. [:div.company-edit__payment-details__coupons
  399. [:h2 "Discounts"]
  400. [:div
  401. [:p "Details of any existing discounts will be listed here. You can also apply new discount by entering your code and pressing Apply."]
  402. [:p.company-edit__payment-details__coupons__description
  403. (if-let [coupon (<sub [::subs/coupon])]
  404. [:span "Currently applied: " [:span (str (:description coupon) ", " (name (:duration coupon)))]]
  405. [:i "You don't currently have an active discount."])]
  406. (when (<sub [::subs/coupon-apply-success?])
  407. [:p.company-edit__payment-details__coupons__new-coupon
  408. [:i "Success! A new coupon has been applied to your subscription."]])
  409. [payment/coupon-field true [::events/apply-coupon]]]]])]))
  410.  
  411. (defn cancel-payment
  412. []
  413. (when (<sub [::subs/has-subscription?])
  414. (let [exp (<sub [::subs/payment-expires])
  415. admin? (<sub [:wh.user/super-admin?])]
  416. [:div.company-edit__payment-details.company-edit__payment-details__cancel-plan
  417. [:h2 "Cancel your plan"]
  418. [:p "We'll be very sorry to see you go \uD83D\uDE15"]
  419. [:p "Please drop us an email to let us know why you’d like to cancel and then we’ll get it sorted for you."]
  420. [:p "Your account will close on the last day of your current plan and no further payments will be taken."]
  421. [:div
  422. (when exp
  423. [:p.is-error (str "This subscription is set to expire on " exp)])
  424. (if
  425. (or (<sub [::subs/can-cancel-sub?])
  426. admin?)
  427. [:button.button
  428. {:class (when (<sub [::subs/cancel-plan-loading?]) "button--loading button--inverted")
  429. :disabled (and exp (not admin?))
  430. :on-click #(dispatch [::events/show-cancel-plan-dialog true])}
  431. "Cancel plan"]
  432. [:a {:href (str "mailto:hello@works-hub.com?subject=[" (<sub [::subs/name]) "]+I+wish+to+cancel+my+plan")
  433. :target "_blank"
  434. :rel "noopener"}
  435. [:button.button
  436. "Contact WorksHub"]])]])))
  437.  
  438. (defmulti error->message identity)
  439. (defmethod error->message :default [_]
  440. "Unfortunately we could not load the page you were looking for. If the issue persists, please contact us.")
  441. (defmethod error->message :company-with-same-name-already-exists [_]
  442. "The company with the same name already exists.")
  443. (defmethod error->message :failed-to-fetch-company [_]
  444. "Unfortunately we could not load company information at this time. If the issue persists, please contact us.")
  445.  
  446. (defn hiring-pod
  447. [admin?
  448. {:keys [cost extras description img perks] :as package}
  449. {:keys [discount number] :as billing-period :or {discount 0}}
  450. coupon
  451. {:keys [recurring-fee placement-percentage accepted-at]}]
  452. [:div.pod.company-edit__hiring-pod
  453. (if package
  454. [:span.company-edit__hiring-pod__your-package "Your package"]
  455. [:p "You don't currently have a package selected. Select one of our packages to begin your hiring adventure."])
  456. [:div.company-edit__hiring-pod__title
  457. [:h1 (:name package)]
  458. (cond (pos? cost)
  459. [:h2 (int->dollars (cost/calculate-monthly-cost cost discount coupon)) [:i "/" (:per package)]]
  460. (and accepted-at recurring-fee)
  461. [:h2 (int->dollars (cost/calculate-monthly-cost recurring-fee discount coupon)) [:i "/month" ]]
  462. :else [:div.empty])
  463. (when (and (or (pos? cost) (and accepted-at recurring-fee)) (:description billing-period))
  464. [:div.company-edit__hiring-pod__title__billing-description
  465. [:span "Billed every "]
  466. (when (> number 1) [:strong number " "])
  467. [:strong (pluralize number "month")]])
  468. (when accepted-at
  469. [:div.company-edit__hiring-pod__title__billing-description
  470. [:span [:strong placement-percentage "%"] " placement fee"]])]
  471. [:div.company-edit__hiring-pod__extras extras]
  472. (when description
  473. [:div.company-edit__hiring-pod__description description])
  474. [:div.company-signup__hiring_pod__logo-container
  475. [:div.company-signup__hiring_pod__logo-circle
  476. [:img img]]]
  477. (when perks
  478. [:ul.company-edit__hiring-pod__perks
  479. (for [perk perks]
  480. ^{:key perk}
  481. [:li.company-edit__hiring-pod__perk
  482. [icon "tick"]
  483. [:span perk]])])
  484. (if admin?
  485. [link [:button.button "Create Take-Off Offer"]
  486. :create-company-offer
  487. :id (<sub [::subs/id])]
  488. [link (if package "Upgrade/View package options" "Select a package")
  489. :payment-setup
  490. :step :select-package
  491. :class "a--underlined"])])
  492.  
  493. (defn disabled-banner
  494. []
  495. [:div.company-edit__disabled-banner
  496. [icon "error"]
  497. "This company is currently disabled."])
  498.  
  499. (defn page [edit? admin?]
  500. (let [page-selection (<sub [::subs/page-selection])
  501. error (<sub [::subs/error])
  502. payment? (<sub [::subs/payment])
  503. loading? (<sub [::subs/loading?])
  504. disabled? (<sub [::subs/disabled?])
  505. settings-title (cond (and admin? edit?) (str (<sub [::subs/name]) " Settings")
  506. edit? "Settings"
  507. :else "Create company")]
  508. [:div.main-container
  509. [:div.main
  510. (cond
  511. loading?
  512. [:div.company-edit.company-edit--loading
  513. [:h1 settings-title]]
  514. error
  515. [:div.company-edit.wh-formx-page-container.company-edit--error
  516. [:h1 "An error occurred"]
  517. [:h3 (error->message error)]]
  518. :else
  519. [:div.company-edit.wh-formx-page-container
  520. {:class (str "company-edit--" (if edit? "edit" "create"))}
  521. (if (and admin? edit?)
  522. [:div.company-edit__banner
  523. [link [:h1 settings-title] :company-dashboard :id (<sub [::subs/id])]
  524. (when disabled?
  525. (disabled-banner))]
  526. [:h1 settings-title])
  527. (when (and edit? payment?)
  528. [selector
  529. page-selection
  530. (<sub [::subs/page-selections])
  531. #(dispatch [::events/set-page-selection %])])
  532. [:div.columns.is-variable.is-2
  533. [:div.column.is-7
  534. (if (and (= page-selection :payment-details) payment?)
  535. [:div
  536. [payment-details edit? admin?]
  537. (when edit?
  538. [cancel-payment])]
  539. [:div
  540. (when admin?
  541. [company-details edit? admin?])
  542. (when edit?
  543. [integrations])
  544. (when edit?
  545. [users admin?])])]
  546.  
  547. [:div.column.is-4.is-offset-1.company-edit__side-pods
  548. [:div.company-edit__side-pods--container
  549. [manager-pod admin?]
  550. (let [pk (<sub [::subs/package-kw])
  551. bp (<sub [::subs/billing-period])
  552. coupon (<sub [::subs/coupon])
  553. offer (<sub [::subs/offer])]
  554. (hiring-pod admin? (-> (get package-data pk)
  555. (dissoc :perks))
  556. (get billing-data bp)
  557. coupon
  558. offer))
  559.  
  560. (when (and edit? admin?)
  561. [admin-pod])
  562. (when (= page-selection :payment-details)
  563. [invoices-pod admin?])]]]])]
  564.  
  565. (when (<sub [::subs/show-integration-popup?])
  566. (integration-popup))
  567. (when (<sub [::subs/showing-cancel-plan-dialog?])
  568. [cancel-plan-dialog])]))
  569.  
  570. (defn create-page []
  571. (page false true))
  572.  
  573. (defn edit-page []
  574. (page true (<sub [:user/admin?])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement