@selfcommunity/react-templates
Version:
React Templates Components to integrate a Community created with SelfCommunity.
64 lines (57 loc) • 2.51 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, styled } from '@mui/material';
import { EventHeader } from '@selfcommunity/react-ui';
import { useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
import EventSkeletonTemplate from './Skeleton';
import { useThemeProps } from '@mui/system';
import classNames from 'classnames';
import { PREFIX } from './constants';
import EventFeed from '../EventFeed';
const classes = {
root: `${PREFIX}-root`,
feed: `${PREFIX}-feed`
};
const Root = styled(Box, {
name: PREFIX,
slot: 'Root'
})(() => ({}));
/**
* > API documentation for the Community-JS Category Template. Learn about the available props and the CSS API.
*
*
* This component renders a specific event's template.
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-templates/Components/Group)
#### Import
```jsx
import {Group} from '@selfcommunity/react-templates';
```
#### Component Name
The name `SCGroupTemplate` can be used when providing style overrides in the theme.
#### CSS
|Rule Name|Global class|Description|
|---|---|---|
|root|.SCGroupTemplate-root|Styles applied to the root element.|
|feed|.SCGroupTemplate-feed|Styles applied to the feed element.|
*
* @param inProps
*/
export default function Event(inProps) {
// PROPS
const props = useThemeProps({
props: inProps,
name: PREFIX
});
const { id = 'event', className, event, eventId, widgets, FeedObjectProps, FeedSidebarProps, EventFeedProps = {}, EventHeaderProps = {} } = props;
// HOOKS
const { scEvent } = useSCFetchEvent({ id: eventId, event });
const scUserContext = useSCUser();
if (scUserContext.user === undefined ||
!scEvent ||
(scUserContext.user &&
((scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED))) {
return _jsx(EventSkeletonTemplate, {});
}
return (_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: [_jsx(EventHeader, Object.assign({ event: scEvent }, EventHeaderProps)), _jsx(EventFeed, Object.assign({ className: classes.feed, event: scEvent, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, EventFeedProps))] })));
}