From 04d0b812f0f8e27cc7fd8a2bf5fff64a9633c311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 22 Oct 2024 16:11:30 +0200 Subject: [PATCH 1/2] Support events with external join MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-api/lib/entities/status.ts | 2 +- packages/pl-api/package.json | 2 +- packages/pl-fe/package.json | 2 +- packages/pl-fe/src/components/ui/button/index.tsx | 11 +++++++++++ .../event/components/event-action-button.tsx | 13 +++++++++++++ packages/pl-fe/yarn.lock | 8 ++++---- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/packages/pl-api/lib/entities/status.ts b/packages/pl-api/lib/entities/status.ts index b89c78578..ba56f6db8 100644 --- a/packages/pl-api/lib/entities/status.ts +++ b/packages/pl-api/lib/entities/status.ts @@ -19,7 +19,7 @@ const statusEventSchema = v.object({ name: v.fallback(v.string(), ''), start_time: v.fallback(v.nullable(datetimeSchema), null), end_time: v.fallback(v.nullable(datetimeSchema), null), - join_mode: v.fallback(v.nullable(v.picklist(['free', 'restricted', 'invite'])), null), + join_mode: v.fallback(v.nullable(v.picklist(['free', 'restricted', 'invite', 'external'])), null), participants_count: v.fallback(v.number(), 0), location: v.fallback(v.nullable(v.object({ name: v.fallback(v.string(), ''), diff --git a/packages/pl-api/package.json b/packages/pl-api/package.json index 6df7d29b5..73c958266 100644 --- a/packages/pl-api/package.json +++ b/packages/pl-api/package.json @@ -1,6 +1,6 @@ { "name": "pl-api", - "version": "0.1.3", + "version": "0.1.4", "type": "module", "homepage": "https://github.com/mkljczk/pl-fe/tree/fork/packages/pl-api", "repository": { diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index 026b19883..f1e27d489 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -102,7 +102,7 @@ "mini-css-extract-plugin": "^2.9.1", "multiselect-react-dropdown": "^2.0.25", "path-browserify": "^1.0.1", - "pl-api": "^0.1.3", + "pl-api": "^0.1.4", "postcss": "^8.4.47", "process": "^0.11.10", "punycode": "^2.1.1", diff --git a/packages/pl-fe/src/components/ui/button/index.tsx b/packages/pl-fe/src/components/ui/button/index.tsx index 373b10754..bf83c5bbf 100644 --- a/packages/pl-fe/src/components/ui/button/index.tsx +++ b/packages/pl-fe/src/components/ui/button/index.tsx @@ -24,6 +24,8 @@ interface IButton extends Pick< text?: React.ReactNode; /** Makes the button into a navlink, if provided. */ to?: string; + /** Makes the button into an anchor, if provided. */ + href?: string; /** Styles the button visually with a predefined theme. */ theme?: ButtonThemes; } @@ -40,6 +42,7 @@ const Button = React.forwardRef(({ text, theme = 'secondary', to, + href, type = 'button', className, ...props @@ -87,6 +90,14 @@ const Button = React.forwardRef(({ ); } + if (href) { + return ( + + {renderButton()} + + ); + } + return renderButton(); }); diff --git a/packages/pl-fe/src/features/event/components/event-action-button.tsx b/packages/pl-fe/src/features/event/components/event-action-button.tsx index f0d7ee84e..92f03feb8 100644 --- a/packages/pl-fe/src/features/event/components/event-action-button.tsx +++ b/packages/pl-fe/src/features/event/components/event-action-button.tsx @@ -30,6 +30,19 @@ const EventActionButton: React.FC = ({ status, theme = 'secondary' const event = status.event!; + if (event.join_mode === 'external') { + return ( + + ); + } + const handleJoin: React.EventHandler = (e) => { e.preventDefault(); diff --git a/packages/pl-fe/yarn.lock b/packages/pl-fe/yarn.lock index dd79bc7fb..25e2d5838 100644 --- a/packages/pl-fe/yarn.lock +++ b/packages/pl-fe/yarn.lock @@ -7570,10 +7570,10 @@ pkg-dir@^4.1.0: dependencies: find-up "^4.0.0" -pl-api@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.1.3.tgz#72d434a0ec8d713e5b227b35497da33cf26975a6" - integrity sha512-vcl3aGOy3AocQek3+S97QB0jIcF+iV66FvMqrFB/qnfo3Ryte9dcG6XcDxQ5LpogFQAILKk/Mm5uY2W9RZtwHA== +pl-api@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.1.4.tgz#8062dc0ac34bb60f7dcbcb556cfbc18a19482948" + integrity sha512-8ZUQeoCgJZFsp9wrrBOEL2wKRPfLf7Jxz9vPTUnGQMPA0BBtQvsgDxomEC96fRjO+ycxK7gEZrKLVEaNFA0nyw== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3" From e88b10599fb1b5487b032f1a1c08cf54a5c2b06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 22 Oct 2024 16:12:33 +0200 Subject: [PATCH 2/2] pl-fe: Indicate that the join button leads to external page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../pl-fe/src/features/event/components/event-action-button.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/pl-fe/src/features/event/components/event-action-button.tsx b/packages/pl-fe/src/features/event/components/event-action-button.tsx index 92f03feb8..9b9f03687 100644 --- a/packages/pl-fe/src/features/event/components/event-action-button.tsx +++ b/packages/pl-fe/src/features/event/components/event-action-button.tsx @@ -36,6 +36,7 @@ const EventActionButton: React.FC = ({ status, theme = 'secondary' className='min-w-max' size='sm' theme={theme} + icon={require('@tabler/icons/outline/external-link.svg')} href={status.url} >