@nextjs-cms-plugins/cpanel-emails 0.1.24 → 0.1.26

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 +1 @@
1
- {"version":3,"file":"EmailsPage.d.ts","sourceRoot":"","sources":["../../src/client/EmailsPage.tsx"],"names":[],"mappings":"AA6CA,eAAO,MAAM,gBAAgB,+CAgD5B,CAAA;AA0ID,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"EmailsPage.d.ts","sourceRoot":"","sources":["../../src/client/EmailsPage.tsx"],"names":[],"mappings":"AA6CA,eAAO,MAAM,gBAAgB,+CAiD5B,CAAA;AA0ID,eAAe,gBAAgB,CAAA"}
@@ -1,9 +1,10 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState } from 'react';
4
- import getString from 'nextjs-cms/translations';
5
4
  import { trpc as trpcClient } from 'nextjs-cms/api/trpc/client';
5
+ import { useI18n } from 'nextjs-cms/translations/client';
6
6
  export const CpanelEmailsPage = () => {
7
+ const t = useI18n();
7
8
  const trpc = trpcClient;
8
9
  const query = trpc?.cpanelEmails?.getEmails.useQuery;
9
10
  const { data, isLoading, isError, error, refetch } = query
@@ -17,23 +18,25 @@ export const CpanelEmailsPage = () => {
17
18
  const quotaMutation = pluginApi.quotaChange.useMutation({ onSuccess: () => refetch() });
18
19
  const passwordMutation = pluginApi.passwordChange.useMutation({ onSuccess: () => refetch() });
19
20
  const deleteMutation = pluginApi.deleteEmail.useMutation({ onSuccess: () => refetch() });
20
- return (_jsxs("div", { className: 'bg-white dark:bg-slate-900', children: [_jsx("div", { className: 'bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold text-foreground dark:from-blue-800 dark:via-amber-700 dark:to-rose-900', children: _jsx("h1", { className: 'text-3xl', children: getString('email_accounts') }) }), _jsxs("div", { className: 'flex flex-col gap-3 p-4', children: [_jsx(CreateEmailForm, { onSubmit: createEmailMutation.mutateAsync, isSubmitting: !!createEmailMutation.isPending }), isLoading && _jsx("div", { className: 'text-muted-foreground', children: "Loading emails\u2026" }), isError && !isLoading && (_jsx("div", { className: 'rounded border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive', children: error instanceof Error ? error.message : 'Unable to load emails' })), data?.emails?.length ? (_jsx("div", { className: 'grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3', children: data.emails.map((email) => (_jsx(EmailCard, { email: email, onDelete: () => deleteMutation.mutateAsync(email.user), onQuotaChange: (quota) => quotaMutation.mutateAsync({ email: email.user, quota }), onPasswordChange: (password, confirm) => passwordMutation.mutateAsync({ email: email.user, password, passwordConfirm: confirm }) }, email.user))) })) : null] })] }));
21
+ return (_jsxs("div", { className: 'bg-white dark:bg-slate-900', children: [_jsx("div", { className: 'bg-linear-to-r from-sky-200 via-emerald-300 to-blue-600 p-8 font-extrabold text-foreground dark:from-blue-800 dark:via-amber-700 dark:to-rose-900', children: _jsx("h1", { className: 'text-3xl', children: t('email_accounts') }) }), _jsxs("div", { className: 'flex flex-col gap-3 p-4', children: [_jsx(CreateEmailForm, { onSubmit: createEmailMutation.mutateAsync, isSubmitting: !!createEmailMutation.isPending }), isLoading && _jsx("div", { className: 'text-muted-foreground', children: "Loading emails\u2026" }), isError && !isLoading && (_jsx("div", { className: 'rounded border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive', children: error instanceof Error ? error.message : 'Unable to load emails' })), data?.emails?.length ? (_jsx("div", { className: 'grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3', children: data.emails.map((email) => (_jsx(EmailCard, { email: email, onDelete: () => deleteMutation.mutateAsync(email.user), onQuotaChange: (quota) => quotaMutation.mutateAsync({ email: email.user, quota }), onPasswordChange: (password, confirm) => passwordMutation.mutateAsync({ email: email.user, password, passwordConfirm: confirm }) }, email.user))) })) : null] })] }));
21
22
  };
22
23
  const CreateEmailForm = ({ onSubmit, isSubmitting, }) => {
23
24
  const [email, setEmail] = useState('');
24
25
  const [password, setPassword] = useState('');
25
26
  const [quota, setQuota] = useState('1024');
27
+ const t = useI18n();
26
28
  return (_jsxs("form", { className: 'rounded-lg border bg-card p-4 text-card-foreground shadow-sm', onSubmit: async (e) => {
27
29
  e.preventDefault();
28
30
  await onSubmit({ email, password, quota });
29
31
  setEmail('');
30
32
  setPassword('');
31
- }, children: [_jsx("div", { className: 'text-lg font-semibold', children: getString('create_new_email_account') }), _jsxs("div", { className: 'mt-3 grid grid-cols-1 gap-3 md:grid-cols-3', children: [_jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: email, onChange: (e) => setEmail(e.target.value), placeholder: 'email', required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', type: 'password', value: password, onChange: (e) => setPassword(e.target.value), placeholder: 'password', required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: quota, onChange: (e) => setQuota(e.target.value), placeholder: 'quota', required: true })] }), _jsx("button", { type: 'submit', disabled: isSubmitting, className: 'mt-3 inline-flex items-center justify-center rounded bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground shadow-sm hover:opacity-90 disabled:opacity-50', children: isSubmitting ? 'Saving…' : getString('create') })] }));
33
+ }, children: [_jsx("div", { className: 'text-lg font-semibold', children: t('create_new_email_account') }), _jsxs("div", { className: 'mt-3 grid grid-cols-1 gap-3 md:grid-cols-3', children: [_jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: email, onChange: (e) => setEmail(e.target.value), placeholder: t('email'), required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', type: 'password', value: password, onChange: (e) => setPassword(e.target.value), placeholder: t('password'), required: true }), _jsx("input", { className: 'rounded border px-3 py-2 text-sm', value: quota, onChange: (e) => setQuota(e.target.value), placeholder: t('quota'), required: true })] }), _jsx("button", { type: 'submit', disabled: isSubmitting, className: 'mt-3 inline-flex items-center justify-center rounded bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground shadow-sm hover:opacity-90 disabled:opacity-50', children: isSubmitting ? t('saving') + '…' : t('create') })] }));
32
34
  };
33
35
  const EmailCard = ({ email, onDelete, onQuotaChange, onPasswordChange, }) => {
34
36
  const [quota, setQuota] = useState(email.diskquota);
35
37
  const [password, setPassword] = useState('');
36
38
  const [confirm, setConfirm] = useState('');
37
- return (_jsxs("div", { className: 'rounded-lg border bg-card p-4 text-card-foreground shadow-sm', children: [_jsxs("div", { className: 'flex items-center justify-between', children: [_jsx("div", { className: 'font-semibold', children: email.user }), _jsx("button", { className: 'text-sm text-destructive hover:underline', type: 'button', onClick: () => onDelete(), children: getString('delete') })] }), _jsxs("div", { className: 'mt-2 text-sm text-muted-foreground', children: [_jsxs("div", { children: ["Disk Used: ", email.diskusedpercent, " / ", email.diskquota] }), _jsxs("div", { children: ["Login: ", email.user] })] }), _jsxs("div", { className: 'mt-3 space-y-2 text-sm', children: [_jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-xs text-muted-foreground', children: "Quota" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', value: quota, onChange: (e) => setQuota(e.target.value) }), _jsx("button", { type: 'button', className: 'mt-1 inline-flex items-center justify-center rounded bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground hover:opacity-90', onClick: () => onQuotaChange(quota), children: getString('update') })] }), _jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-xs text-muted-foreground', children: "Password" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', type: 'password', value: password, onChange: (e) => setPassword(e.target.value) })] }), _jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-xs text-muted-foreground', children: "Confirm" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', type: 'password', value: confirm, onChange: (e) => setConfirm(e.target.value) })] }), _jsx("button", { type: 'button', className: 'inline-flex items-center justify-center rounded bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground hover:opacity-90', onClick: () => onPasswordChange(password, confirm), children: getString('updatePassword') })] })] }));
39
+ const t = useI18n();
40
+ return (_jsxs("div", { className: 'rounded-lg border bg-card p-4 text-card-foreground shadow-sm', children: [_jsxs("div", { className: 'flex items-center justify-between', children: [_jsx("div", { className: 'font-semibold', children: email.user }), _jsx("button", { className: 'text-sm text-destructive hover:underline', type: 'button', onClick: () => onDelete(), children: t('delete') })] }), _jsxs("div", { className: 'mt-2 text-sm text-muted-foreground', children: [_jsxs("div", { children: ["Disk Used: ", email.diskusedpercent, " / ", email.diskquota] }), _jsxs("div", { children: ["Login: ", email.user] })] }), _jsxs("div", { className: 'mt-3 space-y-2 text-sm', children: [_jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-xs text-muted-foreground', children: "Quota" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', value: quota, onChange: (e) => setQuota(e.target.value) }), _jsx("button", { type: 'button', className: 'mt-1 inline-flex items-center justify-center rounded bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground hover:opacity-90', onClick: () => onQuotaChange(quota), children: t('update') })] }), _jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-xs text-muted-foreground', children: "Password" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', type: 'password', value: password, onChange: (e) => setPassword(e.target.value) })] }), _jsxs("label", { className: 'block', children: [_jsx("span", { className: 'text-xs text-muted-foreground', children: "Confirm" }), _jsx("input", { className: 'mt-1 w-full rounded border px-3 py-2', type: 'password', value: confirm, onChange: (e) => setConfirm(e.target.value) })] }), _jsx("button", { type: 'button', className: 'inline-flex items-center justify-center rounded bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground hover:opacity-90', onClick: () => onPasswordChange(password, confirm), children: t('updatePassword') })] })] }));
38
41
  };
39
42
  export default CpanelEmailsPage;
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;gBAmDf,CAAR;iBACI,CADwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuHlC,CAAA"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;gBAkDf,CAAf;iBAA2B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwH3B,CAAA"}
package/dist/router.js CHANGED
@@ -8,7 +8,7 @@ export const cpanelEmailsRouter = router({
8
8
  if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
9
9
  throw new TRPCError({
10
10
  code: 'BAD_REQUEST',
11
- message: getString('cpanelCredentialsNotSet'),
11
+ message: getString('cpanelCredentialsNotSet', ctx.session.user.locale),
12
12
  });
13
13
  }
14
14
  const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
@@ -34,7 +34,7 @@ export const cpanelEmailsRouter = router({
34
34
  if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
35
35
  throw new TRPCError({
36
36
  code: 'BAD_REQUEST',
37
- message: getString('cpanelCredentialsNotSet'),
37
+ message: getString('cpanelCredentialsNotSet', ctx.session.user.locale),
38
38
  });
39
39
  }
40
40
  const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
@@ -61,7 +61,7 @@ export const cpanelEmailsRouter = router({
61
61
  if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
62
62
  throw new TRPCError({
63
63
  code: 'BAD_REQUEST',
64
- message: getString('cpanelCredentialsNotSet'),
64
+ message: getString('cpanelCredentialsNotSet', ctx.session.user.locale),
65
65
  });
66
66
  }
67
67
  const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
@@ -88,13 +88,13 @@ export const cpanelEmailsRouter = router({
88
88
  if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
89
89
  throw new TRPCError({
90
90
  code: 'BAD_REQUEST',
91
- message: getString('cpanelCredentialsNotSet'),
91
+ message: getString('cpanelCredentialsNotSet', ctx.session.user.locale),
92
92
  });
93
93
  }
94
94
  if (input.password !== input.passwordConfirm) {
95
95
  throw new TRPCError({
96
96
  code: 'BAD_REQUEST',
97
- message: getString('passwordsDoNotMatch'),
97
+ message: getString('passwordsDoNotMatch', ctx.session.user.locale),
98
98
  });
99
99
  }
100
100
  const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
@@ -117,7 +117,7 @@ export const cpanelEmailsRouter = router({
117
117
  if (!process.env.CPANEL_USER || !process.env.CPANEL_PASSWORD || !process.env.CPANEL_DOMAIN) {
118
118
  throw new TRPCError({
119
119
  code: 'BAD_REQUEST',
120
- message: getString('cpanelCredentialsNotSet'),
120
+ message: getString('cpanelCredentialsNotSet', ctx.session.user.locale),
121
121
  });
122
122
  }
123
123
  const cPanel = new CpanelAPI(process.env.CPANEL_USER, process.env.CPANEL_PASSWORD, `cpanel.${process.env.CPANEL_DOMAIN}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextjs-cms-plugins/cpanel-emails",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "peerDependencies": {
27
27
  "react": "19.0.0",
28
28
  "react-dom": "19.0.0",
29
- "nextjs-cms": "0.5.91"
29
+ "nextjs-cms": "0.5.93"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/react": "~19.0.0",