From a736b5ac1bc67d8edf86e1735f3a8dde0cb530f9 Mon Sep 17 00:00:00 2001 From: jahooma Date: Tue, 25 Jan 2022 14:16:32 -0600 Subject: [PATCH] Add about field to Fold --- common/fold.ts | 1 + functions/src/create-fold.ts | 8 +++- web/components/edit-fold-button.tsx | 25 ++++++++++- web/lib/firebase/api-call.ts | 2 +- web/pages/fold/[...slugs]/index.tsx | 12 ++--- web/pages/folds.tsx | 69 ++++++++++++++++++----------- 6 files changed, 80 insertions(+), 37 deletions(-) diff --git a/common/fold.ts b/common/fold.ts index c9df3389..46be7499 100644 --- a/common/fold.ts +++ b/common/fold.ts @@ -2,6 +2,7 @@ export type Fold = { id: string slug: string name: string + about: string curatorId: string // User id createdTime: number diff --git a/functions/src/create-fold.ts b/functions/src/create-fold.ts index eb75a762..a653fa93 100644 --- a/functions/src/create-fold.ts +++ b/functions/src/create-fold.ts @@ -12,6 +12,7 @@ export const createFold = functions.runWith({ minInstances: 1 }).https.onCall( async ( data: { name: string + about: string tags: string[] }, context @@ -22,7 +23,7 @@ export const createFold = functions.runWith({ minInstances: 1 }).https.onCall( const creator = await getUser(userId) if (!creator) return { status: 'error', message: 'User not found' } - const { name, tags } = data + const { name, about, tags } = data if (!name || typeof name !== 'string') return { status: 'error', message: 'Name must be a non-empty string' } @@ -35,7 +36,9 @@ export const createFold = functions.runWith({ minInstances: 1 }).https.onCall( creator.username, 'named', name, - 'on', + 'about', + about, + 'tags', tags ) @@ -48,6 +51,7 @@ export const createFold = functions.runWith({ minInstances: 1 }).https.onCall( curatorId: userId, slug, name, + about, tags, createdTime: Date.now(), contractIds: [], diff --git a/web/components/edit-fold-button.tsx b/web/components/edit-fold-button.tsx index 2f840eff..3ac2504d 100644 --- a/web/components/edit-fold-button.tsx +++ b/web/components/edit-fold-button.tsx @@ -12,7 +12,8 @@ import { TagsList } from './tags-list' export function EditFoldButton(props: { fold: Fold }) { const { fold } = props - const [name, setName] = useState(fold?.name ?? '') + const [name, setName] = useState(fold.name) + const [about, setAbout] = useState(fold.about ?? '') const initialOtherTags = fold?.tags.filter((tag) => tag !== toCamelCase(name)).join(', ') ?? '' @@ -23,13 +24,16 @@ export function EditFoldButton(props: { fold: Fold }) { const tags = parseWordsAsTags(toCamelCase(name) + ' ' + otherTags) const saveDisabled = - !name || (name === fold.name && _.isEqual(tags, fold.tags)) + name === fold.name && + _.isEqual(tags, fold.tags) && + about === (fold.about ?? '') const onSubmit = async () => { setIsSubmitting(true) await updateFold(fold, { name, + about, tags, }) @@ -66,6 +70,23 @@ export function EditFoldButton(props: { fold: Fold }) { +
+ + + setAbout(e.target.value || '')} + /> +
+ + +
)