Support events with external join

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-10-22 16:11:30 +02:00
parent 775f6b1d2b
commit 04d0b812f0
6 changed files with 31 additions and 7 deletions

View file

@ -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(), ''),

View file

@ -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": {

View file

@ -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",

View file

@ -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<HTMLButtonElement, IButton>(({
text,
theme = 'secondary',
to,
href,
type = 'button',
className,
...props
@ -87,6 +90,14 @@ const Button = React.forwardRef<HTMLButtonElement, IButton>(({
);
}
if (href) {
return (
<a href={href} target='_blank' rel='noopener' tabIndex={-1} className='inline-flex'>
{renderButton()}
</a>
);
}
return renderButton();
});

View file

@ -30,6 +30,19 @@ const EventActionButton: React.FC<IEventAction> = ({ status, theme = 'secondary'
const event = status.event!;
if (event.join_mode === 'external') {
return (
<Button
className='min-w-max'
size='sm'
theme={theme}
href={status.url}
>
<FormattedMessage id='event.join_state.empty' defaultMessage='Participate' />
</Button>
);
}
const handleJoin: React.EventHandler<React.MouseEvent> = (e) => {
e.preventDefault();

View file

@ -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"