react-easy-wall 1.1.1 → 1.1.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.
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var session_hooks = require('../session/session.hooks.js');
6
+ var PaywallSubscription = require('./PaywallSubscription.js');
7
+
8
+ const Paywall = ({ children, post, postTypeField, postType }) => {
9
+ const { user, subscription } = session_hooks.useSession();
10
+ const postTypeValue = post[postTypeField];
11
+ if (!subscription && post && postTypeValue && postTypeValue === postType) {
12
+ return jsxRuntime.jsx(PaywallSubscription.PaywallSubscription, { post: post });
13
+ }
14
+ if (!user && post && postTypeValue && postTypeValue === postType) {
15
+ return null;
16
+ }
17
+ return children;
18
+ };
19
+
20
+ exports.Paywall = Paywall;
21
+ //# sourceMappingURL=Paywall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Paywall.js","sources":["../../../../src/components/paywall/Paywall.tsx"],"sourcesContent":["'use client';\nimport React from 'react';\nimport { Box } from '@mui/material';\nimport { useSession } from '../session/session.hooks';\nimport { PaywallSubscription } from './PaywallSubscription';\n\nexport interface PaywallProps {\n children?: React.ReactNode;\n post?: any;\n postTypeField?: string;\n postType?: string;\n}\n\nexport const Paywall: React.FC<PaywallProps> = ({ children, post, postTypeField, postType }) => {\n const { user, subscription } = useSession();\n const postTypeValue = post[postTypeField as string];\n if (!subscription && post && postTypeValue && postTypeValue === postType) {\n return <PaywallSubscription post={post} />;\n }\n\n if (!user && post && postTypeValue && postTypeValue === postType) {\n return null;\n }\n\n return children;\n};\n"],"names":[],"mappings":";;;;;;;AAaO;;AAEL;;AAEE;;;AAIA;;AAGF;AACF;;"}
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var paywall_constants = require('./paywall.constants.js');
5
+ var Box = require('../../node_modules/@mui/material/esm/Box/Box.js');
6
+ var Typography = require('../../node_modules/@mui/material/esm/Typography/Typography.js');
7
+ var Button = require('../../node_modules/@mui/material/esm/Button/Button.js');
8
+
9
+ const PaywallSubscription = ({ containerProps = {}, subtitleProps = {}, buttonProps = {}, titleProps = {}, secondaryButtonText = '', secondaryButtonProps = {}, withCaption = false, title = 'Este artículo es exclusivo para suscriptores', subtitle = 'Tu contribución nos ayuda a cubrir costos de investigación, tecnología y ofrecerte servicios de valor agregado.', post, buttonText = '', }) => {
10
+ const { sx: sxContainerProps, ...containerPropRest } = containerProps;
11
+ const { sx: sxSubtitleProps, ...subtitlePropRest } = subtitleProps;
12
+ const { sx: sxTitleProps, ...titlePropRest } = titleProps;
13
+ const { sx: sxButtonProps, ...buttonPropsRest } = buttonProps;
14
+ const { sx: sxSecondaryButtonProps, ...secondaryButtonPropsRest } = secondaryButtonProps;
15
+ const handleButton = () => {
16
+ if (!paywall_constants.PAYWALL_AUTH_ENDPOINT) {
17
+ console.error('PAYWALL_AUTH_ENDPOINT is required!');
18
+ return null;
19
+ }
20
+ return (window.location.href = `${paywall_constants.PAYWALL_AUTH_ENDPOINT}/planes?post_url=${window.location.href}`);
21
+ };
22
+ const handleSecondaryButton = () => {
23
+ if (!paywall_constants.PAYWALL_AUTH_ENDPOINT) {
24
+ console.error('PAYWALL_AUTH_ENDPOINT is required!');
25
+ return null;
26
+ }
27
+ return (window.location.href = `${paywall_constants.PAYWALL_AUTH_ENDPOINT}/autenticacion?action=AUTH_LOGIN?post_url=${window.location.href}`);
28
+ };
29
+ return (jsxRuntime.jsxs(Box.default, { sx: {
30
+ height: withCaption ? 220 : 300,
31
+ width: '100%',
32
+ border: '1px solid #707070',
33
+ justifyContent: 'center',
34
+ alignItems: 'center',
35
+ flexDirection: 'column',
36
+ ...sxContainerProps,
37
+ }, ...containerPropRest, children: [jsxRuntime.jsx(Typography.default, { sx: { ...sxTitleProps }, ...titlePropRest, children: title }), jsxRuntime.jsx(Typography.default, { sx: { ...sxSubtitleProps }, ...subtitlePropRest, children: subtitle }), jsxRuntime.jsx(Button.default, { disableElevation: true, disableRipple: true, disableTouchRipple: true, disableFocusRipple: true, sx: {
38
+ background: '#f75957',
39
+ '&:hover': {
40
+ backgroundColor: '#f75957',
41
+ },
42
+ ...sxButtonProps,
43
+ }, onClick: () => handleButton(), ...buttonPropsRest, children: buttonText }), jsxRuntime.jsx(Button.default, { disableElevation: true, disableRipple: true, disableTouchRipple: true, disableFocusRipple: true, sx: {
44
+ textDecoration: 'underline',
45
+ background: 'transparent',
46
+ padding: '0.5rem 1rem',
47
+ ...sxSecondaryButtonProps,
48
+ }, onClick: () => handleSecondaryButton(), ...secondaryButtonPropsRest, children: secondaryButtonText })] }));
49
+ };
50
+
51
+ exports.PaywallSubscription = PaywallSubscription;
52
+ //# sourceMappingURL=PaywallSubscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaywallSubscription.js","sources":["../../../../src/components/paywall/PaywallSubscription.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, BoxProps, Typography, TypographyProps, ButtonProps, Button } from '@mui/material';\nimport { PAYWALL_AUTH_ENDPOINT } from './paywall.constants';\n\nexport interface PaywallSubscriptionProps {\n post?: any;\n containerProps?: BoxProps;\n titleProps?: TypographyProps;\n subtitleProps?: TypographyProps;\n buttonProps?: ButtonProps;\n buttonText?: string;\n secondaryButtonProps?: ButtonProps;\n secondaryButtonText?: string;\n title?: string;\n subtitle?: string;\n withCaption?: boolean;\n}\n\nexport const PaywallSubscription: React.FC<PaywallSubscriptionProps> = ({\n containerProps = {},\n subtitleProps = {},\n buttonProps = {},\n titleProps = {},\n secondaryButtonText = '',\n secondaryButtonProps = {},\n withCaption = false,\n title = 'Este artículo es exclusivo para suscriptores',\n subtitle = 'Tu contribución nos ayuda a cubrir costos de investigación, tecnología y ofrecerte servicios de valor agregado.',\n post,\n buttonText = '',\n}) => {\n const { sx: sxContainerProps, ...containerPropRest } = containerProps;\n const { sx: sxSubtitleProps, ...subtitlePropRest } = subtitleProps;\n const { sx: sxTitleProps, ...titlePropRest } = titleProps;\n const { sx: sxButtonProps, ...buttonPropsRest } = buttonProps;\n const { sx: sxSecondaryButtonProps, ...secondaryButtonPropsRest } = secondaryButtonProps;\n\n const handleButton = () => {\n if (!PAYWALL_AUTH_ENDPOINT) {\n console.error('PAYWALL_AUTH_ENDPOINT is required!');\n return null;\n }\n\n return (window.location.href = `${PAYWALL_AUTH_ENDPOINT}/planes?post_url=${window.location.href}`);\n };\n\n const handleSecondaryButton = () => {\n if (!PAYWALL_AUTH_ENDPOINT) {\n console.error('PAYWALL_AUTH_ENDPOINT is required!');\n return null;\n }\n\n return (window.location.href = `${PAYWALL_AUTH_ENDPOINT}/autenticacion?action=AUTH_LOGIN?post_url=${window.location.href}`);\n };\n\n return (\n <Box\n sx={{\n height: withCaption ? 220 : 300,\n width: '100%',\n border: '1px solid #707070',\n justifyContent: 'center',\n alignItems: 'center',\n flexDirection: 'column',\n ...sxContainerProps,\n }}\n {...containerPropRest}>\n <Typography sx={{ ...sxTitleProps }} {...titlePropRest}>\n {title}\n </Typography>\n <Typography sx={{ ...sxSubtitleProps }} {...subtitlePropRest}>\n {subtitle}\n </Typography>\n <Button\n disableElevation\n disableRipple\n disableTouchRipple\n disableFocusRipple\n sx={{\n background: '#f75957',\n '&:hover': {\n backgroundColor: '#f75957',\n },\n ...sxButtonProps,\n }}\n onClick={() => handleButton()}\n {...buttonPropsRest}>\n {buttonText}\n </Button>\n <Button\n disableElevation\n disableRipple\n disableTouchRipple\n disableFocusRipple\n sx={{\n textDecoration: 'underline',\n background: 'transparent',\n padding: '0.5rem 1rem',\n ...sxSecondaryButtonProps,\n }}\n onClick={() => handleSecondaryButton()}\n {...secondaryButtonPropsRest}>\n {secondaryButtonText}\n </Button>\n </Box>\n );\n};\n"],"names":["PAYWALL_AUTH_ENDPOINT","_jsxs","Box","_jsx","Typography","Button"],"mappings":";;;;;;;;MAkBa,mBAAmB,GAAuC,CAAC,EACtE,cAAc,GAAG,E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AAwB,EAAA,QAAA,EAC3B,mBAAmB,EAAA,CACb,CAAA,EAAA,CACL;AAEV;;;;"}
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const PAYWALL_AUTH_ENDPOINT = process.env.NEXT_PUBLIC_PAYWALL_AUTH_ENDPOINT || '';
4
+
5
+ exports.PAYWALL_AUTH_ENDPOINT = PAYWALL_AUTH_ENDPOINT;
6
+ //# sourceMappingURL=paywall.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paywall.constants.js","sources":["../../../../src/components/paywall/paywall.constants.ts"],"sourcesContent":["\nexport const PAYWALL_AUTH_ENDPOINT = process.env.NEXT_PUBLIC_PAYWALL_AUTH_ENDPOINT || '';\n"],"names":[],"mappings":";;AACO,MAAM,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI;;;;"}
@@ -3,6 +3,7 @@
3
3
 
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var React = require('react');
6
+ var generated = require('../../shared/types/generated.js');
6
7
  var SessionUserContext = require('./SessionUserContext.js');
7
8
  var theme = require('../../shared/mui/theme.js');
8
9
  var ThemeProvider = require('../../node_modules/@mui/material/esm/styles/ThemeProvider.js');
@@ -13,7 +14,7 @@ const SessionUserProvider = ({ children, initial, config, }) => {
13
14
  const values = {
14
15
  user,
15
16
  config,
16
- subscription: { id: 1 },
17
+ subscription: user?.subscriptions?.find((item) => item?.status === generated.SubscriptionStatuses.Active),
17
18
  };
18
19
  return (jsxRuntime.jsx(SessionUserContext.Provider, { value: values, children: jsxRuntime.jsxs(ThemeProvider.default, { theme: theme.theme, children: [jsxRuntime.jsx(CssBaseline.default, {}), children] }) }));
19
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SessionUserProvider.js","sources":["../../../../src/components/session/SessionUserProvider.tsx"],"sourcesContent":["'use client';\nimport React, { useState } from 'react';\nimport { User } from '../../shared/types/generated';\nimport { Provider } from './SessionUserContext';\nimport { SessionContextDefaultValues } from './session.types';\nimport { Config } from '../../config/config.types';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { theme } from '../../shared/mui/theme';\n\ntype SessionUserProviderProps = {\n children: React.ReactNode;\n initial: User | null | undefined;\n config: Config;\n};\n\nexport const SessionUserProvider: React.FC<SessionUserProviderProps> = ({\n children,\n initial,\n config,\n}) => {\n const [user] = useState<User | null | undefined>(initial);\n\n const values: SessionContextDefaultValues = {\n user,\n config,\n subscription: { id: 1 },\n };\n return (\n <Provider value={values}>\n <ThemeProvider theme={theme}>\n <CssBaseline />\n\n {children}\n </ThemeProvider>\n </Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAgBO;;AAOL;;;AAGE;;;AAWJ;;"}
1
+ {"version":3,"file":"SessionUserProvider.js","sources":["../../../../src/components/session/SessionUserProvider.tsx"],"sourcesContent":["'use client';\nimport React, { useState } from 'react';\nimport { SubscriptionStatuses, User } from '../../shared/types/generated';\nimport { Provider } from './SessionUserContext';\nimport { SessionContextDefaultValues } from './session.types';\nimport { Config } from '../../config/config.types';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { theme } from '../../shared/mui/theme';\n\ntype SessionUserProviderProps = {\n children: React.ReactNode;\n initial: User | null | undefined;\n config: Config;\n};\n\nexport const SessionUserProvider: React.FC<SessionUserProviderProps> = ({\n children,\n initial,\n config,\n}) => {\n const [user] = useState<User | null | undefined>(initial);\n\n const values: SessionContextDefaultValues = {\n user,\n config,\n subscription: user?.subscriptions?.find((item) => item?.status === SubscriptionStatuses.Active),\n };\n return (\n <Provider value={values}>\n <ThemeProvider theme={theme}>\n <CssBaseline />\n\n {children}\n </ThemeProvider>\n </Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAgBO;;AAOL;;;AAGE;;;AAWJ;;"}
package/dist/cjs/index.js CHANGED
@@ -12,6 +12,9 @@ var PanelListItems = require('./components/panel/PanelListItems.js');
12
12
  var panel_store = require('./components/panel/panel.store.js');
13
13
  var panel_actions = require('./components/panel/panel.actions.js');
14
14
  var SessionProvider = require('./components/session/SessionProvider.js');
15
+ var PaywallSubscription = require('./components/paywall/PaywallSubscription.js');
16
+ var paywall_constants = require('./components/paywall/paywall.constants.js');
17
+ var Paywall = require('./components/paywall/Paywall.js');
15
18
 
16
19
 
17
20
 
@@ -29,4 +32,7 @@ exports.handleLogout = panel_actions.handleLogout;
29
32
  exports.handlePanelClick = panel_actions.handlePanelClick;
30
33
  exports.panelStoreAction = panel_actions.panelStoreAction;
31
34
  exports.SessionProvider = SessionProvider.SessionProvider;
35
+ exports.PaywallSubscription = PaywallSubscription.PaywallSubscription;
36
+ exports.PAYWALL_AUTH_ENDPOINT = paywall_constants.PAYWALL_AUTH_ENDPOINT;
37
+ exports.Paywall = Paywall.Paywall;
32
38
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useSession } from '../session/session.hooks.js';
4
+ import { PaywallSubscription } from './PaywallSubscription.js';
5
+
6
+ const Paywall = ({ children, post, postTypeField, postType }) => {
7
+ const { user, subscription } = useSession();
8
+ const postTypeValue = post[postTypeField];
9
+ if (!subscription && post && postTypeValue && postTypeValue === postType) {
10
+ return jsx(PaywallSubscription, { post: post });
11
+ }
12
+ if (!user && post && postTypeValue && postTypeValue === postType) {
13
+ return null;
14
+ }
15
+ return children;
16
+ };
17
+
18
+ export { Paywall };
19
+ //# sourceMappingURL=Paywall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Paywall.js","sources":["../../../../src/components/paywall/Paywall.tsx"],"sourcesContent":["'use client';\nimport React from 'react';\nimport { Box } from '@mui/material';\nimport { useSession } from '../session/session.hooks';\nimport { PaywallSubscription } from './PaywallSubscription';\n\nexport interface PaywallProps {\n children?: React.ReactNode;\n post?: any;\n postTypeField?: string;\n postType?: string;\n}\n\nexport const Paywall: React.FC<PaywallProps> = ({ children, post, postTypeField, postType }) => {\n const { user, subscription } = useSession();\n const postTypeValue = post[postTypeField as string];\n if (!subscription && post && postTypeValue && postTypeValue === postType) {\n return <PaywallSubscription post={post} />;\n }\n\n if (!user && post && postTypeValue && postTypeValue === postType) {\n return null;\n }\n\n return children;\n};\n"],"names":[],"mappings":";;;;;AAaO;;AAEL;;AAEE;;;AAIA;;AAGF;AACF;;"}
@@ -0,0 +1,50 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { PAYWALL_AUTH_ENDPOINT } from './paywall.constants.js';
3
+ import Box from '../../node_modules/@mui/material/esm/Box/Box.js';
4
+ import Typography from '../../node_modules/@mui/material/esm/Typography/Typography.js';
5
+ import Button from '../../node_modules/@mui/material/esm/Button/Button.js';
6
+
7
+ const PaywallSubscription = ({ containerProps = {}, subtitleProps = {}, buttonProps = {}, titleProps = {}, secondaryButtonText = '', secondaryButtonProps = {}, withCaption = false, title = 'Este artículo es exclusivo para suscriptores', subtitle = 'Tu contribución nos ayuda a cubrir costos de investigación, tecnología y ofrecerte servicios de valor agregado.', post, buttonText = '', }) => {
8
+ const { sx: sxContainerProps, ...containerPropRest } = containerProps;
9
+ const { sx: sxSubtitleProps, ...subtitlePropRest } = subtitleProps;
10
+ const { sx: sxTitleProps, ...titlePropRest } = titleProps;
11
+ const { sx: sxButtonProps, ...buttonPropsRest } = buttonProps;
12
+ const { sx: sxSecondaryButtonProps, ...secondaryButtonPropsRest } = secondaryButtonProps;
13
+ const handleButton = () => {
14
+ if (!PAYWALL_AUTH_ENDPOINT) {
15
+ console.error('PAYWALL_AUTH_ENDPOINT is required!');
16
+ return null;
17
+ }
18
+ return (window.location.href = `${PAYWALL_AUTH_ENDPOINT}/planes?post_url=${window.location.href}`);
19
+ };
20
+ const handleSecondaryButton = () => {
21
+ if (!PAYWALL_AUTH_ENDPOINT) {
22
+ console.error('PAYWALL_AUTH_ENDPOINT is required!');
23
+ return null;
24
+ }
25
+ return (window.location.href = `${PAYWALL_AUTH_ENDPOINT}/autenticacion?action=AUTH_LOGIN?post_url=${window.location.href}`);
26
+ };
27
+ return (jsxs(Box, { sx: {
28
+ height: withCaption ? 220 : 300,
29
+ width: '100%',
30
+ border: '1px solid #707070',
31
+ justifyContent: 'center',
32
+ alignItems: 'center',
33
+ flexDirection: 'column',
34
+ ...sxContainerProps,
35
+ }, ...containerPropRest, children: [jsx(Typography, { sx: { ...sxTitleProps }, ...titlePropRest, children: title }), jsx(Typography, { sx: { ...sxSubtitleProps }, ...subtitlePropRest, children: subtitle }), jsx(Button, { disableElevation: true, disableRipple: true, disableTouchRipple: true, disableFocusRipple: true, sx: {
36
+ background: '#f75957',
37
+ '&:hover': {
38
+ backgroundColor: '#f75957',
39
+ },
40
+ ...sxButtonProps,
41
+ }, onClick: () => handleButton(), ...buttonPropsRest, children: buttonText }), jsx(Button, { disableElevation: true, disableRipple: true, disableTouchRipple: true, disableFocusRipple: true, sx: {
42
+ textDecoration: 'underline',
43
+ background: 'transparent',
44
+ padding: '0.5rem 1rem',
45
+ ...sxSecondaryButtonProps,
46
+ }, onClick: () => handleSecondaryButton(), ...secondaryButtonPropsRest, children: secondaryButtonText })] }));
47
+ };
48
+
49
+ export { PaywallSubscription };
50
+ //# sourceMappingURL=PaywallSubscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaywallSubscription.js","sources":["../../../../src/components/paywall/PaywallSubscription.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, BoxProps, Typography, TypographyProps, ButtonProps, Button } from '@mui/material';\nimport { PAYWALL_AUTH_ENDPOINT } from './paywall.constants';\n\nexport interface PaywallSubscriptionProps {\n post?: any;\n containerProps?: BoxProps;\n titleProps?: TypographyProps;\n subtitleProps?: TypographyProps;\n buttonProps?: ButtonProps;\n buttonText?: string;\n secondaryButtonProps?: ButtonProps;\n secondaryButtonText?: string;\n title?: string;\n subtitle?: string;\n withCaption?: boolean;\n}\n\nexport const PaywallSubscription: React.FC<PaywallSubscriptionProps> = ({\n containerProps = {},\n subtitleProps = {},\n buttonProps = {},\n titleProps = {},\n secondaryButtonText = '',\n secondaryButtonProps = {},\n withCaption = false,\n title = 'Este artículo es exclusivo para suscriptores',\n subtitle = 'Tu contribución nos ayuda a cubrir costos de investigación, tecnología y ofrecerte servicios de valor agregado.',\n post,\n buttonText = '',\n}) => {\n const { sx: sxContainerProps, ...containerPropRest } = containerProps;\n const { sx: sxSubtitleProps, ...subtitlePropRest } = subtitleProps;\n const { sx: sxTitleProps, ...titlePropRest } = titleProps;\n const { sx: sxButtonProps, ...buttonPropsRest } = buttonProps;\n const { sx: sxSecondaryButtonProps, ...secondaryButtonPropsRest } = secondaryButtonProps;\n\n const handleButton = () => {\n if (!PAYWALL_AUTH_ENDPOINT) {\n console.error('PAYWALL_AUTH_ENDPOINT is required!');\n return null;\n }\n\n return (window.location.href = `${PAYWALL_AUTH_ENDPOINT}/planes?post_url=${window.location.href}`);\n };\n\n const handleSecondaryButton = () => {\n if (!PAYWALL_AUTH_ENDPOINT) {\n console.error('PAYWALL_AUTH_ENDPOINT is required!');\n return null;\n }\n\n return (window.location.href = `${PAYWALL_AUTH_ENDPOINT}/autenticacion?action=AUTH_LOGIN?post_url=${window.location.href}`);\n };\n\n return (\n <Box\n sx={{\n height: withCaption ? 220 : 300,\n width: '100%',\n border: '1px solid #707070',\n justifyContent: 'center',\n alignItems: 'center',\n flexDirection: 'column',\n ...sxContainerProps,\n }}\n {...containerPropRest}>\n <Typography sx={{ ...sxTitleProps }} {...titlePropRest}>\n {title}\n </Typography>\n <Typography sx={{ ...sxSubtitleProps }} {...subtitlePropRest}>\n {subtitle}\n </Typography>\n <Button\n disableElevation\n disableRipple\n disableTouchRipple\n disableFocusRipple\n sx={{\n background: '#f75957',\n '&:hover': {\n backgroundColor: '#f75957',\n },\n ...sxButtonProps,\n }}\n onClick={() => handleButton()}\n {...buttonPropsRest}>\n {buttonText}\n </Button>\n <Button\n disableElevation\n disableRipple\n disableTouchRipple\n disableFocusRipple\n sx={{\n textDecoration: 'underline',\n background: 'transparent',\n padding: '0.5rem 1rem',\n ...sxSecondaryButtonProps,\n }}\n onClick={() => handleSecondaryButton()}\n {...secondaryButtonPropsRest}>\n {secondaryButtonText}\n </Button>\n </Box>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;MAkBa,mBAAmB,GAAuC,CAAC,EACtE,cAAc,GAAG,EAAE,EACnB,aAAa,GAAG,EAAE,EAClB,WAAW,GAAG,EAAE,EAChB,UAAU,GAAG,EAAE,EACf,mBAAmB,GAAG,EAAE,EACxB,oBAAoB,GAAG,EAAE,EACzB,WAAW,GAAG,KAAK,EACnB,KAAK,GAAG,8CAA8C,EACtD,QAAQ,GAAG,iHAAiH,EAC5H,IAAI,EACJ,UAAU,GAAG,EAAE,GAChB,KAAI;IACH,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,GAAG,iBAAiB,EAAE,GAAG,cAAc;IACrE,MAAM,EAAE,EAAE,EAAE,eAAe,EAAE,GAAG,gBAAgB,EAAE,GAAG,aAAa;IAClE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU;IACzD,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,eAAe,EAAE,GAAG,WAAW;IAC7D,MAAM,EAAE,EAAE,EAAE,sBAAsB,EAAE,GAAG,wBAAwB,EAAE,GAAG,oBAAoB;IAExF,MAAM,YAAY,GAAG,MAAK;QACxB,IAAI,CAAC,qBAAqB,EAAE;AAC1B,YAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC;AACnD,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,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,aAAa;iBACjB,EACD,OAAO,EAAE,MAAM,YAAY,EAAE,EAAA,GACzB,eAAe,EAAA,QAAA,EAClB,UAAU,EAAA,CACJ,EACTA,GAAA,CAAC,MAAM,EAAA,EACL,gBAAgB,EAAA,IAAA,EAChB,aAAa,EAAA,IAAA,EACb,kBAAkB,EAAA,IAAA,EAClB,kBAAkB,EAAA,IAAA,EAClB,EAAE,EAAE;AACF,oBAAA,cAAc,EAAE,WAAW;AAC3B,oBAAA,UAAU,EAAE,aAAa;AACzB,oBAAA,OAAO,EAAE,aAAa;AACtB,oBAAA,GAAG,sBAAsB;AAC1B,iBAAA,EACD,OAAO,EAAE,MAAM,qBAAqB,EAAE,EAAA,GAClC,wBAAwB,EAAA,QAAA,EAC3B,mBAAmB,EAAA,CACb,CAAA,EAAA,CACL;AAEV;;;;"}
@@ -0,0 +1,4 @@
1
+ const PAYWALL_AUTH_ENDPOINT = process.env.NEXT_PUBLIC_PAYWALL_AUTH_ENDPOINT || '';
2
+
3
+ export { PAYWALL_AUTH_ENDPOINT };
4
+ //# sourceMappingURL=paywall.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paywall.constants.js","sources":["../../../../src/components/paywall/paywall.constants.ts"],"sourcesContent":["\nexport const PAYWALL_AUTH_ENDPOINT = process.env.NEXT_PUBLIC_PAYWALL_AUTH_ENDPOINT || '';\n"],"names":[],"mappings":"AACO,MAAM,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI;;;;"}
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { useState } from 'react';
4
+ import { SubscriptionStatuses } from '../../shared/types/generated.js';
4
5
  import { Provider } from './SessionUserContext.js';
5
6
  import { theme } from '../../shared/mui/theme.js';
6
7
  import ThemeProvider from '../../node_modules/@mui/material/esm/styles/ThemeProvider.js';
@@ -11,7 +12,7 @@ const SessionUserProvider = ({ children, initial, config, }) => {
11
12
  const values = {
12
13
  user,
13
14
  config,
14
- subscription: { id: 1 },
15
+ subscription: user?.subscriptions?.find((item) => item?.status === SubscriptionStatuses.Active),
15
16
  };
16
17
  return (jsx(Provider, { value: values, children: jsxs(ThemeProvider, { theme: theme, children: [jsx(CssBaseline, {}), children] }) }));
17
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SessionUserProvider.js","sources":["../../../../src/components/session/SessionUserProvider.tsx"],"sourcesContent":["'use client';\nimport React, { useState } from 'react';\nimport { User } from '../../shared/types/generated';\nimport { Provider } from './SessionUserContext';\nimport { SessionContextDefaultValues } from './session.types';\nimport { Config } from '../../config/config.types';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { theme } from '../../shared/mui/theme';\n\ntype SessionUserProviderProps = {\n children: React.ReactNode;\n initial: User | null | undefined;\n config: Config;\n};\n\nexport const SessionUserProvider: React.FC<SessionUserProviderProps> = ({\n children,\n initial,\n config,\n}) => {\n const [user] = useState<User | null | undefined>(initial);\n\n const values: SessionContextDefaultValues = {\n user,\n config,\n subscription: { id: 1 },\n };\n return (\n <Provider value={values}>\n <ThemeProvider theme={theme}>\n <CssBaseline />\n\n {children}\n </ThemeProvider>\n </Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAgBO;;AAOL;;;AAGE;;;AAWJ;;"}
1
+ {"version":3,"file":"SessionUserProvider.js","sources":["../../../../src/components/session/SessionUserProvider.tsx"],"sourcesContent":["'use client';\nimport React, { useState } from 'react';\nimport { SubscriptionStatuses, User } from '../../shared/types/generated';\nimport { Provider } from './SessionUserContext';\nimport { SessionContextDefaultValues } from './session.types';\nimport { Config } from '../../config/config.types';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { theme } from '../../shared/mui/theme';\n\ntype SessionUserProviderProps = {\n children: React.ReactNode;\n initial: User | null | undefined;\n config: Config;\n};\n\nexport const SessionUserProvider: React.FC<SessionUserProviderProps> = ({\n children,\n initial,\n config,\n}) => {\n const [user] = useState<User | null | undefined>(initial);\n\n const values: SessionContextDefaultValues = {\n user,\n config,\n subscription: user?.subscriptions?.find((item) => item?.status === SubscriptionStatuses.Active),\n };\n return (\n <Provider value={values}>\n <ThemeProvider theme={theme}>\n <CssBaseline />\n\n {children}\n </ThemeProvider>\n </Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAgBO;;AAOL;;;AAGE;;;AAWJ;;"}
package/dist/esm/index.js CHANGED
@@ -10,4 +10,7 @@ export { PanelListItems } from './components/panel/PanelListItems.js';
10
10
  export { panelStore } from './components/panel/panel.store.js';
11
11
  export { handleLogout, handlePanelClick, panelStoreAction } from './components/panel/panel.actions.js';
12
12
  export { SessionProvider } from './components/session/SessionProvider.js';
13
+ export { PaywallSubscription } from './components/paywall/PaywallSubscription.js';
14
+ export { PAYWALL_AUTH_ENDPOINT } from './components/paywall/paywall.constants.js';
15
+ export { Paywall } from './components/paywall/Paywall.js';
13
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -3,5 +3,5 @@ import { Config } from '../../config/config.types';
3
3
  export type SessionContextDefaultValues = {
4
4
  user?: User | null;
5
5
  config?: Config;
6
- subscription?: Subscription;
6
+ subscription?: Subscription | null;
7
7
  };
@@ -1,2 +1,3 @@
1
1
  export * from './components/panel';
2
2
  export * from './components/session';
3
+ export * from './components/paywall';
package/dist/index.d.ts CHANGED
@@ -96,5 +96,30 @@ type SessionProviderProps = {
96
96
  };
97
97
  declare const SessionProvider: React.FC<SessionProviderProps>;
98
98
 
99
- export { Panel, PanelAvatar, PanelButton, PanelDivider, PanelFooter, PanelHeader, PanelItem, PanelListItems, PanelSubscriptionIcon, SessionProvider, handleLogout, handlePanelClick, panelStore, panelStoreAction };
100
- export type { PanelAvatarProps, PanelButtonProps, PanelDividerProps, PanelFooterProps, PanelHeaderProps, PanelItemProps, PanelListRoute, PanelProps, PanelStoreAction, PanelSubscriptionIconProps };
99
+ interface PaywallSubscriptionProps {
100
+ post?: any;
101
+ containerProps?: BoxProps;
102
+ titleProps?: TypographyProps;
103
+ subtitleProps?: TypographyProps;
104
+ buttonProps?: ButtonProps;
105
+ buttonText?: string;
106
+ secondaryButtonProps?: ButtonProps;
107
+ secondaryButtonText?: string;
108
+ title?: string;
109
+ subtitle?: string;
110
+ withCaption?: boolean;
111
+ }
112
+ declare const PaywallSubscription: React.FC<PaywallSubscriptionProps>;
113
+
114
+ declare const PAYWALL_AUTH_ENDPOINT: string;
115
+
116
+ interface PaywallProps {
117
+ children?: React.ReactNode;
118
+ post?: any;
119
+ postTypeField?: string;
120
+ postType?: string;
121
+ }
122
+ declare const Paywall: React.FC<PaywallProps>;
123
+
124
+ export { PAYWALL_AUTH_ENDPOINT, Panel, PanelAvatar, PanelButton, PanelDivider, PanelFooter, PanelHeader, PanelItem, PanelListItems, PanelSubscriptionIcon, Paywall, PaywallSubscription, SessionProvider, handleLogout, handlePanelClick, panelStore, panelStoreAction };
125
+ export type { PanelAvatarProps, PanelButtonProps, PanelDividerProps, PanelFooterProps, PanelHeaderProps, PanelItemProps, PanelListRoute, PanelProps, PanelStoreAction, PanelSubscriptionIconProps, PaywallProps, PaywallSubscriptionProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-easy-wall",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/index.d.ts",