@selfcommunity/react-ui 0.10.5-payments.149 → 0.10.5-payments.151

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.
Files changed (172) hide show
  1. package/lib/cjs/components/BuyButton/BuyButton.js +2 -2
  2. package/lib/cjs/components/CategoryFollowButton/CategoryFollowButton.d.ts +4 -0
  3. package/lib/cjs/components/CategoryFollowButton/CategoryFollowButton.js +20 -4
  4. package/lib/cjs/components/CategoryHeader/CategoryHeader.js +5 -1
  5. package/lib/cjs/components/Checkout/Checkout.d.ts +7 -1
  6. package/lib/cjs/components/Checkout/Checkout.js +6 -10
  7. package/lib/cjs/components/CheckoutReturnDialog/CheckoutReturnDialog.d.ts +1 -0
  8. package/lib/cjs/components/CheckoutReturnDialog/CheckoutReturnDialog.js +33 -5
  9. package/lib/cjs/components/CommentObjectReply/CommentObjectReply.js +11 -5
  10. package/lib/cjs/components/CommunityPaywall/CommunityPaywall.d.ts +8 -0
  11. package/lib/cjs/components/CommunityPaywall/CommunityPaywall.js +70 -0
  12. package/lib/cjs/components/CommunityPaywall/Skeleton.d.ts +27 -0
  13. package/lib/cjs/components/CommunityPaywall/Skeleton.js +54 -0
  14. package/lib/cjs/components/CommunityPaywall/constants.d.ts +1 -0
  15. package/lib/cjs/components/CommunityPaywall/constants.js +4 -0
  16. package/lib/cjs/components/CommunityPaywall/index.d.ts +3 -0
  17. package/lib/cjs/components/CommunityPaywall/index.js +5 -0
  18. package/lib/cjs/components/Composer/Content/ContentLesson/ContentLesson.js +35 -4
  19. package/lib/cjs/components/Course/Course.js +10 -11
  20. package/lib/cjs/components/Course/Skeleton.js +1 -1
  21. package/lib/cjs/components/CourseDashboard/Student.d.ts +2 -2
  22. package/lib/cjs/components/CourseDashboard/Student.js +43 -9
  23. package/lib/cjs/components/CourseDashboard/Teacher/Comments.js +2 -2
  24. package/lib/cjs/components/CourseForm/CourseForm.js +2 -1
  25. package/lib/cjs/components/CourseJoinButton/CourseJoinButton.js +1 -1
  26. package/lib/cjs/components/CourseParticipantsButton/CourseParticipantsButton.js +1 -1
  27. package/lib/cjs/components/EditCourse/Customize.d.ts +1 -1
  28. package/lib/cjs/components/EditCourse/Customize.js +3 -3
  29. package/lib/cjs/components/EditCourse/EditCourse.js +4 -4
  30. package/lib/cjs/components/EditCourse/Lessons/FieldName.d.ts +1 -1
  31. package/lib/cjs/components/EditCourse/Lessons/FieldName.js +1 -1
  32. package/lib/cjs/components/EditCourse/Lessons/LessonRow.d.ts +1 -1
  33. package/lib/cjs/components/EditCourse/Lessons/SectionRow.d.ts +1 -1
  34. package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +4 -3
  35. package/lib/cjs/components/EditCourse/Lessons.d.ts +1 -1
  36. package/lib/cjs/components/EditCourse/Lessons.js +36 -20
  37. package/lib/cjs/components/EditCourse/Options.d.ts +1 -1
  38. package/lib/cjs/components/EditCourse/Options.js +2 -2
  39. package/lib/cjs/components/EditCourse/Status.js +2 -2
  40. package/lib/cjs/components/Editor/Editor.d.ts +13 -1
  41. package/lib/cjs/components/Editor/Editor.js +3 -4
  42. package/lib/cjs/components/Editor/nodes/index.d.ts +1 -2
  43. package/lib/cjs/components/Editor/nodes/index.js +1 -3
  44. package/lib/cjs/components/Editor/plugins/MediaPlugin.d.ts +2 -1
  45. package/lib/cjs/components/Editor/plugins/MediaPlugin.js +5 -27
  46. package/lib/cjs/components/Editor/plugins/ToolbarPlugin.d.ts +2 -0
  47. package/lib/cjs/components/Editor/plugins/ToolbarPlugin.js +2 -2
  48. package/lib/cjs/components/EventHeader/EventHeader.js +4 -7
  49. package/lib/cjs/components/GroupHeader/GroupHeader.js +2 -1
  50. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  51. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  52. package/lib/cjs/components/LessonCommentObject/LessonCommentObject.d.ts +1 -0
  53. package/lib/cjs/components/LessonCommentObject/LessonCommentObject.js +8 -2
  54. package/lib/cjs/components/LessonCommentObjects/LessonCommentObjects.js +5 -1
  55. package/lib/cjs/components/LessonObject/LessonObject.js +9 -37
  56. package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -2
  57. package/lib/cjs/components/PaymentOrders/PaymentOrders.js +8 -1
  58. package/lib/cjs/components/PaymentProduct/PaymentProduct.d.ts +7 -4
  59. package/lib/cjs/components/PaymentProduct/PaymentProduct.js +8 -6
  60. package/lib/cjs/components/PaymentProduct/Skeleton.d.ts +6 -1
  61. package/lib/cjs/components/PaymentProduct/Skeleton.js +10 -3
  62. package/lib/cjs/components/PaymentProductPrice/PaymentProductPrice.js +1 -1
  63. package/lib/cjs/components/PaymentProductPrice/Skeleton.js +2 -2
  64. package/lib/cjs/components/PaymentProducts/PaymentProducts.js +1 -1
  65. package/lib/cjs/components/UserPaymentMethods/Skeleton.d.ts +22 -0
  66. package/lib/cjs/components/UserPaymentMethods/Skeleton.js +38 -0
  67. package/lib/cjs/components/UserPaymentMethods/UserPaymentMethods.d.ts +39 -0
  68. package/lib/cjs/components/UserPaymentMethods/UserPaymentMethods.js +104 -0
  69. package/lib/cjs/components/UserPaymentMethods/constants.d.ts +1 -0
  70. package/lib/cjs/components/UserPaymentMethods/constants.js +4 -0
  71. package/lib/cjs/components/UserPaymentMethods/index.d.ts +4 -0
  72. package/lib/cjs/components/UserPaymentMethods/index.js +8 -0
  73. package/lib/cjs/index.d.ts +3 -1
  74. package/lib/cjs/index.js +7 -2
  75. package/lib/cjs/shared/AccordionLessons/AccordionLessons.js +5 -4
  76. package/lib/cjs/shared/HiddenPurchasableContent/HiddenPurchasableContent.d.ts +44 -0
  77. package/lib/cjs/shared/HiddenPurchasableContent/HiddenPurchasableContent.js +53 -0
  78. package/lib/cjs/shared/HiddenPurchasableContent/index.d.ts +3 -0
  79. package/lib/cjs/shared/HiddenPurchasableContent/index.js +5 -0
  80. package/lib/cjs/shared/LessonFilePreview/index.d.ts +12 -0
  81. package/lib/cjs/shared/LessonFilePreview/index.js +29 -0
  82. package/lib/cjs/shared/Media/Link/UrlTextField/index.js +2 -3
  83. package/lib/cjs/utils/course.d.ts +1 -1
  84. package/lib/esm/components/BuyButton/BuyButton.js +3 -3
  85. package/lib/esm/components/CategoryFollowButton/CategoryFollowButton.d.ts +4 -0
  86. package/lib/esm/components/CategoryFollowButton/CategoryFollowButton.js +22 -6
  87. package/lib/esm/components/CategoryHeader/CategoryHeader.js +6 -2
  88. package/lib/esm/components/Checkout/Checkout.d.ts +7 -1
  89. package/lib/esm/components/Checkout/Checkout.js +6 -10
  90. package/lib/esm/components/CheckoutReturnDialog/CheckoutReturnDialog.d.ts +1 -0
  91. package/lib/esm/components/CheckoutReturnDialog/CheckoutReturnDialog.js +34 -6
  92. package/lib/esm/components/CommentObjectReply/CommentObjectReply.js +11 -5
  93. package/lib/esm/components/CommunityPaywall/CommunityPaywall.d.ts +8 -0
  94. package/lib/esm/components/CommunityPaywall/CommunityPaywall.js +67 -0
  95. package/lib/esm/components/CommunityPaywall/Skeleton.d.ts +27 -0
  96. package/lib/esm/components/CommunityPaywall/Skeleton.js +51 -0
  97. package/lib/esm/components/CommunityPaywall/constants.d.ts +1 -0
  98. package/lib/esm/components/CommunityPaywall/constants.js +1 -0
  99. package/lib/esm/components/CommunityPaywall/index.d.ts +3 -0
  100. package/lib/esm/components/CommunityPaywall/index.js +2 -0
  101. package/lib/esm/components/Composer/Content/ContentLesson/ContentLesson.js +37 -6
  102. package/lib/esm/components/Course/Course.js +10 -11
  103. package/lib/esm/components/Course/Skeleton.js +1 -1
  104. package/lib/esm/components/CourseDashboard/Student.d.ts +2 -2
  105. package/lib/esm/components/CourseDashboard/Student.js +46 -12
  106. package/lib/esm/components/CourseDashboard/Teacher/Comments.js +3 -3
  107. package/lib/esm/components/CourseForm/CourseForm.js +2 -1
  108. package/lib/esm/components/CourseJoinButton/CourseJoinButton.js +1 -1
  109. package/lib/esm/components/CourseParticipantsButton/CourseParticipantsButton.js +1 -1
  110. package/lib/esm/components/EditCourse/Customize.d.ts +1 -1
  111. package/lib/esm/components/EditCourse/Customize.js +3 -3
  112. package/lib/esm/components/EditCourse/EditCourse.js +4 -4
  113. package/lib/esm/components/EditCourse/Lessons/FieldName.d.ts +1 -1
  114. package/lib/esm/components/EditCourse/Lessons/FieldName.js +1 -1
  115. package/lib/esm/components/EditCourse/Lessons/LessonRow.d.ts +1 -1
  116. package/lib/esm/components/EditCourse/Lessons/SectionRow.d.ts +1 -1
  117. package/lib/esm/components/EditCourse/Lessons/SectionRow.js +4 -3
  118. package/lib/esm/components/EditCourse/Lessons.d.ts +1 -1
  119. package/lib/esm/components/EditCourse/Lessons.js +36 -20
  120. package/lib/esm/components/EditCourse/Options.d.ts +1 -1
  121. package/lib/esm/components/EditCourse/Options.js +2 -2
  122. package/lib/esm/components/EditCourse/Status.js +2 -2
  123. package/lib/esm/components/Editor/Editor.d.ts +13 -1
  124. package/lib/esm/components/Editor/Editor.js +3 -4
  125. package/lib/esm/components/Editor/nodes/index.d.ts +1 -2
  126. package/lib/esm/components/Editor/nodes/index.js +1 -3
  127. package/lib/esm/components/Editor/plugins/MediaPlugin.d.ts +2 -1
  128. package/lib/esm/components/Editor/plugins/MediaPlugin.js +5 -27
  129. package/lib/esm/components/Editor/plugins/ToolbarPlugin.d.ts +2 -0
  130. package/lib/esm/components/Editor/plugins/ToolbarPlugin.js +2 -2
  131. package/lib/esm/components/EventHeader/EventHeader.js +6 -9
  132. package/lib/esm/components/GroupHeader/GroupHeader.js +2 -1
  133. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  134. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  135. package/lib/esm/components/LessonCommentObject/LessonCommentObject.d.ts +1 -0
  136. package/lib/esm/components/LessonCommentObject/LessonCommentObject.js +8 -2
  137. package/lib/esm/components/LessonCommentObjects/LessonCommentObjects.js +5 -1
  138. package/lib/esm/components/LessonObject/LessonObject.js +13 -41
  139. package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -2
  140. package/lib/esm/components/PaymentOrders/PaymentOrders.js +8 -1
  141. package/lib/esm/components/PaymentProduct/PaymentProduct.d.ts +7 -4
  142. package/lib/esm/components/PaymentProduct/PaymentProduct.js +9 -7
  143. package/lib/esm/components/PaymentProduct/Skeleton.d.ts +6 -1
  144. package/lib/esm/components/PaymentProduct/Skeleton.js +11 -3
  145. package/lib/esm/components/PaymentProductPrice/PaymentProductPrice.js +1 -1
  146. package/lib/esm/components/PaymentProductPrice/Skeleton.js +2 -2
  147. package/lib/esm/components/PaymentProducts/PaymentProducts.js +1 -1
  148. package/lib/esm/components/UserPaymentMethods/Skeleton.d.ts +22 -0
  149. package/lib/esm/components/UserPaymentMethods/Skeleton.js +36 -0
  150. package/lib/esm/components/UserPaymentMethods/UserPaymentMethods.d.ts +39 -0
  151. package/lib/esm/components/UserPaymentMethods/UserPaymentMethods.js +101 -0
  152. package/lib/esm/components/UserPaymentMethods/constants.d.ts +1 -0
  153. package/lib/esm/components/UserPaymentMethods/constants.js +1 -0
  154. package/lib/esm/components/UserPaymentMethods/index.d.ts +4 -0
  155. package/lib/esm/components/UserPaymentMethods/index.js +4 -0
  156. package/lib/esm/index.d.ts +3 -1
  157. package/lib/esm/index.js +3 -1
  158. package/lib/esm/shared/AccordionLessons/AccordionLessons.js +6 -5
  159. package/lib/esm/shared/HiddenPurchasableContent/HiddenPurchasableContent.d.ts +44 -0
  160. package/lib/esm/shared/HiddenPurchasableContent/HiddenPurchasableContent.js +50 -0
  161. package/lib/esm/shared/HiddenPurchasableContent/index.d.ts +3 -0
  162. package/lib/esm/shared/HiddenPurchasableContent/index.js +2 -0
  163. package/lib/esm/shared/LessonFilePreview/index.d.ts +12 -0
  164. package/lib/esm/shared/LessonFilePreview/index.js +25 -0
  165. package/lib/esm/shared/Media/Link/UrlTextField/index.js +3 -4
  166. package/lib/esm/utils/course.d.ts +1 -1
  167. package/lib/umd/react-ui.js +1 -1
  168. package/package.json +8 -8
  169. package/lib/cjs/components/Editor/nodes/DocNode.d.ts +0 -39
  170. package/lib/cjs/components/Editor/nodes/DocNode.js +0 -181
  171. package/lib/esm/components/Editor/nodes/DocNode.d.ts +0 -39
  172. package/lib/esm/components/Editor/nodes/DocNode.js +0 -175
@@ -62,7 +62,7 @@ function BuyButton(inProps) {
62
62
  props: inProps,
63
63
  name: PREFIX
64
64
  });
65
- const { className, contentId, contentType, content, onPurchase } = props, rest = tslib_1.__rest(props, ["className", "contentId", "contentType", "content", "onPurchase"]);
65
+ const { className, contentId, contentType, content, disabled, onPurchase } = props, rest = tslib_1.__rest(props, ["className", "contentId", "contentType", "content", "disabled", "onPurchase"]);
66
66
  // STATE
67
67
  const [open, setOpen] = (0, react_1.useState)(false);
68
68
  // CONTEXT
@@ -172,6 +172,6 @@ function BuyButton(inProps) {
172
172
  if (!contentId && !content) {
173
173
  return null;
174
174
  }
175
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(RequestRoot, Object.assign({ className: (0, classnames_1.default)(classes.requestRoot, className), variant: "contained", color: purchased ? 'inherit' : 'secondary', size: "small", startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "card_giftcard" }), loading: scUserContext.user === undefined || purchased === null, onClick: handleOpen }, rest, { children: btnLabel })), open && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: true, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", component: "div", marginBottom: 2 }, { children: (0, jsx_runtime_1.jsx)("b", { children: paymentOrder ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentProductsDialog.title.purchased", defaultMessage: "ui.paymentProductsDialog.title.purchased" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentProductsDialog.title", defaultMessage: "ui.paymentProductsDialog.title" })) }) })), (0, jsx_runtime_1.jsx)(PaymentProducts_1.default, Object.assign({ contentType: contentType }, (content ? { content } : { contentId }), (paymentOrder && { paymentOrder: paymentOrder, onUpdatePaymentOrder: handleUpdatePaymentOrder })))] }) }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(PaymentProductsDialog_1.default, { open: true, onClose: handleClose, PaymentProductsComponentProps: Object.assign(Object.assign({ contentType }, (content ? { content } : { contentId })), (paymentOrder && { paymentOrder: paymentOrder, onUpdatePaymentOrder: handleUpdatePaymentOrder })) }) })) }))] }));
175
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: disabled == true ? '' : (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.buyButton.disabled", defaultMessage: "ui.buyButton.disabled" }) }, { children: (0, jsx_runtime_1.jsx)(RequestRoot, Object.assign({ className: (0, classnames_1.default)(classes.requestRoot, className), variant: "contained", color: purchased ? 'inherit' : 'secondary', size: "small", startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "card_giftcard" }), loading: scUserContext.user === undefined || purchased === null, onClick: handleOpen }, rest, { children: btnLabel })) })), open && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: true, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", component: "div", marginBottom: 2 }, { children: (0, jsx_runtime_1.jsx)("b", { children: paymentOrder ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentProductsDialog.title.purchased", defaultMessage: "ui.paymentProductsDialog.title.purchased" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentProductsDialog.title", defaultMessage: "ui.paymentProductsDialog.title" })) }) })), (0, jsx_runtime_1.jsx)(PaymentProducts_1.default, Object.assign({ contentType: contentType }, (content ? { content } : { contentId }), (paymentOrder && { paymentOrder: paymentOrder, onUpdatePaymentOrder: handleUpdatePaymentOrder })))] }) }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(PaymentProductsDialog_1.default, { open: true, onClose: handleClose, PaymentProductsComponentProps: Object.assign(Object.assign({ contentType }, (content ? { content } : { contentId })), (paymentOrder && { paymentOrder: paymentOrder, onUpdatePaymentOrder: handleUpdatePaymentOrder })) }) })) }))] }));
176
176
  }
177
177
  exports.default = BuyButton;
@@ -21,6 +21,10 @@ export interface CategoryFollowButtonProps {
21
21
  * @param followed
22
22
  */
23
23
  onFollow?: (category: SCCategoryType, followed: boolean) => any;
24
+ /**
25
+ * Disable action if feature payments is enabled and the content is paid item
26
+ */
27
+ disableBuyContentIfPaidContent?: boolean;
24
28
  /**
25
29
  * Others properties
26
30
  */
@@ -6,12 +6,13 @@ const react_1 = require("react");
6
6
  const styles_1 = require("@mui/material/styles");
7
7
  const utils_1 = require("@selfcommunity/utils");
8
8
  const react_core_1 = require("@selfcommunity/react-core");
9
+ const types_1 = require("@selfcommunity/types");
9
10
  const Errors_1 = require("../../constants/Errors");
10
11
  const lab_1 = require("@mui/lab");
11
12
  const react_intl_1 = require("react-intl");
12
13
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
13
14
  const system_1 = require("@mui/system");
14
- const types_1 = require("@selfcommunity/types");
15
+ const BuyButton_1 = tslib_1.__importDefault(require("../BuyButton"));
15
16
  const PREFIX = 'SCCategoryFollowButton';
16
17
  const classes = {
17
18
  root: `${PREFIX}-root`
@@ -44,24 +45,33 @@ const FollowButton = (0, styles_1.styled)(lab_1.LoadingButton, {
44
45
  * @param inProps
45
46
  */
46
47
  function CategoryFollowButton(inProps) {
48
+ var _a;
47
49
  // PROPS
48
50
  const props = (0, system_1.useThemeProps)({
49
51
  props: inProps,
50
52
  name: PREFIX
51
53
  });
52
- const { className, categoryId, category, onFollow } = props, rest = tslib_1.__rest(props, ["className", "categoryId", "category", "onFollow"]);
54
+ const { className, categoryId, category, onFollow, disableBuyContentIfPaidContent, disabled } = props, rest = tslib_1.__rest(props, ["className", "categoryId", "category", "onFollow", "disableBuyContentIfPaidContent", "disabled"]);
53
55
  // CONTEXT
54
56
  const scContext = (0, react_core_1.useSCContext)();
55
57
  const scUserContext = (0, react_core_1.useSCUser)();
56
58
  const scCategoriesManager = scUserContext.managers.categories;
57
59
  // CONST
58
60
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
59
- const { scCategory, setSCCategory } = (0, react_core_1.useSCFetchCategory)({
61
+ // PAYMENTS
62
+ const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
63
+ const { scCategory } = (0, react_core_1.useSCFetchCategory)({
60
64
  id: categoryId,
61
65
  category,
62
66
  cacheStrategy: authUserId ? utils_1.CacheStrategies.CACHE_FIRST : utils_1.CacheStrategies.STALE_WHILE_REVALIDATE
63
67
  });
64
68
  const [followed, setFollowed] = (0, react_1.useState)(null);
69
+ /**
70
+ * Check the button if is disabled
71
+ * Disable action follow/unfollow only if payments feature is active
72
+ * and the category is a paid content and the category isn't paid
73
+ */
74
+ const isActionFollowDisabled = (0, react_1.useMemo)(() => { var _a; return disabled || (scCategory && scUserContext.user && isPaymentsEnabled && ((_a = scCategory.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0 && !scCategory.payment_order); }, [disabled, scCategory, scUserContext.user, isPaymentsEnabled]);
65
75
  (0, react_1.useEffect)(() => {
66
76
  /**
67
77
  * Call scCategoriesManager.isFollowed inside an effect
@@ -92,6 +102,12 @@ function CategoryFollowButton(inProps) {
92
102
  if (!scCategory || (scCategory && followed && scCategory.auto_follow === types_1.SCCategoryAutoFollowType.FORCED)) {
93
103
  return null;
94
104
  }
95
- return ((0, jsx_runtime_1.jsx)(FollowButton, Object.assign({ size: "small", variant: "outlined", onClick: handleFollowAction, loading: scUserContext.user ? followed === null || scCategoriesManager.isLoading(scCategory) : null, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: followed && scUserContext.user ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.categoryFollowButton.unfollow", id: "ui.categoryFollowButton.unfollow" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.categoryFollowButton.follow", id: "ui.categoryFollowButton.follow" })) })));
105
+ /**
106
+ * if the category is a paid content and it isn't followed show the Buy button
107
+ */
108
+ if (scCategory && scUserContext.user && isPaymentsEnabled && ((_a = scCategory.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0 && !followed) {
109
+ return (0, jsx_runtime_1.jsx)(BuyButton_1.default, { contentType: types_1.SCContentType.CATEGORY, content: scCategory, disabled: disableBuyContentIfPaidContent });
110
+ }
111
+ return ((0, jsx_runtime_1.jsx)(FollowButton, Object.assign({ size: "small", variant: "outlined", onClick: handleFollowAction, loading: scUserContext.user ? followed === null || scCategoriesManager.isLoading(scCategory) : null, className: (0, classnames_1.default)(classes.root, className), disabled: isActionFollowDisabled }, rest, { children: followed && scUserContext.user ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.categoryFollowButton.unfollow", id: "ui.categoryFollowButton.unfollow" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.categoryFollowButton.follow", id: "ui.categoryFollowButton.follow" })) })));
96
112
  }
97
113
  exports.default = CategoryFollowButton;
@@ -8,10 +8,12 @@ const material_1 = require("@mui/material");
8
8
  const CategoryFollowButton_1 = tslib_1.__importDefault(require("../CategoryFollowButton"));
9
9
  const react_intl_1 = require("react-intl");
10
10
  const react_core_1 = require("@selfcommunity/react-core");
11
+ const types_1 = require("@selfcommunity/types");
11
12
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
12
13
  const system_1 = require("@mui/system");
13
14
  const CategoryFollowersButton_1 = tslib_1.__importDefault(require("../CategoryFollowersButton"));
14
15
  const constants_1 = require("./constants");
16
+ const BuyButton_1 = tslib_1.__importDefault(require("../BuyButton"));
15
17
  const classes = {
16
18
  root: `${constants_1.PREFIX}-root`,
17
19
  cover: `${constants_1.PREFIX}-cover`,
@@ -65,6 +67,8 @@ function CategoryHeader(inProps) {
65
67
  const { className, categoryId, category, CategoryFollowButtonProps = {}, CategoryFollowersButtonProps = {} } = props, rest = tslib_1.__rest(props, ["className", "categoryId", "category", "CategoryFollowButtonProps", "CategoryFollowersButtonProps"]);
66
68
  // STATE
67
69
  const { scCategory, setSCCategory } = (0, react_core_1.useSCFetchCategory)({ id: categoryId, category });
70
+ // PAYMENTS
71
+ const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
68
72
  /**
69
73
  * Handles callback follow/unfollow category
70
74
  */
@@ -76,6 +80,6 @@ function CategoryHeader(inProps) {
76
80
  if (!scCategory) {
77
81
  return null;
78
82
  }
79
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, { style: _backgroundCover, classes: { root: classes.cover } }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.info }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.name, gutterBottom: true }, { children: scCategory.name })), scCategory.slogan && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.slogan }, { children: scCategory.slogan }))), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.followed }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.followedCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryHeader.followedBy", defaultMessage: "ui.categoryHeader.followedBy", values: { total: scCategory.followers_counter } }) })), (0, jsx_runtime_1.jsx)(CategoryFollowersButton_1.default, Object.assign({ category: scCategory, categoryId: scCategory === null || scCategory === void 0 ? void 0 : scCategory.id }, CategoryFollowersButtonProps))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.action }, { children: (0, jsx_runtime_1.jsx)(CategoryFollowButton_1.default, Object.assign({ category: scCategory, onFollow: handleFollow }, CategoryFollowButtonProps)) }))] }))] })));
83
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, { style: _backgroundCover, classes: { root: classes.cover } }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.info }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.name, gutterBottom: true }, { children: scCategory.name })), scCategory.slogan && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.slogan }, { children: scCategory.slogan }))), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.followed }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.followedCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryHeader.followedBy", defaultMessage: "ui.categoryHeader.followedBy", values: { total: scCategory.followers_counter } }) })), (0, jsx_runtime_1.jsx)(CategoryFollowersButton_1.default, Object.assign({ category: scCategory, categoryId: scCategory === null || scCategory === void 0 ? void 0 : scCategory.id }, CategoryFollowersButtonProps))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.action }, { children: [isPaymentsEnabled && scCategory.paywalls.length > 0 && scCategory.payment_order && ((0, jsx_runtime_1.jsx)(BuyButton_1.default, { contentType: types_1.SCContentType.CATEGORY, content: scCategory })), (0, jsx_runtime_1.jsx)(CategoryFollowButton_1.default, Object.assign({ category: scCategory, onFollow: handleFollow }, CategoryFollowButtonProps))] }))] }))] })));
80
84
  }
81
85
  exports.default = CategoryHeader;
@@ -1,4 +1,5 @@
1
- import { SCContentType, SCPurchasableContent } from '@selfcommunity/types';
1
+ import { SCCheckoutSessionUIMode, SCContentType, SCPurchasableContent } from '@selfcommunity/types';
2
+ import * as stripeJs from '@stripe/stripe-js';
2
3
  export interface CheckoutProps {
3
4
  className?: string;
4
5
  clientSecret?: string;
@@ -6,5 +7,10 @@ export interface CheckoutProps {
6
7
  contentId?: number;
7
8
  content?: SCPurchasableContent;
8
9
  priceId?: number;
10
+ returnUrl?: string;
11
+ successUrl?: string;
12
+ uiMode?: SCCheckoutSessionUIMode;
13
+ onComplete?: () => void;
14
+ onShippingDetailsChange?: (event: stripeJs.StripeEmbeddedCheckoutShippingDetailsChangeEvent) => Promise<stripeJs.ResultAction>;
9
15
  }
10
16
  export default function Checkout(inProps: CheckoutProps): JSX.Element;
@@ -41,7 +41,7 @@ function Checkout(inProps) {
41
41
  props: inProps,
42
42
  name: constants_1.PREFIX
43
43
  });
44
- const { className, contentType, contentId, content, priceId } = props, rest = tslib_1.__rest(props, ["className", "contentType", "contentId", "content", "priceId"]);
44
+ const { className, contentType, contentId, content, priceId, returnUrl, successUrl, uiMode, onComplete, onShippingDetailsChange } = props, rest = tslib_1.__rest(props, ["className", "contentType", "contentId", "content", "priceId", "returnUrl", "successUrl", "uiMode", "onComplete", "onShippingDetailsChange"]);
45
45
  const [loading, setLoading] = (0, react_1.useState)(false);
46
46
  const [initialized, setInitialized] = (0, react_1.useState)(false);
47
47
  // CONTEXT
@@ -58,16 +58,10 @@ function Checkout(inProps) {
58
58
  const fetchClientSecret = (0, react_1.useCallback)(() => {
59
59
  // Create a Checkout Session
60
60
  if (!loading) {
61
- console.log('fetching client secret...');
62
61
  setInitialized(true);
63
62
  setLoading(true);
64
- api_services_1.PaymentApiClient.checkoutCreateSession({
65
- content_type: contentType,
66
- content_id: content ? content.id : contentId,
67
- payment_price_id: priceId
68
- })
63
+ api_services_1.PaymentApiClient.checkoutCreateSession(Object.assign(Object.assign(Object.assign({ content_type: contentType, content_id: content ? content.id : contentId, payment_price_id: priceId }, (returnUrl && { return_url: returnUrl })), (successUrl && { success_url: successUrl })), (uiMode && { ui_mode: uiMode })))
69
64
  .then((r) => {
70
- console.log(r);
71
65
  setClientSecret(r.client_secret);
72
66
  setLoading(false);
73
67
  })
@@ -86,6 +80,8 @@ function Checkout(inProps) {
86
80
  };
87
81
  }
88
82
  }, [scUserContext.user, clientSecret, stripePromise, contentType, contentId, content, priceId, loading, initialized]);
83
+ // Payment provider options
84
+ const providerOptions = (0, react_1.useMemo)(() => (Object.assign(Object.assign({ clientSecret }, (onComplete && { onComplete })), (onShippingDetailsChange && { onShippingDetailsChange }))), [clientSecret, onComplete, onShippingDetailsChange]);
89
85
  if (!isPaymentsEnabled) {
90
86
  return null;
91
87
  }
@@ -104,7 +100,7 @@ function Checkout(inProps) {
104
100
  _c = (0, jsx_runtime_1.jsx)(Category_1.default, { categoryId: contentId, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), variant: "outlined", className: classes.object });
105
101
  break;
106
102
  case types_1.SCContentType.COURSE:
107
- return ((0, jsx_runtime_1.jsx)(Course_1.default, { courseId: contentId, template: course_1.SCCourseTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }));
103
+ _c = ((0, jsx_runtime_1.jsx)(Course_1.default, { courseId: contentId, template: course_1.SCCourseTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }));
108
104
  break;
109
105
  case types_1.SCContentType.GROUP:
110
106
  _c = (0, jsx_runtime_1.jsx)(Group_1.default, { courseId: contentId, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object });
@@ -113,6 +109,6 @@ function Checkout(inProps) {
113
109
  }
114
110
  return _c;
115
111
  };
116
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [isContentObject && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: renderContentObject() })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.contentDesc }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", mb: 1 }, { children: (0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkout.contentDesc.title", defaultMessage: "ui.checkout.contentDesc.title" }) }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", color: "textSecondary" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkout.contentDesc.subTitle", defaultMessage: "ui.checkout.contentDesc.subTitle" }) }))] }))] }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ id: "checkout", className: classes.checkout }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckoutProvider, Object.assign({ stripe: stripePromise, options: { clientSecret } }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckout, {}) })) }))] })));
112
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [isContentObject && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: renderContentObject() })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.contentDesc }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", mb: 1 }, { children: (0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkout.contentDesc.title", defaultMessage: "ui.checkout.contentDesc.title" }) }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", color: "textSecondary" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkout.contentDesc.subTitle", defaultMessage: "ui.checkout.contentDesc.subTitle" }) }))] }))] }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ id: "checkout", className: classes.checkout }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckoutProvider, Object.assign({ stripe: stripePromise, options: providerOptions }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckout, {}) })) }))] })));
117
113
  }
118
114
  exports.default = Checkout;
@@ -3,5 +3,6 @@ export interface CheckoutReturnDialogProps extends DialogProps {
3
3
  className?: string;
4
4
  checkoutSessionId: string;
5
5
  disableInitialTransition?: boolean;
6
+ onHandleViewContentPurchased?: (redirectUrl: string) => void;
6
7
  }
7
8
  export default function CheckoutReturnDialog(inProps: CheckoutReturnDialogProps): JSX.Element;
@@ -46,7 +46,7 @@ function CheckoutReturnDialog(inProps) {
46
46
  props: inProps,
47
47
  name: PREFIX
48
48
  });
49
- const { className, checkoutSessionId, disableInitialTransition = false } = props, rest = tslib_1.__rest(props, ["className", "checkoutSessionId", "disableInitialTransition"]);
49
+ const { className, checkoutSessionId, disableInitialTransition = false, onHandleViewContentPurchased } = props, rest = tslib_1.__rest(props, ["className", "checkoutSessionId", "disableInitialTransition", "onHandleViewContentPurchased"]);
50
50
  const [loading, setLoading] = (0, react_1.useState)(true);
51
51
  const [contentType, setContentType] = (0, react_1.useState)(null);
52
52
  const [contentId, setContentId] = (0, react_1.useState)(null);
@@ -56,6 +56,34 @@ function CheckoutReturnDialog(inProps) {
56
56
  const intl = (0, react_intl_1.useIntl)();
57
57
  // CONTEXT
58
58
  const scRoutingContext = (0, react_core_2.useSCRouting)();
59
+ /**
60
+ * Handle view new object purchased
61
+ */
62
+ const handleViewPurchasedObject = (0, react_1.useCallback)(() => {
63
+ let _redirectUrl;
64
+ switch (contentType) {
65
+ case types_1.SCContentType.GROUP:
66
+ _redirectUrl = scRoutingContext.url(react_core_2.SCRoutes.GROUP_ROUTE_NAME, content);
67
+ break;
68
+ case types_1.SCContentType.EVENT:
69
+ _redirectUrl = scRoutingContext.url(react_core_2.SCRoutes.EVENT_ROUTE_NAME, content);
70
+ break;
71
+ case types_1.SCContentType.CATEGORY:
72
+ _redirectUrl = scRoutingContext.url(react_core_2.SCRoutes.CATEGORY_ROUTE_NAME, content);
73
+ break;
74
+ case types_1.SCContentType.COURSE:
75
+ _redirectUrl = scRoutingContext.url(react_core_2.SCRoutes.COURSE_ROUTE_NAME, content);
76
+ break;
77
+ default:
78
+ break;
79
+ }
80
+ if (onHandleViewContentPurchased) {
81
+ onHandleViewContentPurchased(_redirectUrl);
82
+ }
83
+ else if (_redirectUrl) {
84
+ window.location.href = _redirectUrl;
85
+ }
86
+ }, [scRoutingContext, onHandleViewContentPurchased, content, contentType]);
59
87
  (0, react_1.useEffect)(() => {
60
88
  api_services_1.PaymentApiClient.getCheckoutSession({ session_id: checkoutSessionId })
61
89
  .then((r) => {
@@ -81,16 +109,16 @@ function CheckoutReturnDialog(inProps) {
81
109
  const renderContent = () => {
82
110
  let footer;
83
111
  if (contentType === types_1.SCContentType.EVENT) {
84
- footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Event_1.default, { event: content, template: event_1.SCEventTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.EVENT_ROUTE_NAME, content), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.event.button", defaultMessage: "ui.checkoutReturnDialog.event.button" }) }))] }));
112
+ footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Event_1.default, { event: content, template: event_1.SCEventTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', onClick: handleViewPurchasedObject, component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.event.button", defaultMessage: "ui.checkoutReturnDialog.event.button" }) }))] }));
85
113
  }
86
114
  else if (contentType === types_1.SCContentType.CATEGORY) {
87
- footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Category_1.default, { category: content, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.CATEGORY_ROUTE_NAME, content), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.category.button", defaultMessage: "ui.checkoutReturnDialog.category.button" }) }))] }));
115
+ footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Category_1.default, { category: content, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', onClick: handleViewPurchasedObject, component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.category.button", defaultMessage: "ui.checkoutReturnDialog.category.button" }) }))] }));
88
116
  }
89
117
  else if (contentType === types_1.SCContentType.COURSE) {
90
- footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Course_1.default, { course: content, template: course_1.SCCourseTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.COURSE_ROUTE_NAME, content), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.course.button", defaultMessage: "ui.checkoutReturnDialog.course.button" }) }))] }));
118
+ footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Course_1.default, { course: content, template: course_1.SCCourseTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', onClick: handleViewPurchasedObject, component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.course.button", defaultMessage: "ui.checkoutReturnDialog.course.button" }) }))] }));
91
119
  }
92
120
  else if (contentType === types_1.SCContentType.GROUP) {
93
- footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Group_1.default, { group: content, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.GROUP_ROUTE_NAME, content), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.category.button", defaultMessage: "ui.checkoutReturnDialog.category.button" }) }))] }));
121
+ footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Group_1.default, { group: content, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', onClick: handleViewPurchasedObject, component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.category.button", defaultMessage: "ui.checkoutReturnDialog.category.button" }) }))] }));
94
122
  }
95
123
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ spacing: 2, justifyContent: "center", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(Grow_1.default, Object.assign({ in: true, style: { transitionDelay: '300ms' } }, { children: (0, jsx_runtime_1.jsx)("img", { src: clapping_1.CLAPPING, className: classes.img, alt: intl.formatMessage({
96
124
  id: 'ui.checkoutReturnDialog.buy',
@@ -14,10 +14,12 @@ const lab_1 = require("@mui/lab");
14
14
  const BaseItem_1 = tslib_1.__importDefault(require("../../shared/BaseItem"));
15
15
  const UserAvatar_1 = tslib_1.__importDefault(require("../../shared/UserAvatar"));
16
16
  const system_1 = require("@mui/system");
17
+ const PreviewComponent_1 = tslib_1.__importDefault(require("../../shared/Media/File/PreviewComponent"));
17
18
  const PREFIX = 'SCCommentObjectReply';
18
19
  const classes = {
19
20
  root: `${PREFIX}-root`,
20
21
  comment: `${PREFIX}-comment`,
22
+ media: `${PREFIX}-media`,
21
23
  hasValue: `${PREFIX}-has-value`,
22
24
  avatar: `${PREFIX}-avatar`,
23
25
  actions: `${PREFIX}-actions`,
@@ -70,7 +72,8 @@ function CommentObjectReply(inProps) {
70
72
  const scUserContext = (0, react_core_1.useSCUser)();
71
73
  // RETRIEVE OBJECTS
72
74
  const [html, setHtml] = (0, react_1.useState)(text);
73
- const [media, setMedia] = (0, react_1.useState)(medias);
75
+ const [media, setMedia] = (0, react_1.useState)(medias !== null && medias !== void 0 ? medias : []);
76
+ const [uploadingMedia, setUploadingMedia] = (0, react_1.useState)(false);
74
77
  // HOOKS
75
78
  const theme = (0, material_1.useTheme)();
76
79
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
@@ -115,8 +118,11 @@ function CommentObjectReply(inProps) {
115
118
  const handleChangeText = (value) => {
116
119
  setHtml(value);
117
120
  };
118
- const handleChangeMedia = (medias) => {
119
- setMedia(medias);
121
+ const handleChangeMedia = (value) => {
122
+ setMedia((prev) => [...prev, value]);
123
+ };
124
+ const handleChangeMedias = (value) => {
125
+ setMedia([...value]);
120
126
  };
121
127
  /**
122
128
  * Check if editor is empty
@@ -127,7 +133,7 @@ function CommentObjectReply(inProps) {
127
133
  }, [html]);
128
134
  // RENDER
129
135
  return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id }, rest, { disableTypography: true, onClick: handleEditorFocus, elevation: elevation, className: (0, classnames_1.default)(classes.root, className), image: showAvatar &&
130
- (!scUserContext.user ? ((0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "circular", className: classes.avatar })) : ((0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !scUserContext.user.community_badge }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scUserContext.user.username, variant: "circular", src: scUserContext.user.avatar, classes: { root: classes.avatar } }) })))), secondary: (0, jsx_runtime_1.jsxs)(Widget_1.default, Object.assign({ className: (0, classnames_1.default)(classes.comment, { [classes.hasValue]: !isEditorEmpty }) }, WidgetProps, { children: [(0, jsx_runtime_1.jsx)(Editor_1.default, Object.assign({ ref: editor, onChange: handleChangeText, onMediaChange: handleChangeMedia, defaultValue: html, editable: editable, uploadImage: true, action: replyIcon &&
131
- onReply && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleReply, className: classes.iconReply }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "send" }) }))) }, EditorProps)), !isEditorEmpty && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 2, className: classes.actions }, { children: [onReply && !replyIcon && ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "outlined", size: "small", onClick: handleReply, loading: !editable, className: classes.buttonReply }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.replyComment.reply", defaultMessage: "ui.commentObject.replyComment.reply" }) }))), onSave && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [onCancel && ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: 'text', size: "small", onClick: handleCancel, disabled: !editable, color: "inherit", className: classes.buttonCancel }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.replyComment.cancel", defaultMessage: "ui.commentObject.replyComment.cancel" }) }))), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "outlined", size: "small", onClick: handleSave, loading: !editable, className: classes.buttonSave }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.replyComment.save", defaultMessage: "ui.commentObject.replyComment.save" }) }))] }))] })))] })) })));
136
+ (!scUserContext.user ? ((0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "circular", className: classes.avatar })) : ((0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !scUserContext.user.community_badge }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scUserContext.user.username, variant: "circular", src: scUserContext.user.avatar, classes: { root: classes.avatar } }) })))), secondary: (0, jsx_runtime_1.jsxs)(Widget_1.default, Object.assign({ className: (0, classnames_1.default)(classes.comment, { [classes.hasValue]: !isEditorEmpty }) }, WidgetProps, { children: [media && media.length > 0 && (0, jsx_runtime_1.jsx)(PreviewComponent_1.default, { value: media, onChange: handleChangeMedias, className: classes.media }), (0, jsx_runtime_1.jsx)(Editor_1.default, Object.assign({ ref: editor, onChange: handleChangeText, defaultValue: html, editable: editable, uploadImage: true, action: replyIcon &&
137
+ onReply && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleReply, className: classes.iconReply, disabled: uploadingMedia }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "send" }) }))) }, EditorProps, { MediaPluginProps: { isUploading: setUploadingMedia, onMediaAdd: handleChangeMedia } })), !isEditorEmpty && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 2, className: classes.actions }, { children: [onReply && !replyIcon && ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "outlined", size: "small", onClick: handleReply, loading: !editable, className: classes.buttonReply }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.replyComment.reply", defaultMessage: "ui.commentObject.replyComment.reply" }) }))), onSave && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [onCancel && ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: 'text', size: "small", onClick: handleCancel, disabled: !editable, color: "inherit", className: classes.buttonCancel }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.replyComment.cancel", defaultMessage: "ui.commentObject.replyComment.cancel" }) }))), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ variant: "outlined", size: "small", onClick: handleSave, loading: !editable, className: classes.buttonSave }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.replyComment.save", defaultMessage: "ui.commentObject.replyComment.save" }) }))] }))] })))] })) })));
132
138
  }
133
139
  exports.default = CommentObjectReply;
@@ -0,0 +1,8 @@
1
+ import { SCContentType, SCPaymentOrder, SCPaymentPrice, SCPaymentProduct } from '@selfcommunity/types';
2
+ export interface CommunityPaywallProps {
3
+ className?: string;
4
+ prefetchedProducts?: SCPaymentProduct[];
5
+ paymentOrder?: SCPaymentOrder;
6
+ onUpdatePaymentOrder?: (price: SCPaymentPrice, contentType?: SCContentType, contentId?: string | number) => void;
7
+ }
8
+ export default function CommunityPaywall(inProps: CommunityPaywallProps): JSX.Element;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const Unstable_Grid2_1 = tslib_1.__importDefault(require("@mui/material/Unstable_Grid2"));
7
+ const styles_1 = require("@mui/material/styles");
8
+ const system_1 = require("@mui/system");
9
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
10
+ const api_services_1 = require("@selfcommunity/api-services");
11
+ const types_1 = require("@selfcommunity/types");
12
+ const react_core_1 = require("@selfcommunity/react-core");
13
+ const constants_1 = require("./constants");
14
+ const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
15
+ const PaymentProduct_1 = tslib_1.__importDefault(require("../PaymentProduct"));
16
+ const utils_1 = require("@selfcommunity/utils");
17
+ const Errors_1 = require("../../constants/Errors");
18
+ const classes = {
19
+ root: `${constants_1.PREFIX}-root`
20
+ };
21
+ const Root = (0, styles_1.styled)(Unstable_Grid2_1.default, {
22
+ slot: 'Root',
23
+ name: constants_1.PREFIX
24
+ })(({ theme }) => ({}));
25
+ function CommunityPaywall(inProps) {
26
+ // PROPS
27
+ const props = (0, system_1.useThemeProps)({
28
+ props: inProps,
29
+ name: constants_1.PREFIX
30
+ });
31
+ const { className, prefetchedProducts = [], paymentOrder = null, onUpdatePaymentOrder } = props, rest = tslib_1.__rest(props, ["className", "prefetchedProducts", "paymentOrder", "onUpdatePaymentOrder"]);
32
+ // STATE
33
+ const [products, setProducts] = (0, react_1.useState)([]);
34
+ const [payment, setPayment] = (0, react_1.useState)(null);
35
+ const [loading, setLoading] = (0, react_1.useState)(true);
36
+ // HOOKS
37
+ const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
38
+ const isMountedRef = (0, react_core_1.useIsComponentMountedRef)();
39
+ /**
40
+ * On mount, fetches community products
41
+ */
42
+ (0, react_1.useEffect)(() => {
43
+ if (prefetchedProducts.length) {
44
+ setProducts(prefetchedProducts);
45
+ setPayment(paymentOrder);
46
+ setLoading(false);
47
+ }
48
+ else {
49
+ api_services_1.PaymentApiClient.getCommunityPaymentProducts()
50
+ .then((data) => {
51
+ if (isMountedRef.current) {
52
+ setProducts(data.paywalls);
53
+ setPayment(data.payment_order);
54
+ setLoading(false);
55
+ }
56
+ })
57
+ .catch((error) => {
58
+ utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
59
+ });
60
+ }
61
+ }, [prefetchedProducts.length]);
62
+ if (!isPaymentsEnabled) {
63
+ return null;
64
+ }
65
+ if (loading) {
66
+ return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
67
+ }
68
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), container: true, spacing: 4 }, rest, { children: products.map((p, i) => ((0, jsx_runtime_1.jsx)(Unstable_Grid2_1.default, Object.assign({ xs: 4 }, { children: (0, jsx_runtime_1.jsx)(PaymentProduct_1.default, Object.assign({ expanded: true, paymentProduct: p, contentType: types_1.SCContentType.COMMUNITY, contentId: p.id }, (paymentOrder && { paymentOrder, onUpdatePaymentOrder }))) }), i))) })));
69
+ }
70
+ exports.default = CommunityPaywall;
@@ -0,0 +1,27 @@
1
+ import { PaymentProductSkeletonProps } from '../PaymentProduct/Skeleton';
2
+ import { Grid2Props } from '@mui/material/Unstable_Grid2';
3
+ export interface CommunityPaywallSkeletonProps extends Grid2Props {
4
+ className?: string;
5
+ PaymentProductSkeletonComponentProps?: PaymentProductSkeletonProps;
6
+ }
7
+ /**
8
+ * > API documentation for the Community-JS CommunityPaywall Skeleton component. Learn about the available props and the CSS API.
9
+
10
+ #### Import
11
+
12
+ ```jsx
13
+ import {CommunityPaywallSkeleton} from '@selfcommunity/react-ui';
14
+ ```
15
+
16
+ #### Component Name
17
+
18
+ The name `SCCommunityPaywallSkeleton-skeleton-root` can be used when providing style overrides in the theme.
19
+
20
+ #### CSS
21
+
22
+ |Rule Name|Global class|Description|
23
+ |---|---|---|
24
+ |root|.SCCommunityPaywallSkeleton-skeleton-root|Styles applied to the root element.|
25
+ *
26
+ */
27
+ export default function CommunityPaywallSkeleton(inProps: any): JSX.Element;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const styles_1 = require("@mui/material/styles");
6
+ const material_1 = require("@mui/material");
7
+ const constants_1 = require("./constants");
8
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
9
+ const Skeleton_1 = tslib_1.__importDefault(require("../PaymentProduct/Skeleton"));
10
+ const Unstable_Grid2_1 = tslib_1.__importDefault(require("@mui/material/Unstable_Grid2"));
11
+ const system_1 = require("@mui/system");
12
+ const classes = {
13
+ root: `${constants_1.PREFIX}-skeleton-root`,
14
+ products: `${constants_1.PREFIX}-products`
15
+ };
16
+ const Root = (0, styles_1.styled)(Unstable_Grid2_1.default, {
17
+ name: constants_1.PREFIX,
18
+ slot: 'SkeletonRoot'
19
+ })(() => ({
20
+ overflow: 'hidden'
21
+ }));
22
+ /**
23
+ * > API documentation for the Community-JS CommunityPaywall Skeleton component. Learn about the available props and the CSS API.
24
+
25
+ #### Import
26
+
27
+ ```jsx
28
+ import {CommunityPaywallSkeleton} from '@selfcommunity/react-ui';
29
+ ```
30
+
31
+ #### Component Name
32
+
33
+ The name `SCCommunityPaywallSkeleton-skeleton-root` can be used when providing style overrides in the theme.
34
+
35
+ #### CSS
36
+
37
+ |Rule Name|Global class|Description|
38
+ |---|---|---|
39
+ |root|.SCCommunityPaywallSkeleton-skeleton-root|Styles applied to the root element.|
40
+ *
41
+ */
42
+ function CommunityPaywallSkeleton(inProps) {
43
+ // PROPS
44
+ const props = (0, system_1.useThemeProps)({
45
+ props: inProps,
46
+ name: `${constants_1.PREFIX}Skeleton`
47
+ });
48
+ const { className, PaymentProductSkeletonComponentProps } = props, rest = tslib_1.__rest(props, ["className", "PaymentProductSkeletonComponentProps"]);
49
+ // HOOKS
50
+ const theme = (0, material_1.useTheme)();
51
+ const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
52
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), container: true, spacing: 4 }, rest, { children: [...Array(isMobile ? 2 : 3)].map((product, index) => ((0, jsx_runtime_1.jsx)(Unstable_Grid2_1.default, Object.assign({ xs: 4 }, { children: (0, jsx_runtime_1.jsx)(Skeleton_1.default, Object.assign({ expanded: true, elevation: 0, variant: 'outlined' }, PaymentProductSkeletonComponentProps)) }), index))) })));
53
+ }
54
+ exports.default = CommunityPaywallSkeleton;
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCCommunityPaywall";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PREFIX = void 0;
4
+ exports.PREFIX = 'SCCommunityPaywall';
@@ -0,0 +1,3 @@
1
+ import CommunityPaywall, { CommunityPaywallProps } from './CommunityPaywall';
2
+ export default CommunityPaywall;
3
+ export { CommunityPaywallProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const CommunityPaywall_1 = tslib_1.__importDefault(require("./CommunityPaywall"));
5
+ exports.default = CommunityPaywall_1.default;
@@ -9,12 +9,15 @@ const classnames_1 = tslib_1.__importDefault(require("classnames"));
9
9
  const Editor_1 = tslib_1.__importDefault(require("../../../Editor"));
10
10
  const react_intl_1 = require("react-intl");
11
11
  const constants_1 = require("../../constants");
12
+ const Media_1 = require("../../../../shared/Media");
13
+ const UrlTextField_1 = tslib_1.__importDefault(require("../../../../shared/Media/Link/UrlTextField"));
12
14
  const classes = {
13
15
  root: `${constants_1.PREFIX}-content-lesson-root`,
14
16
  generalError: `${constants_1.PREFIX}-general-error`,
15
17
  title: `${constants_1.PREFIX}-content-lesson-title`,
16
18
  medias: `${constants_1.PREFIX}-content-lesson-medias`,
17
- editor: `${constants_1.PREFIX}-content-lesson-editor`
19
+ editor: `${constants_1.PREFIX}-content-lesson-editor`,
20
+ link: `${constants_1.PREFIX}-content-lesson-link`
18
21
  };
19
22
  const Root = (0, styles_1.styled)(material_1.Box, {
20
23
  name: constants_1.PREFIX,
@@ -24,13 +27,41 @@ exports.default = (props) => {
24
27
  // PROPS
25
28
  const { className = null, value, error = {}, disabled = false, onChange, onMediaChange, EditorProps = {} } = props;
26
29
  const { error: generalError = null } = Object.assign({}, error);
30
+ const mediaObjectTypes = [Media_1.File, Media_1.Link];
31
+ const [medias, setMedias] = (0, react_1.useState)((value === null || value === void 0 ? void 0 : value.medias) || []);
32
+ const [openLink, setOpenLink] = (0, react_1.useState)();
33
+ const linkInputRef = (0, react_1.useRef)(null);
27
34
  // HANDLERS
28
35
  const handleChangeHtml = (0, react_1.useCallback)((html) => {
29
36
  onChange(html);
30
37
  }, [value]);
31
- const handleChangeMedia = (0, react_1.useCallback)((medias) => {
32
- onMediaChange(medias);
38
+ const handleChangeMedias = (0, react_1.useCallback)((value) => {
39
+ setMedias([...value]);
40
+ onMediaChange([...value]);
33
41
  }, []);
42
+ const handleChangeMedia = (value) => {
43
+ setMedias((prev) => [...prev, value]);
44
+ onMediaChange([...medias, value]);
45
+ };
46
+ const handleLinkAdd = (0, react_1.useCallback)((media) => {
47
+ setMedias([...medias, media]);
48
+ setOpenLink(false);
49
+ }, [medias]);
50
+ (0, react_1.useEffect)(() => {
51
+ if (openLink && linkInputRef.current) {
52
+ linkInputRef.current.scrollIntoView({ behavior: 'smooth' });
53
+ }
54
+ }, [openLink]);
34
55
  // RENDER
35
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [generalError && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.generalError }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }) }))), (0, jsx_runtime_1.jsx)(Editor_1.default, Object.assign({}, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, onMediaChange: handleChangeMedia, defaultValue: value.html }))] })));
56
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [generalError && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.generalError }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }) }))), (0, jsx_runtime_1.jsx)(Editor_1.default, Object.assign({}, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, onMediaChange: handleChangeMedia, defaultValue: value.html, ToolBarProps: {
57
+ customLink: (0, jsx_runtime_1.jsx)(Media_1.Link.triggerButton, { color: "default", onClick: () => setOpenLink(true) }, Media_1.Link.name),
58
+ uploadImage: false,
59
+ uploadFile: true
60
+ } })), openLink && ((0, jsx_runtime_1.jsx)(UrlTextField_1.default, { inputRef: linkInputRef, className: classes.link, id: "page", name: "page", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.media.link.add.label", defaultMessage: "ui.composer.media.link.add.label" }), fullWidth: true, variant: "outlined", placeholder: "https://", onSuccess: handleLinkAdd, InputProps: {
61
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => setOpenLink(false) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) })) })))
62
+ } })), medias && medias.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.medias }, { children: mediaObjectTypes.map((mediaObjectType) => {
63
+ if (mediaObjectType.previewComponent) {
64
+ return (0, jsx_runtime_1.jsx)(mediaObjectType.previewComponent, { value: medias, onChange: handleChangeMedias }, mediaObjectType.name);
65
+ }
66
+ }) })))] })));
36
67
  };