From 09d4afbf86c5591c1e4514a107322f27a7a1b9b7 Mon Sep 17 00:00:00 2001 From: andrashee Date: Fri, 22 Nov 2024 10:14:46 +0100 Subject: [PATCH 1/3] feature(shared): Add public and featured flag to campaign model --- admin/src/collections/Campaigns.ts | 12 ++++++++++++ shared/src/types/campaign.ts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/admin/src/collections/Campaigns.ts b/admin/src/collections/Campaigns.ts index fb0f6c1cc..1660ae6d3 100644 --- a/admin/src/collections/Campaigns.ts +++ b/admin/src/collections/Campaigns.ts @@ -104,6 +104,18 @@ export const campaignsCollection = buildAuditedCollection({ enumValues: campaignStatusEnumValues, validation: { required: true }, }, + public: { + dataType: 'boolean', + name: 'Public', + description: 'Listed on campaign overview', + defaultValue: false, + }, + featured: { + dataType: 'boolean', + name: 'Featured', + description: 'Featured on campaign overview', + defaultValue: false, + }, metadata_description: { dataType: 'string', name: 'Metadata Description', diff --git a/shared/src/types/campaign.ts b/shared/src/types/campaign.ts index cf0d11dfa..125a72df3 100644 --- a/shared/src/types/campaign.ts +++ b/shared/src/types/campaign.ts @@ -18,6 +18,8 @@ export type Campaign = { goal_currency?: Currency; end_date: Timestamp; status: CampaignStatus; + public?: boolean; + featured?: boolean; metadata_description?: string; metadata_ogImage?: string; metadata_twitterImage?: string; From 1f2257e726f6cb77d543a8c5e87ef95e9eae342c Mon Sep 17 00:00:00 2001 From: andrashee Date: Fri, 22 Nov 2024 11:01:01 +0100 Subject: [PATCH 2/3] feature(shared): links & slug --- admin/src/collections/Campaigns.ts | 34 ++++++++++++++++++++++++++++++ shared/src/types/campaign.ts | 11 ++++++++++ 2 files changed, 45 insertions(+) diff --git a/admin/src/collections/Campaigns.ts b/admin/src/collections/Campaigns.ts index 1660ae6d3..f1c82de9b 100644 --- a/admin/src/collections/Campaigns.ts +++ b/admin/src/collections/Campaigns.ts @@ -68,6 +68,36 @@ export const campaignsCollection = buildAuditedCollection({ description: 'Visible in the fundraising page.', multiline: true, }, + link_website: { + title: 'Website Link', + dataType: 'string', + validation: { required: false }, + description: 'The link to the website (optional)', + }, + link_instagram: { + title: 'Instagram Link', + dataType: 'string', + validation: { required: false }, + description: 'The link to the Instagram profile (optional)', + }, + link_tiktok: { + title: 'TikTok Link', + dataType: 'string', + validation: { required: false }, + description: 'The link to the TikTok profile (optional)', + }, + link_facebook: { + title: 'Facebook Link', + dataType: 'string', + validation: { required: false }, + description: 'The link to the Facebook profile (optional)', + }, + link_x: { + title: 'X (formerly Twitter) Link', + dataType: 'string', + validation: { required: false }, + description: 'The link to the X profile (optional)', + }, amount_collected_chf: { dataType: 'number', name: 'Collected amount in CHF', @@ -116,6 +146,10 @@ export const campaignsCollection = buildAuditedCollection({ description: 'Featured on campaign overview', defaultValue: false, }, + slug: { + dataType: 'string', + name: 'Url Slug', + }, metadata_description: { dataType: 'string', name: 'Metadata Description', diff --git a/shared/src/types/campaign.ts b/shared/src/types/campaign.ts index 125a72df3..90c98ef8c 100644 --- a/shared/src/types/campaign.ts +++ b/shared/src/types/campaign.ts @@ -12,6 +12,11 @@ export type Campaign = { second_description?: string; third_description_title?: string; third_description?: string; + link_website?: string; + link_instagram?: string; + link_tiktok?: string; + link_facebook?: string; + link_x?: string; amount_collected_chf: number; // automatically updated by incoming payments. contributions: number; // automatically updated by incoming payments. goal?: number; @@ -20,6 +25,7 @@ export type Campaign = { status: CampaignStatus; public?: boolean; featured?: boolean; + slug?: string; // optional, for nicer url instead of firestore id metadata_description?: string; metadata_ogImage?: string; metadata_twitterImage?: string; @@ -29,3 +35,8 @@ export enum CampaignStatus { Active = 'active', Inactive = 'inactive', } + +export type Link = { + name: string; + url: string; +}; From bb0bc601143e907ce11193d12faf85490565a1da Mon Sep 17 00:00:00 2001 From: andrashee Date: Fri, 22 Nov 2024 11:08:00 +0100 Subject: [PATCH 3/3] pr review --- admin/src/collections/Campaigns.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/admin/src/collections/Campaigns.ts b/admin/src/collections/Campaigns.ts index f1c82de9b..41d3fbf56 100644 --- a/admin/src/collections/Campaigns.ts +++ b/admin/src/collections/Campaigns.ts @@ -149,6 +149,13 @@ export const campaignsCollection = buildAuditedCollection({ slug: { dataType: 'string', name: 'Url Slug', + validation: { + required: true, + matches: /^[a-z0-9]+(?:-[a-z0-9]+)*$/, + matchMessage: 'Slug must contain only lowercase letters, numbers, and hyphens', + }, + description: + 'URL-friendly version of the title. Must be unique and contain only lowercase letters, numbers, and hyphens.', }, metadata_description: { dataType: 'string',