From ff6278b147626b3f315b70819cbe782f1092fdd2 Mon Sep 17 00:00:00 2001 From: FRC Date: Wed, 12 Oct 2022 15:04:39 +0100 Subject: [PATCH] Featured items to homepage (#1024) * Featured items to homepage * Fix nits --- common/globalConfig.ts | 3 + firestore.rules | 6 ++ web/components/groups/group-overview.tsx | 1 - web/components/pinned-select-modal.tsx | 6 +- web/hooks/use-global-config.ts | 12 +++ web/hooks/use-post.ts | 14 +++- web/lib/firebase/globalConfig.ts | 33 ++++++++ web/lib/firebase/posts.ts | 4 + web/pages/home/index.tsx | 99 +++++++++++++++++++++++- 9 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 common/globalConfig.ts create mode 100644 web/hooks/use-global-config.ts create mode 100644 web/lib/firebase/globalConfig.ts diff --git a/common/globalConfig.ts b/common/globalConfig.ts new file mode 100644 index 00000000..fc3e25e7 --- /dev/null +++ b/common/globalConfig.ts @@ -0,0 +1,3 @@ +export type GlobalConfig = { + pinnedItems: { itemId: string; type: 'post' | 'contract' }[] +} diff --git a/firestore.rules b/firestore.rules index 993791b2..0a0ecfe0 100644 --- a/firestore.rules +++ b/firestore.rules @@ -23,6 +23,12 @@ service cloud.firestore { allow read; } + match /globalConfig/globalConfig { + allow read; + allow update: if isAdmin() + allow create: if isAdmin() + } + match /users/{userId} { allow read; allow update: if userId == request.auth.uid diff --git a/web/components/groups/group-overview.tsx b/web/components/groups/group-overview.tsx index d5cdaafa..c5a7a46a 100644 --- a/web/components/groups/group-overview.tsx +++ b/web/components/groups/group-overview.tsx @@ -231,7 +231,6 @@ export function PinnedItems(props: { return pinned.length > 0 || isEditable ? (
- {isEditable && (