@selfcommunity/react-ui 0.7.9-alpha.2 → 0.7.9-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/cjs/components/Composer/Composer.d.ts +2 -1
- package/lib/cjs/components/Composer/Composer.js +40 -11
- package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +35 -13
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- package/lib/cjs/components/EditGroupButton/EditGroupButton.js +57 -0
- package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/EditGroupButton/index.js +5 -0
- package/lib/cjs/components/Group/Group.d.ts +4 -3
- package/lib/cjs/components/Group/Group.js +2 -2
- package/lib/cjs/components/Group/Skeleton.js +1 -1
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
- package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
- package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
- package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
- package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
- package/lib/cjs/components/GroupForm/index.d.ts +3 -0
- package/lib/cjs/components/GroupForm/index.js +5 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.js +4 -2
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +6 -4
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +19 -14
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
- package/lib/cjs/components/Groups/Groups.d.ts +65 -0
- package/lib/cjs/components/Groups/Groups.js +181 -0
- package/lib/cjs/components/Groups/Skeleton.d.ts +34 -0
- package/lib/cjs/components/Groups/Skeleton.js +45 -0
- package/lib/cjs/components/Groups/constants.d.ts +1 -0
- package/lib/cjs/components/Groups/constants.js +4 -0
- package/lib/cjs/components/Groups/index.d.ts +4 -0
- package/lib/cjs/components/Groups/index.js +8 -0
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/cjs/index.d.ts +5 -3
- package/lib/cjs/index.js +10 -4
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/esm/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/esm/components/Composer/Composer.d.ts +2 -1
- package/lib/esm/components/Composer/Composer.js +40 -11
- package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +34 -13
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- package/lib/esm/components/EditGroupButton/EditGroupButton.js +54 -0
- package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
- package/lib/esm/components/EditGroupButton/index.js +2 -0
- package/lib/esm/components/Group/Group.d.ts +4 -3
- package/lib/esm/components/Group/Group.js +2 -2
- package/lib/esm/components/Group/Skeleton.js +1 -1
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
- package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/esm/components/GroupAutocomplete/index.js +2 -0
- package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/esm/components/GroupForm/GroupForm.js +236 -0
- package/lib/esm/components/GroupForm/constants.d.ts +1 -0
- package/lib/esm/components/GroupForm/constants.js +1 -0
- package/lib/esm/components/GroupForm/index.d.ts +3 -0
- package/lib/esm/components/GroupForm/index.js +2 -0
- package/lib/esm/components/GroupHeader/GroupHeader.js +4 -2
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +6 -4
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +20 -15
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
- package/lib/esm/components/Groups/Groups.d.ts +65 -0
- package/lib/esm/components/Groups/Groups.js +178 -0
- package/lib/esm/components/Groups/Skeleton.d.ts +34 -0
- package/lib/esm/components/Groups/Skeleton.js +42 -0
- package/lib/esm/components/Groups/constants.d.ts +1 -0
- package/lib/esm/components/Groups/constants.js +1 -0
- package/lib/esm/components/Groups/index.d.ts +4 -0
- package/lib/esm/components/Groups/index.js +4 -0
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/esm/index.d.ts +5 -3
- package/lib/esm/index.js +4 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
- package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
- package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
- package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
- package/lib/cjs/components/CreateGroup/index.js +0 -5
- package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
- package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
- package/lib/esm/components/CreateGroup/constants.js +0 -1
- package/lib/esm/components/CreateGroup/index.d.ts +0 -3
- package/lib/esm/components/CreateGroup/index.js +0 -2
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
5
|
+
import TextField from '@mui/material/TextField';
|
|
6
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
7
|
+
import parse from 'autosuggest-highlight/parse';
|
|
8
|
+
import match from 'autosuggest-highlight/match';
|
|
9
|
+
import { Avatar, Box, Typography } from '@mui/material';
|
|
10
|
+
import { useSCFetchGroups } from '@selfcommunity/react-core';
|
|
11
|
+
import { styled } from '@mui/material/styles';
|
|
12
|
+
import { useThemeProps } from '@mui/system';
|
|
13
|
+
const PREFIX = 'SCGroupAutocomplete';
|
|
14
|
+
const classes = {
|
|
15
|
+
root: `${PREFIX}-root`
|
|
16
|
+
};
|
|
17
|
+
const Root = styled(Autocomplete, {
|
|
18
|
+
name: PREFIX,
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
})(() => ({}));
|
|
22
|
+
/**
|
|
23
|
+
* > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
|
|
27
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
|
|
28
|
+
*
|
|
29
|
+
* #### Import
|
|
30
|
+
* ```jsx
|
|
31
|
+
* import {GroupAutocomplete} from '@selfcommunity/react-ui';
|
|
32
|
+
* ```
|
|
33
|
+
* #### Component Name
|
|
34
|
+
* The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
|
|
35
|
+
*
|
|
36
|
+
* #### CSS
|
|
37
|
+
*
|
|
38
|
+
* |Rule Name|Global class|Description|
|
|
39
|
+
* |---|---|---|
|
|
40
|
+
* |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
|
|
41
|
+
*
|
|
42
|
+
* @param inProps
|
|
43
|
+
*/
|
|
44
|
+
const GroupAutocomplete = (inProps) => {
|
|
45
|
+
const props = useThemeProps({
|
|
46
|
+
props: inProps,
|
|
47
|
+
name: PREFIX
|
|
48
|
+
});
|
|
49
|
+
// Props
|
|
50
|
+
const { onChange, defaultValue = null, disabled = false, TextFieldProps = {
|
|
51
|
+
variant: 'outlined',
|
|
52
|
+
label: React.createElement(FormattedMessage, { id: "ui.groupAutocomplete.label", defaultMessage: "ui.groupAutocomplete.label" })
|
|
53
|
+
} } = props, rest = __rest(props, ["onChange", "defaultValue", "disabled", "TextFieldProps"]);
|
|
54
|
+
// State
|
|
55
|
+
const [open, setOpen] = useState(false);
|
|
56
|
+
const [value, setValue] = useState(typeof defaultValue === 'string' ? null : defaultValue);
|
|
57
|
+
// HOOKS
|
|
58
|
+
const { groups, isLoading } = useSCFetchGroups();
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (value === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
onChange && onChange(value);
|
|
64
|
+
}, [value]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!isLoading && typeof defaultValue === 'string') {
|
|
67
|
+
setValue(groups.find((g) => g.id === Number(defaultValue)));
|
|
68
|
+
}
|
|
69
|
+
}, [isLoading]);
|
|
70
|
+
// Handlers
|
|
71
|
+
const handleOpen = () => {
|
|
72
|
+
setOpen(true);
|
|
73
|
+
};
|
|
74
|
+
const handleClose = () => {
|
|
75
|
+
setOpen(false);
|
|
76
|
+
};
|
|
77
|
+
const handleChange = (event, value) => {
|
|
78
|
+
setValue(value);
|
|
79
|
+
};
|
|
80
|
+
// Render
|
|
81
|
+
return (React.createElement(Root, Object.assign({ freeSolo: true, className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: groups || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: React.createElement(FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
|
|
82
|
+
// renderTags={(value, getTagProps) => {
|
|
83
|
+
// return value.map((option: any, index) => (
|
|
84
|
+
// <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
|
|
85
|
+
// ));
|
|
86
|
+
// }}
|
|
87
|
+
renderOption: (props, option, { inputValue }) => {
|
|
88
|
+
const matches = match(option.name, inputValue);
|
|
89
|
+
const parts = parse(option.name, matches);
|
|
90
|
+
return (React.createElement(Box, Object.assign({ component: "li" }, props),
|
|
91
|
+
React.createElement(Avatar, { alt: option.name, src: option.image_small, sx: { marginRight: 1 } }),
|
|
92
|
+
React.createElement(React.Fragment, null, parts.map((part, index) => (React.createElement(Typography, { key: index, sx: { fontWeight: part.highlight ? 700 : 400, marginRight: 0.2 } }, part.text))))));
|
|
93
|
+
}, renderInput: (params) => {
|
|
94
|
+
return (React.createElement(TextField, Object.assign({}, params, TextFieldProps, { margin: "dense", InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'groups', endAdornment: (React.createElement(React.Fragment, null,
|
|
95
|
+
isLoading ? React.createElement(CircularProgress, { color: "inherit", size: 20 }) : null,
|
|
96
|
+
params.InputProps.endAdornment)) }) })));
|
|
97
|
+
} }, rest)));
|
|
98
|
+
};
|
|
99
|
+
export default GroupAutocomplete;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
export interface GroupFormProps extends BaseDialogProps {
|
|
4
|
+
/**
|
|
5
|
+
* Overrides or extends the styles applied to the component.
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Open dialog
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* On dialog close callback function
|
|
16
|
+
* @default null
|
|
17
|
+
*/
|
|
18
|
+
onClose?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Group Object
|
|
21
|
+
* @default null
|
|
22
|
+
*/
|
|
23
|
+
group?: SCGroupType;
|
|
24
|
+
/**
|
|
25
|
+
* On success callback function
|
|
26
|
+
* @default null
|
|
27
|
+
*/
|
|
28
|
+
onSuccess?: (data: SCGroupType) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Any other properties
|
|
31
|
+
*/
|
|
32
|
+
[p: string]: any;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
*> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
|
|
36
|
+
*
|
|
37
|
+
#### Import
|
|
38
|
+
```jsx
|
|
39
|
+
import {GroupForm} from '@selfcommunity/react-ui';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Component Name
|
|
43
|
+
The name `SCGroupForm` can be used when providing style overrides in the theme.
|
|
44
|
+
|
|
45
|
+
#### CSS
|
|
46
|
+
|
|
47
|
+
|Rule Name|Global class|Description|
|
|
48
|
+
|---|---|---|
|
|
49
|
+
|root|.SCGroupForm-root|Styles applied to the root element.|
|
|
50
|
+
|active|.SCGroupForm-active|Styles applied to the active element.|
|
|
51
|
+
|title|.SCGroupForm-title|Styles applied to the title element.|
|
|
52
|
+
|header|.SCGroupForm-header|Styles applied to the header element.|
|
|
53
|
+
|cover|.SCGroupForm-cover|Styles applied to the cover field.|
|
|
54
|
+
|avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
|
|
55
|
+
|form|.SCGroupForm-form|Styles applied to the form element.|
|
|
56
|
+
|switch|.SCGroupForm-switch|Styles applied to the switch element.|
|
|
57
|
+
|switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
|
|
58
|
+
|name|.SCGroupForm-name|Styles applied to the name field.|
|
|
59
|
+
|description|.SCGroupForm-description|Styles applied to the description field.|
|
|
60
|
+
|content|.SCGroupForm-content|Styles applied to the element.|
|
|
61
|
+
|privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
|
|
62
|
+
|privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
|
|
63
|
+
|visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
|
|
64
|
+
|visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
|
|
65
|
+
|inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
|
|
66
|
+
|error|.SCGroupForm-error|Styles applied to the error elements.|
|
|
67
|
+
|
|
68
|
+
* @param inProps
|
|
69
|
+
*/
|
|
70
|
+
export default function GroupForm(inProps: GroupFormProps): JSX.Element;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { useThemeProps } from '@mui/system';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { Avatar, Box, Divider, FormGroup, Icon, Paper, Stack, Switch, TextField, Typography } from '@mui/material';
|
|
6
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
7
|
+
import { SCPreferences, useSCPreferences } from '@selfcommunity/react-core';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { PREFIX } from './constants';
|
|
10
|
+
import BaseDialog from '../../shared/BaseDialog';
|
|
11
|
+
import { LoadingButton } from '@mui/lab';
|
|
12
|
+
import ChangeGroupPicture from '../ChangeGroupPicture';
|
|
13
|
+
import ChangeGroupCover from '../ChangeGroupCover';
|
|
14
|
+
import { GROUP_DESCRIPTION_MAX_LENGTH, GROUP_TITLE_MAX_LENGTH } from '../../constants/Group';
|
|
15
|
+
import GroupInviteButton from '../GroupInviteButton';
|
|
16
|
+
import { SCGroupPrivacyType } from '@selfcommunity/types';
|
|
17
|
+
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
18
|
+
import { formatHttpErrorCode, GroupService } from '@selfcommunity/api-services';
|
|
19
|
+
import { Logger } from '@selfcommunity/utils';
|
|
20
|
+
const messages = defineMessages({
|
|
21
|
+
name: {
|
|
22
|
+
id: 'ui.groupForm.name.placeholder',
|
|
23
|
+
defaultMessage: 'ui.groupForm.name.placeholder'
|
|
24
|
+
},
|
|
25
|
+
description: {
|
|
26
|
+
id: 'ui.groupForm.description.placeholder',
|
|
27
|
+
defaultMessage: 'ui.groupForm.description.placeholder'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const classes = {
|
|
31
|
+
root: `${PREFIX}-root`,
|
|
32
|
+
active: `${PREFIX}-active`,
|
|
33
|
+
title: `${PREFIX}-title`,
|
|
34
|
+
header: `${PREFIX}-header`,
|
|
35
|
+
cover: `${PREFIX}-cover`,
|
|
36
|
+
avatar: `${PREFIX}-avatar`,
|
|
37
|
+
form: `${PREFIX}-form`,
|
|
38
|
+
switch: `${PREFIX}-switch`,
|
|
39
|
+
switchLabel: `${PREFIX}-switch-label`,
|
|
40
|
+
name: `${PREFIX}-name`,
|
|
41
|
+
description: `${PREFIX}-description`,
|
|
42
|
+
content: `${PREFIX}-content`,
|
|
43
|
+
privacySection: `${PREFIX}-privacy-section`,
|
|
44
|
+
privacySectionInfo: `${PREFIX}-privacy-section-info`,
|
|
45
|
+
visibilitySection: `${PREFIX}-visibility-section`,
|
|
46
|
+
visibilitySectionInfo: `${PREFIX}-visibility-section-info`,
|
|
47
|
+
inviteSection: `${PREFIX}-invite-section`,
|
|
48
|
+
error: `${PREFIX}-error`
|
|
49
|
+
};
|
|
50
|
+
const Root = styled(BaseDialog, {
|
|
51
|
+
name: PREFIX,
|
|
52
|
+
slot: 'Root'
|
|
53
|
+
})(() => ({}));
|
|
54
|
+
/**
|
|
55
|
+
*> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
|
|
56
|
+
*
|
|
57
|
+
#### Import
|
|
58
|
+
```jsx
|
|
59
|
+
import {GroupForm} from '@selfcommunity/react-ui';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Component Name
|
|
63
|
+
The name `SCGroupForm` can be used when providing style overrides in the theme.
|
|
64
|
+
|
|
65
|
+
#### CSS
|
|
66
|
+
|
|
67
|
+
|Rule Name|Global class|Description|
|
|
68
|
+
|---|---|---|
|
|
69
|
+
|root|.SCGroupForm-root|Styles applied to the root element.|
|
|
70
|
+
|active|.SCGroupForm-active|Styles applied to the active element.|
|
|
71
|
+
|title|.SCGroupForm-title|Styles applied to the title element.|
|
|
72
|
+
|header|.SCGroupForm-header|Styles applied to the header element.|
|
|
73
|
+
|cover|.SCGroupForm-cover|Styles applied to the cover field.|
|
|
74
|
+
|avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
|
|
75
|
+
|form|.SCGroupForm-form|Styles applied to the form element.|
|
|
76
|
+
|switch|.SCGroupForm-switch|Styles applied to the switch element.|
|
|
77
|
+
|switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
|
|
78
|
+
|name|.SCGroupForm-name|Styles applied to the name field.|
|
|
79
|
+
|description|.SCGroupForm-description|Styles applied to the description field.|
|
|
80
|
+
|content|.SCGroupForm-content|Styles applied to the element.|
|
|
81
|
+
|privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
|
|
82
|
+
|privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
|
|
83
|
+
|visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
|
|
84
|
+
|visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
|
|
85
|
+
|inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
|
|
86
|
+
|error|.SCGroupForm-error|Styles applied to the error elements.|
|
|
87
|
+
|
|
88
|
+
* @param inProps
|
|
89
|
+
*/
|
|
90
|
+
export default function GroupForm(inProps) {
|
|
91
|
+
//PROPS
|
|
92
|
+
const props = useThemeProps({
|
|
93
|
+
props: inProps,
|
|
94
|
+
name: PREFIX
|
|
95
|
+
});
|
|
96
|
+
const { className, open = true, onClose, onSuccess, group = null } = props, rest = __rest(props, ["className", "open", "onClose", "onSuccess", "group"]);
|
|
97
|
+
const initialFieldState = {
|
|
98
|
+
imageOriginal: group ? group.image_medium : '',
|
|
99
|
+
imageOriginalFile: '',
|
|
100
|
+
emotionalImageOriginal: group ? group.emotional_image : '',
|
|
101
|
+
emotionalImageOriginalFile: '',
|
|
102
|
+
name: group ? group.name : '',
|
|
103
|
+
description: group ? group.description : '',
|
|
104
|
+
isPublic: group && group.privacy === SCGroupPrivacyType.PUBLIC,
|
|
105
|
+
isVisible: group ? group.visible : true,
|
|
106
|
+
invitedUsers: null,
|
|
107
|
+
isSubmitting: false
|
|
108
|
+
};
|
|
109
|
+
// STATE
|
|
110
|
+
const [field, setField] = useState(initialFieldState);
|
|
111
|
+
const [error, setError] = useState({});
|
|
112
|
+
// INTL
|
|
113
|
+
const intl = useIntl();
|
|
114
|
+
// PREFERENCES
|
|
115
|
+
const scPreferences = useSCPreferences();
|
|
116
|
+
const _backgroundCover = Object.assign({}, (field.emotionalImageOriginal
|
|
117
|
+
? { background: `url('${field.emotionalImageOriginal}') center / cover` }
|
|
118
|
+
: { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
|
|
119
|
+
function handleChangeAvatar(avatar) {
|
|
120
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginalFile']: avatar })));
|
|
121
|
+
const reader = new FileReader();
|
|
122
|
+
reader.onloadend = () => {
|
|
123
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginal']: reader.result })));
|
|
124
|
+
};
|
|
125
|
+
reader.readAsDataURL(avatar);
|
|
126
|
+
if (error.imageOriginalError) {
|
|
127
|
+
delete error.imageOriginalError;
|
|
128
|
+
setError(error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function handleChangeCover(cover) {
|
|
132
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginalFile']: cover })));
|
|
133
|
+
const reader = new FileReader();
|
|
134
|
+
reader.onloadend = () => {
|
|
135
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginal']: reader.result })));
|
|
136
|
+
};
|
|
137
|
+
reader.readAsDataURL(cover);
|
|
138
|
+
if (error.emotionalImageOriginalError) {
|
|
139
|
+
delete error.emotionalImageOriginalError;
|
|
140
|
+
setError(error);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const handleSubmit = () => {
|
|
144
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
145
|
+
const formData = new FormData();
|
|
146
|
+
formData.append('name', field.name);
|
|
147
|
+
formData.append('description', field.description);
|
|
148
|
+
formData.append('privacy', field.isPublic ? SCGroupPrivacyType.PUBLIC : SCGroupPrivacyType.PRIVATE);
|
|
149
|
+
formData.append('visible', field.isVisible);
|
|
150
|
+
if (field.imageOriginalFile) {
|
|
151
|
+
formData.append('image_original', field.imageOriginalFile);
|
|
152
|
+
}
|
|
153
|
+
if (field.emotionalImageOriginalFile) {
|
|
154
|
+
formData.append('emotional_image_original', field.emotionalImageOriginalFile);
|
|
155
|
+
}
|
|
156
|
+
for (const key in field.invitedUsers) {
|
|
157
|
+
formData.append(key, field.invitedUsers[key]);
|
|
158
|
+
}
|
|
159
|
+
let groupService;
|
|
160
|
+
if (group) {
|
|
161
|
+
groupService = GroupService.updateGroup(group.id, formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
groupService = GroupService.createGroup(formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
165
|
+
}
|
|
166
|
+
groupService
|
|
167
|
+
.then((data) => {
|
|
168
|
+
onSuccess && onSuccess(data);
|
|
169
|
+
onClose && onClose();
|
|
170
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
171
|
+
})
|
|
172
|
+
.catch((e) => {
|
|
173
|
+
setError(Object.assign(Object.assign({}, error), formatHttpErrorCode(e)));
|
|
174
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
175
|
+
Logger.error(SCOPE_SC_UI, e);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
const handleInviteSection = (data) => {
|
|
179
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['invitedUsers']: data })));
|
|
180
|
+
};
|
|
181
|
+
const handleChange = (event) => {
|
|
182
|
+
const { name, value } = event.target;
|
|
183
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
184
|
+
if (error[`${name}Error`]) {
|
|
185
|
+
delete error[`${name}Error`];
|
|
186
|
+
setError(error);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Renders root object
|
|
191
|
+
*/
|
|
192
|
+
return (React.createElement(Root, Object.assign({ DialogContentProps: { dividers: false }, title: group ? (React.createElement(FormattedMessage, { id: "ui.groupForm.title.edit", defaultMessage: "ui.groupForm.title.edit" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.title", defaultMessage: "ui.groupForm.title" })), open: open, onClose: onClose, className: classNames(classes.root, className), actions: React.createElement(LoadingButton, { loading: field.isSubmitting, disabled: !field.name || Object.keys(error).length !== 0, variant: "contained", onClick: handleSubmit, color: "secondary" }, group ? (React.createElement(FormattedMessage, { id: "ui.groupForm.button.edit", defaultMessage: "ui.groupForm.button.edit" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.button.create", defaultMessage: "ui.groupForm.button.create" }))) }, rest),
|
|
193
|
+
React.createElement(React.Fragment, null,
|
|
194
|
+
React.createElement(React.Fragment, null,
|
|
195
|
+
React.createElement(Paper, { style: _backgroundCover, classes: { root: classes.cover } },
|
|
196
|
+
React.createElement(Box, { className: classes.avatar },
|
|
197
|
+
React.createElement(Avatar, null, field.imageOriginal ? React.createElement("img", { src: field.imageOriginal, alt: "avatar" }) : React.createElement(Icon, null, "icon_image"))),
|
|
198
|
+
React.createElement(React.Fragment, null,
|
|
199
|
+
React.createElement(ChangeGroupPicture, { isCreationMode: true, onChange: handleChangeAvatar }),
|
|
200
|
+
React.createElement(ChangeGroupCover, { isCreationMode: true, onChange: handleChangeCover }))),
|
|
201
|
+
React.createElement(Typography, { className: classNames(classes.header, { [classes.error]: error.emotionalImageOriginalError || error.imageOriginalError }), align: "center" }, error.emotionalImageOriginalError || error.imageOriginalError ? (React.createElement(FormattedMessage, { id: "ui.groupForm.header.error", defaultMessage: "ui.groupForm.header.error" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.header", defaultMessage: "ui.groupForm.header" })))),
|
|
202
|
+
React.createElement(FormGroup, { className: classes.form },
|
|
203
|
+
React.createElement(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
204
|
+
endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_TITLE_MAX_LENGTH - field.name.length)
|
|
205
|
+
} }),
|
|
206
|
+
React.createElement(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
207
|
+
endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_DESCRIPTION_MAX_LENGTH - field.description.length)
|
|
208
|
+
} }),
|
|
209
|
+
React.createElement(Box, { className: classes.privacySection },
|
|
210
|
+
React.createElement(Typography, { variant: "h4" },
|
|
211
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
|
|
212
|
+
React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
213
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) },
|
|
214
|
+
React.createElement(Icon, null, "private"),
|
|
215
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
|
|
216
|
+
React.createElement(Switch, { className: classes.switch, checked: field.isPublic, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))) }),
|
|
217
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) },
|
|
218
|
+
React.createElement(Icon, null, "public"),
|
|
219
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" }))),
|
|
220
|
+
React.createElement(Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))),
|
|
221
|
+
React.createElement(Box, { className: classes.visibilitySection }, !field.isPublic && (React.createElement(React.Fragment, null,
|
|
222
|
+
React.createElement(Typography, { variant: "h4" },
|
|
223
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
|
|
224
|
+
React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
225
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isVisible }) },
|
|
226
|
+
React.createElement(Icon, null, "visibility_off"),
|
|
227
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
|
|
228
|
+
React.createElement(Switch, { className: classes.switch, checked: field.isVisible, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isVisible']: !field.isVisible }))) }),
|
|
229
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isVisible }) },
|
|
230
|
+
React.createElement(Icon, null, "visibility"),
|
|
231
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" }))),
|
|
232
|
+
React.createElement(Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))))),
|
|
233
|
+
React.createElement(Divider, null),
|
|
234
|
+
React.createElement(Box, { className: classes.inviteSection },
|
|
235
|
+
React.createElement(GroupInviteButton, { handleInvitations: handleInviteSection })))));
|
|
236
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCGroupForm";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PREFIX = 'SCGroupForm';
|
|
@@ -13,6 +13,7 @@ import { FormattedMessage } from 'react-intl';
|
|
|
13
13
|
import Bullet from '../../shared/Bullet';
|
|
14
14
|
import ChangeGroupPicture from '../ChangeGroupPicture';
|
|
15
15
|
import GroupMembersButton from '../GroupMembersButton';
|
|
16
|
+
import EditGroupButton from '../EditGroupButton';
|
|
16
17
|
const classes = {
|
|
17
18
|
root: `${PREFIX}-root`,
|
|
18
19
|
cover: `${PREFIX}-cover`,
|
|
@@ -63,7 +64,7 @@ const Root = styled(Box, {
|
|
|
63
64
|
* @param inProps
|
|
64
65
|
*/
|
|
65
66
|
export default function GroupHeader(inProps) {
|
|
66
|
-
var _a
|
|
67
|
+
var _a;
|
|
67
68
|
// PROPS
|
|
68
69
|
const props = useThemeProps({
|
|
69
70
|
props: inProps,
|
|
@@ -77,7 +78,7 @@ export default function GroupHeader(inProps) {
|
|
|
77
78
|
// HOOKS
|
|
78
79
|
const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
|
|
79
80
|
// CONST
|
|
80
|
-
const canEdit = useMemo(() => { var _a
|
|
81
|
+
const canEdit = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
81
82
|
/**
|
|
82
83
|
* Handles Change Avatar
|
|
83
84
|
* @param avatar
|
|
@@ -113,6 +114,7 @@ export default function GroupHeader(inProps) {
|
|
|
113
114
|
React.createElement("div", { className: classes.changeCover },
|
|
114
115
|
React.createElement(ChangeGroupCover, Object.assign({ groupId: scGroup.id, onChange: handleChangeCover }, ChangeCoverProps)))))),
|
|
115
116
|
React.createElement(Box, { className: classes.info },
|
|
117
|
+
canEdit && React.createElement(EditGroupButton, { group: scGroup, groupId: scGroup.id, onEditSuccess: (data) => setSCGroup(data) }),
|
|
116
118
|
React.createElement(Typography, { variant: "h5", className: classes.name }, scGroup.name),
|
|
117
119
|
React.createElement(Box, { className: classes.visibility },
|
|
118
120
|
scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(Typography, { className: classes.visibilityItem },
|
|
@@ -73,25 +73,25 @@ export default function GroupInfoWidget(inProps) {
|
|
|
73
73
|
React.createElement(Typography, { component: "div", className: classes.privacy }, scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(React.Fragment, null,
|
|
74
74
|
React.createElement(Typography, { className: classes.privacyTitle },
|
|
75
75
|
React.createElement(Icon, null, "public"),
|
|
76
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
76
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" })),
|
|
77
77
|
React.createElement(Typography, { variant: "body2" },
|
|
78
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
78
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
|
|
79
79
|
React.createElement(Typography, { className: classes.privacyTitle },
|
|
80
80
|
React.createElement(Icon, null, "private"),
|
|
81
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
81
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
|
|
82
82
|
React.createElement(Typography, { variant: "body2" },
|
|
83
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
83
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))),
|
|
84
84
|
scGroup.privacy === SCGroupPrivacyType.PRIVATE && (React.createElement(Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (React.createElement(React.Fragment, null,
|
|
85
85
|
React.createElement(Typography, { className: classes.visibilityTitle },
|
|
86
86
|
React.createElement(Icon, null, "visibility"),
|
|
87
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
87
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" })),
|
|
88
88
|
React.createElement(Typography, { variant: "body2" },
|
|
89
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
89
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
|
|
90
90
|
React.createElement(Typography, { className: classes.visibilityTitle },
|
|
91
91
|
React.createElement(Icon, null, "visibility_off"),
|
|
92
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
92
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
|
|
93
93
|
React.createElement(Typography, { variant: "body2" },
|
|
94
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
94
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))))),
|
|
95
95
|
React.createElement(Typography, { variant: "body2", className: classes.date },
|
|
96
96
|
React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })))));
|
|
97
97
|
}
|
|
@@ -71,6 +71,7 @@ const DialogRoot = styled(BaseDialog, {
|
|
|
71
71
|
* @param inProps
|
|
72
72
|
*/
|
|
73
73
|
export default function GroupInviteButton(inProps) {
|
|
74
|
+
var _a;
|
|
74
75
|
//PROPS
|
|
75
76
|
const props = useThemeProps({
|
|
76
77
|
props: inProps,
|
|
@@ -105,10 +106,9 @@ export default function GroupInviteButton(inProps) {
|
|
|
105
106
|
}
|
|
106
107
|
return [invited];
|
|
107
108
|
}, [invited]);
|
|
108
|
-
// CONST
|
|
109
|
-
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
110
109
|
// HOOKS
|
|
111
110
|
const { scGroup } = useSCFetchGroup({ id: groupId, group });
|
|
111
|
+
const canEdit = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
112
112
|
// INTL
|
|
113
113
|
const intl = useIntl();
|
|
114
114
|
function fetchResults() {
|
|
@@ -178,8 +178,10 @@ export default function GroupInviteButton(inProps) {
|
|
|
178
178
|
GroupService.inviteOrAcceptGroupRequest(scGroup.id, data)
|
|
179
179
|
.then(() => {
|
|
180
180
|
setIsSending(false);
|
|
181
|
+
setOpen(false);
|
|
181
182
|
})
|
|
182
183
|
.catch((error) => {
|
|
184
|
+
setOpen(false);
|
|
183
185
|
setLoading(false);
|
|
184
186
|
Logger.error(SCOPE_SC_UI, error);
|
|
185
187
|
});
|
|
@@ -223,14 +225,14 @@ export default function GroupInviteButton(inProps) {
|
|
|
223
225
|
/**
|
|
224
226
|
* If there's no authUserId, component is hidden.
|
|
225
227
|
// */
|
|
226
|
-
if (!
|
|
228
|
+
if (!canEdit) {
|
|
227
229
|
return null;
|
|
228
230
|
}
|
|
229
231
|
/**
|
|
230
232
|
* Renders root object
|
|
231
233
|
*/
|
|
232
234
|
return (React.createElement(React.Fragment, null,
|
|
233
|
-
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose,
|
|
235
|
+
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, variant: scGroup ? 'contained' : 'outlined', color: scGroup ? 'secondary' : 'inherit', startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest),
|
|
234
236
|
React.createElement(FormattedMessage, { id: "ui.groupInviteButton", defaultMessage: "ui.groupInviteButton" })),
|
|
235
237
|
open && (React.createElement(DialogRoot, { DialogContentProps: { dividers: false }, open: true, className: classes.dialogRoot, title: React.createElement(React.Fragment, null,
|
|
236
238
|
React.createElement(IconButton, { onClick: handleClose },
|
|
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React, { useEffect, useMemo, useReducer, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import List from '@mui/material/List';
|
|
5
|
-
import { Button, CardContent, ListItem, Typography, useMediaQuery, useTheme } from '@mui/material';
|
|
5
|
+
import { Button, CardActions, CardContent, ListItem, Typography, useMediaQuery, useTheme } from '@mui/material';
|
|
6
6
|
import Widget from '../Widget';
|
|
7
7
|
import { http, Endpoints, GroupService } from '@selfcommunity/api-services';
|
|
8
8
|
import { CacheStrategies, isInteger, Logger } from '@selfcommunity/utils';
|
|
@@ -18,9 +18,11 @@ import { useThemeProps } from '@mui/system';
|
|
|
18
18
|
import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
19
19
|
import { PREFIX } from './constants';
|
|
20
20
|
import User, { UserSkeleton } from '../User';
|
|
21
|
+
import GroupInviteButton from '../GroupInviteButton';
|
|
21
22
|
const classes = {
|
|
22
23
|
root: `${PREFIX}-root`,
|
|
23
24
|
title: `${PREFIX}-title`,
|
|
25
|
+
actions: `${PREFIX}-actions`,
|
|
24
26
|
noResults: `${PREFIX}-no-results`,
|
|
25
27
|
showMore: `${PREFIX}-show-more`,
|
|
26
28
|
dialogRoot: `${PREFIX}-dialog-root`,
|
|
@@ -173,19 +175,22 @@ export default function GroupMembersWidget(inProps) {
|
|
|
173
175
|
if (!state.initialized) {
|
|
174
176
|
return React.createElement(Skeleton, null);
|
|
175
177
|
}
|
|
176
|
-
const content = (React.createElement(
|
|
177
|
-
React.createElement(
|
|
178
|
-
React.createElement(
|
|
179
|
-
|
|
180
|
-
React.createElement(
|
|
181
|
-
|
|
182
|
-
React.createElement(
|
|
183
|
-
|
|
184
|
-
React.createElement(
|
|
185
|
-
|
|
186
|
-
React.createElement(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
React.createElement(
|
|
178
|
+
const content = (React.createElement(React.Fragment, null,
|
|
179
|
+
React.createElement(CardContent, null,
|
|
180
|
+
React.createElement(Typography, { className: classes.title, variant: "h5" },
|
|
181
|
+
React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.title", defaultMessage: "ui.groupMembersWidget.title" })),
|
|
182
|
+
!state.count ? (React.createElement(Typography, { className: classes.noResults, variant: "body2" },
|
|
183
|
+
React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.subtitle.noResults", defaultMessage: "" }))) : (React.createElement(React.Fragment, null,
|
|
184
|
+
React.createElement(List, null, state.results.slice(0, state.visibleItems).map((user) => (React.createElement(ListItem, { key: user.id },
|
|
185
|
+
React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } }))))),
|
|
186
|
+
state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: handleToggleDialogOpen },
|
|
187
|
+
React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.button.showMore", defaultMessage: "ui.groupMembersWidget.button.showMore" }))))),
|
|
188
|
+
openDialog && (React.createElement(DialogRoot, Object.assign({ className: classes.dialogRoot, title: React.createElement(FormattedMessage, { defaultMessage: "ui.groupMembersWidget.dialogTitle", id: "ui.groupMembersWidget.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: openDialog }, DialogProps),
|
|
189
|
+
React.createElement(InfiniteScroll, { dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: React.createElement(UserSkeleton, Object.assign({ elevation: 0 }, UserProps)), height: isMobile ? '100%' : 400, endMessage: React.createElement(Typography, { className: classes.endMessage },
|
|
190
|
+
React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.noMoreResults", defaultMessage: "ui.groupMembersWidget.noMoreResults" })) },
|
|
191
|
+
React.createElement(List, null, state.results.map((user) => (React.createElement(ListItem, { key: user.id },
|
|
192
|
+
React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } }))))))))),
|
|
193
|
+
React.createElement(CardActions, { className: classes.actions },
|
|
194
|
+
React.createElement(GroupInviteButton, { groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup }))));
|
|
190
195
|
return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest), content));
|
|
191
196
|
}
|