@opexa/portal-components 0.0.663 → 0.0.665

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import Image from 'next/image';
3
2
  import { QrCode02Icon } from '../../../../icons/QrCode02Icon.js';
4
3
  import { XIcon } from '../../../../icons/XIcon.js';
5
- import qrphIcon from '../../../../images/qrph-icon.png';
6
4
  import { Button } from '../../../../ui/Button/index.js';
7
5
  import { Dialog } from '../../../../ui/Dialog/index.js';
8
6
  import { Portal } from '../../../../ui/Portal/index.js';
9
- import { QrCode } from '../../../../ui/QrCode/index.js';
10
7
  import { useQRPHDepositContext } from './QRPHDepositContext.js';
8
+ import { QRPHQRCode } from './QRPHQRCode.js';
11
9
  export function QRPHDepositDetails() {
12
10
  const context = useQRPHDepositContext();
13
11
  if (context.view !== 'qrCode')
14
12
  return null;
15
- return (_jsxs("div", { className: "rounded-lg bg-bg-primary-alt p-2xl", children: [_jsx("p", { className: "text-center font-semibold text-lg lg:text-xl", children: "QR Code" }), _jsx("p", { className: "mt-3 text-center text-sm text-text-secondary-700 lg:text-base", children: "Scan the QR code below with your banking app, or upload it to complete your deposit." }), _jsxs(QrCode.Root, { value: context.deposit?.qrCode ?? '', className: "mx-auto mt-6 w-[12.5rem] rounded-lg border border-border-primary bg-bg-brand-secondary-alt p-5 lg:w-[13rem] lg:p-6", children: [_jsxs("div", { className: "relative", children: [_jsx(QrCode.Frame, { className: "mx-auto size-[10rem] rounded-[0.25rem] border border-border-primary bg-white", children: _jsx(QrCode.Pattern, {}) }), _jsx(QrCode.Overlay, { className: "bg-white p-0.5", children: _jsx(Image, { src: qrphIcon, alt: "", className: "size-8", width: 40, height: 40 }) })] }), _jsx(QrCode.DownloadTrigger, { fileName: `qrcode-${Date.now()}`, mimeType: "image/png", className: "mt-5 block w-full text-center font-semibold text-sm text-text-secondary-700", children: "Download QR Code" })] }), _jsx("div", { className: "mt-6 flex flex-col gap-4 lg:flex-row", children: _jsx(Button, { size: "sm", variant: "outline", colorScheme: "gray", onClick: context.reset, children: "Generate New QR Code" }) }), _jsx(Instruction, {})] }));
13
+ return (_jsxs("div", { className: "rounded-lg bg-bg-primary-alt p-2xl", children: [_jsx("p", { className: "text-center font-semibold text-lg lg:text-xl", children: "QR Code" }), _jsx("p", { className: "mt-3 text-center text-sm text-text-secondary-700 lg:text-base", children: "Scan the QR code below with your banking app, or upload it to complete your deposit." }), _jsx(QRPHQRCode, { qrCodeString: context.deposit?.qrCode ?? '' }), _jsx("div", { className: "mt-6 flex flex-col gap-4 lg:flex-row", children: _jsx(Button, { size: "sm", variant: "outline", colorScheme: "gray", onClick: context.reset, children: "Generate New QR Code" }) }), _jsx(Instruction, {})] }));
16
14
  }
17
15
  function Instruction() {
18
16
  return (_jsxs("p", { className: "mt-6 text-center text-text-tertiary-600 text-xs", children: ["Need help using the QR Code?", ' ', _jsxs(Dialog.Root, { lazyMount: true, unmountOnExit: true, children: [_jsx(Dialog.Trigger, { className: "text-text-warning-primary-600", children: "See instructions" }), _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto w-[calc(100%-2rem)] overflow-y-auto rounded-lg p-4xl lg:w-[33.625rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(Dialog.Body, { children: [_jsxs("div", { className: "flex items-center gap-xl", children: [_jsx("div", { className: "flex size-11 items-center justify-center rounded-lg border border-border-primary text-gray-700 text-text-secondary-700 shadow-xs", children: _jsx(QrCode02Icon, { className: "size-6" }) }), _jsx(Dialog.Title, { className: "font-semibold text-lg", children: "How to Use the QR Code for Payment" })] }), _jsx(Dialog.Description, { className: "mt-5", children: "Follow these simple steps to complete your transaction:" }), _jsxs("ol", { className: "mt-3 list-inside list-decimal space-y-3", children: [_jsx("li", { children: "Open your preferred banking or EMI mobile app and select 'Transfer Money' or 'Pay via QR'" }), _jsx("li", { children: "Scan or upload the generated QR Ph code. If prompted by the app, enter the amount to be sent." }), _jsx("li", { children: "Proceed with the transfer or payment." })] })] })] }) })] })] })] }));
@@ -0,0 +1,3 @@
1
+ export declare function QRPHQRCode(props: {
2
+ qrCodeString: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Capacitor } from '@capacitor/core';
4
+ import { Directory, Filesystem } from '@capacitor/filesystem';
5
+ import Image from 'next/image';
6
+ import { toaster } from '../../../../client/utils/toaster.js';
7
+ import qrphIcon from '../../../../images/qrph-icon.png';
8
+ import { QrCode } from '../../../../ui/QrCode/index.js';
9
+ export function QRPHQRCode(props) {
10
+ async function handleNativeDownload() {
11
+ const QRCode = await import('qrcode');
12
+ const dataUrl = await QRCode.toDataURL(props.qrCodeString, {
13
+ type: 'image/png',
14
+ });
15
+ const base64 = dataUrl.split(',')[1];
16
+ try {
17
+ await Filesystem.writeFile({
18
+ path: `qrcode-${Date.now()}.png`,
19
+ data: base64,
20
+ directory: Directory.Documents,
21
+ });
22
+ toaster.success({
23
+ title: 'QR Code successfully saved to your device',
24
+ description: 'To continue with your deposit, please upload the QR code in your banking app.',
25
+ });
26
+ }
27
+ catch (error) {
28
+ console.log(error, 'error');
29
+ toaster.error({
30
+ title: 'Failed to save QR Code',
31
+ description: 'An error occurred while saving the QR code to your device.',
32
+ });
33
+ }
34
+ }
35
+ return (_jsxs(QrCode.Root, { value: props.qrCodeString, className: "mx-auto mt-6 w-[12.5rem] rounded-lg border border-border-primary bg-bg-brand-secondary-alt p-5 lg:w-[13rem] lg:p-6", children: [_jsxs("div", { className: "relative", children: [_jsx(QrCode.Frame, { id: "qrph-qrcode", className: "mx-auto size-[10rem] rounded-[0.25rem] border border-border-primary bg-white", children: _jsx(QrCode.Pattern, {}) }), _jsx(QrCode.Overlay, { className: "bg-white p-0.5", children: _jsx(Image, { src: qrphIcon, alt: "", className: "size-8", width: 40, height: 40 }) })] }), Capacitor.isNativePlatform() ? (_jsx("button", { type: "button", onClick: handleNativeDownload, className: "mt-5 block w-full text-center font-semibold text-sm text-text-secondary-700", children: "Download QR Code to Deviceaa" })) : (_jsx(QrCode.DownloadTrigger, { fileName: `qrcode-${Date.now()}`, mimeType: "image/png", className: "mt-5 block w-full text-center font-semibold text-sm text-text-secondary-700", children: "Download QR Code" }))] }));
36
+ }
@@ -106,9 +106,9 @@ export function MessageDetails() {
106
106
  };
107
107
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: globalStore.message.open, onOpenChange: (details) => {
108
108
  globalStore.message.setOpen(details.open);
109
- }, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto max-h-[80vh] min-w-[21.438rem] max-w-[21.438rem] overflow-y-auto rounded-xl p-3xl lg:min-w-[25rem] lg:max-w-[25rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-brand", children: _jsx(MessageIcon, { type: message?.icon ?? 'INFO', className: "size-6" }) }), _jsx(Dialog.Title, { className: "mt-lg text-center font-semibold text-lg lg:mt-xl", children: message?.title }), message?.content && (_jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700 [&_li]:mb-1 [&_ol]:list-decimal [&_ol]:pl-5 [&_ol]:text-left [&_ul]:list-disc [&_ul]:pl-5 [&_ul]:text-left", dangerouslySetInnerHTML: {
109
+ }, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "mx-auto max-h-[80vh] min-w-[21.438rem] max-w-[21.438rem] overflow-y-auto rounded-xl p-3xl lg:min-w-[25rem] lg:max-w-[25rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-brand", children: _jsx(MessageIcon, { type: message?.icon ?? 'INFO', className: "size-6" }) }), _jsx(Dialog.Title, { className: "mt-lg text-center font-semibold text-lg lg:mt-xl", children: message?.title }), message?.content && (_jsx(Dialog.Description, { className: "mt-xs pb-5 text-center text-sm text-text-secondary-700 [&_li]:mb-1 [&_ol]:list-decimal [&_ol]:pl-5 [&_ol]:text-left [&_ul]:list-disc [&_ul]:pl-5 [&_ul]:text-left", dangerouslySetInnerHTML: {
110
110
  __html: transformContent(message?.content),
111
- } })), message?.image && (_jsx("div", { className: "mt-5 pb-5", children: _jsx(Image, { src: message?.image, alt: "", width: 400, height: 250, loading: "lazy", unoptimized: true, className: "h-auto w-full rounded-sm" }) })), message?.actions.length ? (_jsx("div", { className: "mt-2xl flex flex-col gap-2 text-center lg:mt-2xl", children: message?.actions.map((action, index) => (_jsx(Button, { asChild: true, children: _jsx(Link, { href: normalizeActionUrl(action.url, {
111
+ } })), message?.image && (_jsx("div", { className: "mt-5 pb-5", children: _jsx(Image, { src: message?.image, alt: "", width: 400, height: 250, loading: "lazy", unoptimized: true, className: "h-auto w-full rounded-sm" }) })), message?.actions.length ? (_jsx("div", { className: "mt-3xl flex flex-col gap-2 text-center lg:mt-4xl", children: message?.actions.map((action, index) => (_jsx(Button, { asChild: true, children: _jsx(Link, { href: normalizeActionUrl(action.url, {
112
112
  transactionsPageUrl,
113
113
  questsPageUrl,
114
114
  }), onClick: (e) => {
@@ -117,7 +117,7 @@ export function MessagesPopup() {
117
117
  setIndex(details.page);
118
118
  }, slideCount: messages.length, allowMouseDrag: true, autoplay: false, children: [_jsx(Carousel.ItemGroup, { children: messages.map((message, index) => (_jsxs(Carousel.Item, { index: index, className: "select-none", children: [_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary text-text-brand", children: _jsx(MessageIcon, { type: message.icon, className: "size-6" }) }), _jsx("h2", { className: "mt-lg text-center font-semibold text-lg xl:mt-xl", children: message.title }), message.content && (_jsx("div", { dangerouslySetInnerHTML: {
119
119
  __html: transformContent(message.content),
120
- }, className: "mt-xs pb-5 text-left text-sm text-text-secondary-700 [&_li>ol]:list-decimal [&_li>ol]:pl-5 [&_li>ul]:list-disc [&_li>ul]:pl-5 [&_li]:mb-1 [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5" })), message.image && (_jsx("div", { className: "mt-5 pb-5", children: _jsx(Image, { src: message.image, alt: "", width: 400, height: 250, loading: "lazy", unoptimized: true, className: "h-auto w-full rounded-sm" }) })), message.actions.length ? (_jsx("div", { className: "mt-2xl flex flex-col gap-2 text-center lg:mt-2xl", children: message.actions.map((action, index) => (_jsx(Button, { asChild: true, children: _jsx(Link, { href: normalizeActionUrl(action.url, {
120
+ }, className: "mt-xs pb-5 text-left text-sm text-text-secondary-700 [&_li>ol]:list-decimal [&_li>ol]:pl-5 [&_li>ul]:list-disc [&_li>ul]:pl-5 [&_li]:mb-1 [&_ol]:list-decimal [&_ol]:pl-5 [&_ul]:list-disc [&_ul]:pl-5" })), message.image && (_jsx("div", { className: "mt-5 pb-5", children: _jsx(Image, { src: message.image, alt: "", width: 400, height: 250, loading: "lazy", unoptimized: true, className: "h-auto w-full rounded-sm" }) })), message.actions.length ? (_jsx("div", { className: "mt-3xl flex flex-col gap-2 text-center lg:mt-4xl", children: message.actions.map((action, index) => (_jsx(Button, { asChild: true, children: _jsx(Link, { href: normalizeActionUrl(action.url, {
121
121
  questsPageUrl,
122
122
  transactionsPageUrl,
123
123
  }), onClick: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.663",
3
+ "version": "0.0.665",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",
@@ -81,6 +81,8 @@
81
81
  "@capacitor/app": "^7.0.2",
82
82
  "@capacitor/cli": "^7.4.3",
83
83
  "@capacitor/core": "^7.4.3",
84
+ "@capacitor/file-transfer": "^1.0.5",
85
+ "@capacitor/filesystem": "^7.1.4",
84
86
  "@capacitor/push-notifications": "^7.0.2",
85
87
  "@capacitor/splash-screen": "^7.0.2",
86
88
  "@date-fns/tz": "^1.2.0",
@@ -101,6 +103,7 @@
101
103
  "latest": "^0.2.0",
102
104
  "lodash-es": "^4.17.21",
103
105
  "next-recaptcha-v3": "^1.5.2",
106
+ "qrcode": "^1.5.4",
104
107
  "tailwind-merge": "^3.3.1",
105
108
  "tailwind-variants": "^1.0.0",
106
109
  "tailwind-zag": "^1.0.2",
@@ -118,6 +121,7 @@
118
121
  "@total-typescript/ts-reset": "0.6.1",
119
122
  "@types/lodash-es": "4.17.12",
120
123
  "@types/node": "24",
124
+ "@types/qrcode": "^1.5.5",
121
125
  "@types/react": "19.1.8",
122
126
  "@types/react-dom": "19.1.6",
123
127
  "copy-files-from-to": "3.12.1",