-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigate between organisations by url
- Loading branch information
1 parent
7970b4c
commit e04f237
Showing
13 changed files
with
97 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
(ns villagebookUI.components.main-content) | ||
(ns villagebookUI.components.main-content | ||
(:require [villagebookUI.store.organisations :as org-store])) | ||
|
||
(defn main-content [] | ||
[:div.main-content | ||
[:div.navbar]]) | ||
[:div.navbar | ||
[:h5 (:name (org-store/get-selected))]]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
(ns villagebookUI.routes | ||
(:require [reagent.session :as session] | ||
[villagebookUI.fetchers :as fetchers] | ||
(:require [villagebookUI.fetchers :as fetchers] | ||
[villagebookUI.middleware :refer [require-login]] | ||
[villagebookUI.components.login :refer [login]] | ||
[villagebookUI.components.signup :refer [signup]] | ||
[villagebookUI.components.dashboard :refer [dashboard]] | ||
[villagebookUI.components.notfound :refer [notfound]])) | ||
|
||
(def routes | ||
["" {"/" login | ||
"/signup" signup | ||
"/dashboard" (require-login | ||
(fn [] | ||
(fetchers/fetch-orgs!) | ||
dashboard)) | ||
true notfound}]) | ||
["" {"/" login | ||
"/signup" signup | ||
"/dashboard" (require-login dashboard #(fetchers/fetch-orgs! first)) | ||
["/orgs/" :org-id] (require-login dashboard #(fetchers/fetch-orgs!)) | ||
true notfound}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
(ns villagebookUI.store.core | ||
(:require [villagebookUI.store.user :as user-store] | ||
[villagebookUI.store.session :as session] | ||
[villagebookUI.store.organisations :as org-store] | ||
[villagebookUI.api.user :as user-api])) | ||
|
||
(defn init! [] | ||
(session/init!) | ||
(user-store/init!) | ||
(org-store/init!) | ||
(user-api/get-data!)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
(ns villagebookUI.store.organisations | ||
(:require [reagent.core :as r] | ||
[clojure.walk :refer [keywordize-keys]] | ||
[villagebookUI.helpers :as helpers] | ||
[villagebookUI.store.state :refer [state]])) | ||
|
||
(def organisations | ||
(r/cursor state [:organisations])) | ||
|
||
(def selected-organisation | ||
(r/cursor state [:selected-organisation])) | ||
|
||
(defn get-all [] | ||
@organisations) | ||
|
||
(defn get-by-id [id] | ||
(some #(if (= (:id %) id) %) (get-all))) | ||
|
||
(defn get-selected [] | ||
(or (get-by-id (helpers/org-id-from-url)) | ||
@selected-organisation)) | ||
|
||
(defn add-all! [orgs] | ||
(reset! organisations (map #(keywordize-keys %) orgs))) | ||
|
||
(defn add-one! [org] | ||
(swap! organisations conj (keywordize-keys org))) | ||
|
||
(defn set-selected! [org] | ||
(reset! selected-organisation (keywordize-keys org))) | ||
|
||
(defn init! [] | ||
(reset! organisations {})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(ns villagebookUI.store.session | ||
(:require [reagent.core :as r] | ||
[villagebookUI.store.state :refer [state]])) | ||
|
||
(def session | ||
(r/cursor state [:session])) | ||
|
||
(defn get-session [] | ||
@session) | ||
|
||
(defn set! | ||
[page] | ||
(reset! session page)) | ||
|
||
(defn current-page [] | ||
(:current-page @session)) | ||
|
||
(defn route-params [] | ||
(:route-params @session)) | ||
|
||
(defn init! [] | ||
(reset! session {:current-page nil | ||
:route-params nil})) |