@selfcommunity/react-ui 0.7.6-alpha.1 → 0.7.7-alpha.0

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.
@@ -1,4 +1,5 @@
1
1
  import { BoxProps } from '@mui/material';
2
+ import { SCUserType } from '@selfcommunity/types';
2
3
  export interface AccountDeleteProps extends BoxProps {
3
4
  /**
4
5
  * Callback when logout rejecting policy document
@@ -7,7 +8,7 @@ export interface AccountDeleteProps extends BoxProps {
7
8
  /**
8
9
  * Callback when delete account rejecting policy document
9
10
  */
10
- onDeleteAccount?: () => void;
11
+ onDeleteAccount?: (user?: SCUserType) => void;
11
12
  /**
12
13
  * Any other properties
13
14
  */
@@ -83,7 +83,7 @@ function AccountDelete(inProps) {
83
83
  api_services_1.UserService.userDelete(scUserContext.user.id, 0)
84
84
  .then(() => {
85
85
  setIsDeleting(false);
86
- onDeleteAccount && onDeleteAccount();
86
+ onDeleteAccount && onDeleteAccount(scUserContext.user);
87
87
  handleLogout();
88
88
  })
89
89
  .catch((_error) => {
@@ -110,7 +110,7 @@ function AccountDelete(inProps) {
110
110
  * Renders root object
111
111
  */
112
112
  return (react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest),
113
- react_1.default.createElement(material_1.Typography, { className: classes.message },
113
+ react_1.default.createElement(material_1.Typography, { className: classes.message, component: material_1.Box },
114
114
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.accountDelete.message", defaultMessage: "ui.accountDelete.message", values: {
115
115
  communityName,
116
116
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
@@ -120,7 +120,7 @@ function AccountDelete(inProps) {
120
120
  // @ts-ignore
121
121
  ul: (chunks) => react_1.default.createElement("ul", null, chunks)
122
122
  } })),
123
- react_1.default.createElement(material_1.Typography, { className: classes.confirm },
123
+ react_1.default.createElement(material_1.Typography, { className: classes.confirm, component: material_1.Box },
124
124
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.accountDelete.confirmMessage", defaultMessage: "ui.accountDelete.confirmMessage", values: {
125
125
  username: scUserContext.user.username,
126
126
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
@@ -1,5 +1,10 @@
1
1
  import { ButtonProps } from '@mui/material';
2
+ import { SCUserType } from '@selfcommunity/types';
2
3
  export interface AccountDeleteButtonProps extends Pick<ButtonProps, Exclude<keyof ButtonProps, 'onClick' | 'disabled'>> {
4
+ /**
5
+ * Callback when delete account
6
+ */
7
+ onDeleteAccount?: (user?: SCUserType) => void;
3
8
  /**
4
9
  * Others properties
5
10
  */
@@ -56,7 +56,7 @@ function AccountDeleteButton(inProps) {
56
56
  props: inProps,
57
57
  name: PREFIX
58
58
  });
59
- const { className } = props, rest = tslib_1.__rest(props, ["className"]);
59
+ const { className, onDeleteAccount } = props, rest = tslib_1.__rest(props, ["className", "onDeleteAccount"]);
60
60
  // STATE
61
61
  const [open, setOpen] = (0, react_1.useState)(false);
62
62
  // CONTEXT
@@ -68,6 +68,10 @@ function AccountDeleteButton(inProps) {
68
68
  const handleClose = () => {
69
69
  setOpen(false);
70
70
  };
71
+ const handleDelete = (user) => {
72
+ onDeleteAccount && onDeleteAccount(user);
73
+ handleClose();
74
+ };
71
75
  // RENDER
72
76
  if (!scUserContext.user) {
73
77
  return null;
@@ -76,6 +80,6 @@ function AccountDeleteButton(inProps) {
76
80
  react_1.default.createElement(Root, Object.assign({ onClick: handleOpen, className: (0, classnames_1.default)(classes.root, className) }, rest),
77
81
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.accountDeleteButton.buttonLabel", defaultMessage: "ui.accountDeleteButton.buttonLabel" })),
78
82
  open && (react_1.default.createElement(DialogRoot, { title: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.accountDeleteButton.dialogTitle", defaultMessage: "ui.accountDeleteButton.dialogTitle" }), onClose: handleClose, open: open, DialogContentProps: {} },
79
- react_1.default.createElement(AccountDelete_1.default, { onDeleteAccount: handleClose })))));
83
+ react_1.default.createElement(AccountDelete_1.default, { onDeleteAccount: handleDelete })))));
80
84
  }
81
85
  exports.default = AccountDeleteButton;
@@ -1,4 +1,5 @@
1
1
  import { DialogProps } from '@mui/material';
2
+ import { SCUserType } from '@selfcommunity/types';
2
3
  export interface ConsentSolutionProps extends Pick<DialogProps, Exclude<keyof DialogProps, 'open'>> {
3
4
  /**
4
5
  * Overrides or extends the styles applied to the component.
@@ -21,7 +22,7 @@ export interface ConsentSolutionProps extends Pick<DialogProps, Exclude<keyof Di
21
22
  /**
22
23
  * Callback when delete account rejecting policy document
23
24
  */
24
- onDeleteAccount?: () => void;
25
+ onDeleteAccount?: (user?: SCUserType) => void;
25
26
  /**
26
27
  * Any other properties
27
28
  */
@@ -195,7 +195,7 @@ function ConsentSolution(inProps) {
195
195
  api_services_1.UserService.userDelete(scUserContext.user.id, 0)
196
196
  .then(() => {
197
197
  setLoadingDeleteAccount(false);
198
- onDeleteAccount && onDeleteAccount();
198
+ onDeleteAccount && onDeleteAccount(scUserContext.user);
199
199
  handleLogout();
200
200
  })
201
201
  .catch((_error) => {
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { AccountCredentialProps } from './AccountCredentials';
3
+ import { AccountDeleteButtonProps } from '../../AccountDeleteButton';
3
4
  import { LanguageSwitcherProps } from '../../../shared/LanguageSwitcher';
4
5
  export interface AccountProps {
5
6
  /**
@@ -47,6 +48,11 @@ export interface AccountProps {
47
48
  * @default {}
48
49
  */
49
50
  AccountCredentialProps?: AccountCredentialProps;
51
+ /**
52
+ * Props to apply to Account delete button
53
+ * @default {}
54
+ */
55
+ AccountDeleteButtonProps?: AccountDeleteButtonProps;
50
56
  /**
51
57
  * Any other properties
52
58
  */
@@ -45,7 +45,7 @@ function Account(props) {
45
45
  // CONTEXT
46
46
  const scUserContext = (0, react_core_1.useSCUser)();
47
47
  // PROPS
48
- const { className = null, handleAssociationCreate, showSocialAccountSection = true, showCredentialsSection = false, AccountCredentialProps = {}, showLanguageSwitcher = false, LanguageSwitcherProps = {}, startActions = null, endActions = null } = props, rest = tslib_1.__rest(props, ["className", "handleAssociationCreate", "showSocialAccountSection", "showCredentialsSection", "AccountCredentialProps", "showLanguageSwitcher", "LanguageSwitcherProps", "startActions", "endActions"]);
48
+ const { className = null, handleAssociationCreate, showSocialAccountSection = true, showCredentialsSection = false, AccountCredentialProps = {}, AccountDeleteButtonProps = {}, showLanguageSwitcher = false, LanguageSwitcherProps = {}, startActions = null, endActions = null } = props, rest = tslib_1.__rest(props, ["className", "handleAssociationCreate", "showSocialAccountSection", "showCredentialsSection", "AccountCredentialProps", "AccountDeleteButtonProps", "showLanguageSwitcher", "LanguageSwitcherProps", "startActions", "endActions"]);
49
49
  // STATE
50
50
  const [provider, setProvider] = (0, react_1.useState)(null);
51
51
  const [openDeleteDialog, setOpenDeleteDialog] = (0, react_1.useState)(false);
@@ -82,6 +82,6 @@ function Account(props) {
82
82
  endActions,
83
83
  react_1.default.createElement(material_1.Box, { className: classes.dangerZone },
84
84
  react_1.default.createElement(AccountDataPortabilityButton_1.default, { fullWidth: true, variant: "outlined", color: "primary" }),
85
- react_1.default.createElement(AccountDeleteButton_1.default, { fullWidth: true, variant: "contained", color: "secondary" }))));
85
+ react_1.default.createElement(AccountDeleteButton_1.default, Object.assign({ fullWidth: true, variant: "contained", color: "secondary" }, AccountDeleteButtonProps)))));
86
86
  }
87
87
  exports.default = Account;
@@ -1,4 +1,5 @@
1
1
  import { BoxProps } from '@mui/material';
2
+ import { SCUserType } from '@selfcommunity/types';
2
3
  export interface AccountDeleteProps extends BoxProps {
3
4
  /**
4
5
  * Callback when logout rejecting policy document
@@ -7,7 +8,7 @@ export interface AccountDeleteProps extends BoxProps {
7
8
  /**
8
9
  * Callback when delete account rejecting policy document
9
10
  */
10
- onDeleteAccount?: () => void;
11
+ onDeleteAccount?: (user?: SCUserType) => void;
11
12
  /**
12
13
  * Any other properties
13
14
  */
@@ -81,7 +81,7 @@ export default function AccountDelete(inProps) {
81
81
  UserService.userDelete(scUserContext.user.id, 0)
82
82
  .then(() => {
83
83
  setIsDeleting(false);
84
- onDeleteAccount && onDeleteAccount();
84
+ onDeleteAccount && onDeleteAccount(scUserContext.user);
85
85
  handleLogout();
86
86
  })
87
87
  .catch((_error) => {
@@ -108,7 +108,7 @@ export default function AccountDelete(inProps) {
108
108
  * Renders root object
109
109
  */
110
110
  return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest),
111
- React.createElement(Typography, { className: classes.message },
111
+ React.createElement(Typography, { className: classes.message, component: Box },
112
112
  React.createElement(FormattedMessage, { id: "ui.accountDelete.message", defaultMessage: "ui.accountDelete.message", values: {
113
113
  communityName,
114
114
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
@@ -118,7 +118,7 @@ export default function AccountDelete(inProps) {
118
118
  // @ts-ignore
119
119
  ul: (chunks) => React.createElement("ul", null, chunks)
120
120
  } })),
121
- React.createElement(Typography, { className: classes.confirm },
121
+ React.createElement(Typography, { className: classes.confirm, component: Box },
122
122
  React.createElement(FormattedMessage, { id: "ui.accountDelete.confirmMessage", defaultMessage: "ui.accountDelete.confirmMessage", values: {
123
123
  username: scUserContext.user.username,
124
124
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
@@ -1,5 +1,10 @@
1
1
  import { ButtonProps } from '@mui/material';
2
+ import { SCUserType } from '@selfcommunity/types';
2
3
  export interface AccountDeleteButtonProps extends Pick<ButtonProps, Exclude<keyof ButtonProps, 'onClick' | 'disabled'>> {
4
+ /**
5
+ * Callback when delete account
6
+ */
7
+ onDeleteAccount?: (user?: SCUserType) => void;
3
8
  /**
4
9
  * Others properties
5
10
  */
@@ -54,7 +54,7 @@ export default function AccountDeleteButton(inProps) {
54
54
  props: inProps,
55
55
  name: PREFIX
56
56
  });
57
- const { className } = props, rest = __rest(props, ["className"]);
57
+ const { className, onDeleteAccount } = props, rest = __rest(props, ["className", "onDeleteAccount"]);
58
58
  // STATE
59
59
  const [open, setOpen] = useState(false);
60
60
  // CONTEXT
@@ -66,6 +66,10 @@ export default function AccountDeleteButton(inProps) {
66
66
  const handleClose = () => {
67
67
  setOpen(false);
68
68
  };
69
+ const handleDelete = (user) => {
70
+ onDeleteAccount && onDeleteAccount(user);
71
+ handleClose();
72
+ };
69
73
  // RENDER
70
74
  if (!scUserContext.user) {
71
75
  return null;
@@ -74,5 +78,5 @@ export default function AccountDeleteButton(inProps) {
74
78
  React.createElement(Root, Object.assign({ onClick: handleOpen, className: classNames(classes.root, className) }, rest),
75
79
  React.createElement(FormattedMessage, { id: "ui.accountDeleteButton.buttonLabel", defaultMessage: "ui.accountDeleteButton.buttonLabel" })),
76
80
  open && (React.createElement(DialogRoot, { title: React.createElement(FormattedMessage, { id: "ui.accountDeleteButton.dialogTitle", defaultMessage: "ui.accountDeleteButton.dialogTitle" }), onClose: handleClose, open: open, DialogContentProps: {} },
77
- React.createElement(AccountDelete, { onDeleteAccount: handleClose })))));
81
+ React.createElement(AccountDelete, { onDeleteAccount: handleDelete })))));
78
82
  }
@@ -1,4 +1,5 @@
1
1
  import { DialogProps } from '@mui/material';
2
+ import { SCUserType } from '@selfcommunity/types';
2
3
  export interface ConsentSolutionProps extends Pick<DialogProps, Exclude<keyof DialogProps, 'open'>> {
3
4
  /**
4
5
  * Overrides or extends the styles applied to the component.
@@ -21,7 +22,7 @@ export interface ConsentSolutionProps extends Pick<DialogProps, Exclude<keyof Di
21
22
  /**
22
23
  * Callback when delete account rejecting policy document
23
24
  */
24
- onDeleteAccount?: () => void;
25
+ onDeleteAccount?: (user?: SCUserType) => void;
25
26
  /**
26
27
  * Any other properties
27
28
  */
@@ -192,7 +192,7 @@ export default function ConsentSolution(inProps) {
192
192
  UserService.userDelete(scUserContext.user.id, 0)
193
193
  .then(() => {
194
194
  setLoadingDeleteAccount(false);
195
- onDeleteAccount && onDeleteAccount();
195
+ onDeleteAccount && onDeleteAccount(scUserContext.user);
196
196
  handleLogout();
197
197
  })
198
198
  .catch((_error) => {
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { AccountCredentialProps } from './AccountCredentials';
3
+ import { AccountDeleteButtonProps } from '../../AccountDeleteButton';
3
4
  import { LanguageSwitcherProps } from '../../../shared/LanguageSwitcher';
4
5
  export interface AccountProps {
5
6
  /**
@@ -47,6 +48,11 @@ export interface AccountProps {
47
48
  * @default {}
48
49
  */
49
50
  AccountCredentialProps?: AccountCredentialProps;
51
+ /**
52
+ * Props to apply to Account delete button
53
+ * @default {}
54
+ */
55
+ AccountDeleteButtonProps?: AccountDeleteButtonProps;
50
56
  /**
51
57
  * Any other properties
52
58
  */
@@ -43,7 +43,7 @@ export default function Account(props) {
43
43
  // CONTEXT
44
44
  const scUserContext = useSCUser();
45
45
  // PROPS
46
- const { className = null, handleAssociationCreate, showSocialAccountSection = true, showCredentialsSection = false, AccountCredentialProps = {}, showLanguageSwitcher = false, LanguageSwitcherProps = {}, startActions = null, endActions = null } = props, rest = __rest(props, ["className", "handleAssociationCreate", "showSocialAccountSection", "showCredentialsSection", "AccountCredentialProps", "showLanguageSwitcher", "LanguageSwitcherProps", "startActions", "endActions"]);
46
+ const { className = null, handleAssociationCreate, showSocialAccountSection = true, showCredentialsSection = false, AccountCredentialProps = {}, AccountDeleteButtonProps = {}, showLanguageSwitcher = false, LanguageSwitcherProps = {}, startActions = null, endActions = null } = props, rest = __rest(props, ["className", "handleAssociationCreate", "showSocialAccountSection", "showCredentialsSection", "AccountCredentialProps", "AccountDeleteButtonProps", "showLanguageSwitcher", "LanguageSwitcherProps", "startActions", "endActions"]);
47
47
  // STATE
48
48
  const [provider, setProvider] = useState(null);
49
49
  const [openDeleteDialog, setOpenDeleteDialog] = useState(false);
@@ -80,5 +80,5 @@ export default function Account(props) {
80
80
  endActions,
81
81
  React.createElement(Box, { className: classes.dangerZone },
82
82
  React.createElement(AccountDataPortabilityButton, { fullWidth: true, variant: "outlined", color: "primary" }),
83
- React.createElement(AccountDeleteButton, { fullWidth: true, variant: "contained", color: "secondary" }))));
83
+ React.createElement(AccountDeleteButton, Object.assign({ fullWidth: true, variant: "contained", color: "secondary" }, AccountDeleteButtonProps)))));
84
84
  }