create-nextjs-cms 0.9.5 → 0.9.7

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 (26) hide show
  1. package/dist/helpers/check-directory.d.ts +1 -0
  2. package/dist/helpers/check-directory.d.ts.map +1 -1
  3. package/dist/helpers/check-directory.js +98 -23
  4. package/dist/index.js +13 -8
  5. package/dist/lib/create-project.js +1 -1
  6. package/package.json +3 -3
  7. package/templates/default/app/(auth)/auth-language-provider.tsx +34 -34
  8. package/templates/default/components/AnalyticsPage.tsx +22 -6
  9. package/templates/default/components/CategorySectionSelectInput.tsx +2 -2
  10. package/templates/default/components/form/Form.tsx +12 -2
  11. package/templates/default/components/form/FormInputs.tsx +25 -16
  12. package/templates/default/components/form/inputs/DateFormInput.tsx +110 -53
  13. package/templates/default/components/form/inputs/DateRangeFormInput.tsx +175 -0
  14. package/templates/default/components/form/inputs/TagsFormInput.tsx +6 -5
  15. package/templates/default/next-env.d.ts +1 -1
  16. package/templates/default/package.json +3 -3
  17. package/templates/default/proxy.ts +2 -2
  18. package/templates/default/app/(rootLayout)/dashboard-new/page.tsx +0 -7
  19. package/templates/default/components/DashboardNewPage.tsx +0 -253
  20. package/templates/default/components/DashboardPage.tsx +0 -188
  21. package/templates/default/components/EmailCard.tsx +0 -138
  22. package/templates/default/components/EmailPasswordForm.tsx +0 -85
  23. package/templates/default/components/EmailQuotaForm.tsx +0 -73
  24. package/templates/default/components/EmailsPage.tsx +0 -49
  25. package/templates/default/components/NewEmailForm.tsx +0 -132
  26. package/templates/default/components/form/DateRangeFormInput.tsx +0 -57
@@ -1,73 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import React from 'react'
3
- import useModal from '@/hooks/useModal'
4
- import { Badge } from '@/components/ui/badge'
5
- import { useToast } from '@/components/ui/use-toast'
6
- import InfoCard from '@/components/InfoCard'
7
- import { trpc } from '@/app/_trpc/client'
8
-
9
- export default function EmailQuotaForm({ email, action }: { email: string; action: any }) {
10
- const t = useI18n()
11
- const { setModal, modal, modalResponse, setModalResponse } = useModal()
12
- const { toast } = useToast()
13
-
14
- const quotaMutation = trpc.cpanelEmails.quotaChange.useMutation({
15
- onError: (error) => {
16
- setModal({
17
- title: t('error'),
18
- body: (
19
- <div className='p-4'>
20
- <InfoCard result={{ key: 'danger', title: error.message, status: false }} />
21
- </div>
22
- ),
23
- headerColor: 'bg-red-700',
24
- titleColor: 'text-white',
25
- lang: 'en',
26
- })
27
- },
28
- onSuccess: (data) => {
29
- action()
30
- setModal(null)
31
- setModalResponse(null)
32
- toast({
33
- variant: 'success',
34
- title: t('success'),
35
- })
36
- },
37
- })
38
- const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
39
- e.preventDefault()
40
- quotaMutation.mutate({
41
- email,
42
- quota: e.currentTarget.quota.value,
43
- })
44
- }
45
-
46
- return (
47
- <form onSubmit={handleSubmit} className='flex flex-col gap-2'>
48
- <div>
49
- <label htmlFor='quota' className='block text-sm font-medium leading-6 text-foreground'>
50
- {t('emailQuota')}
51
- </label>
52
- <div className=''>
53
- <input
54
- id='quota'
55
- name='quota'
56
- type='number'
57
- autoComplete='quota'
58
- required
59
- className='block rounded-md border-0 bg-input p-2.5 text-foreground shadow-xs outline-0 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6'
60
- />
61
- <Badge className='rounded-sm border-muted-foreground text-muted-foreground' variant='secondary'>
62
- 0 = {t('unlimited')}
63
- </Badge>
64
- </div>
65
- </div>
66
- <div className='mt-4'>
67
- <button className='rounded bg-blue-700 px-2 py-1 font-bold text-white'>
68
- {t('updateQuota')}
69
- </button>
70
- </div>
71
- </form>
72
- )
73
- }
@@ -1,49 +0,0 @@
1
- 'use client'
2
-
3
- import { useEffect } from 'react'
4
- import { EmailItem } from 'nextjs-cms/core/types'
5
- import { useI18n } from 'nextjs-cms/translations/client'
6
- import ContainerBox from '@/components/ContainerBox'
7
- import NewEmailForm from '@/components/NewEmailForm'
8
- import EmailCard from '@/components/EmailCard'
9
- import { trpc } from '@/app/_trpc/client'
10
-
11
- const EmailsPage = () => {
12
- const t = useI18n()
13
- const controller = new AbortController()
14
-
15
- const { isLoading, isError, data, error, refetch } = trpc.cpanelEmails.getEmails.useQuery()
16
-
17
- useEffect(() => {
18
- return () => {
19
- controller.abort()
20
- }
21
- }, [])
22
-
23
- return (
24
- <div className='bg-white dark:bg-slate-900'>
25
- <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'>
26
- <h1 className='text-3xl'>{t('emailAccounts')}</h1>
27
- </div>
28
-
29
- <div className='flex flex-col gap-2 p-4'>
30
- <ContainerBox title={t('createNewEmailAccount')}>
31
- <NewEmailForm action={() => refetch()} />
32
- </ContainerBox>
33
-
34
- {isLoading && <div>{t('loading')}</div>}
35
- {data && data.emails && data.emails.length > 0 && (
36
- <ContainerBox title={t('emailAccountsList')}>
37
- <div className='mt-2 grid w-full grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3'>
38
- {data.emails.map((email: EmailItem) => (
39
- <EmailCard key={email.user} action={() => refetch()} email={email} />
40
- ))}
41
- </div>
42
- </ContainerBox>
43
- )}
44
- </div>
45
- </div>
46
- )
47
- }
48
-
49
- export default EmailsPage
@@ -1,132 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import React from 'react'
3
- import useModal from '@/hooks/useModal'
4
- import { Badge } from '@/components/ui/badge'
5
- import { useToast } from '@/components/ui/use-toast'
6
- import InfoCard from '@/components/InfoCard'
7
- import { trpc } from '@/app/_trpc/client'
8
-
9
- export default function NewEmailForm({ action }: { action: any }) {
10
- const t = useI18n()
11
- const { setModal, modal, modalResponse, setModalResponse } = useModal()
12
- const formRef = React.useRef<HTMLFormElement>(null)
13
- const { toast } = useToast()
14
- const newEmailMutation = trpc.cpanelEmails.createEmail.useMutation({
15
- onError: (error) => {
16
- setModal({
17
- title: t('error'),
18
- body: (
19
- <div className='p-4'>
20
- <InfoCard result={{ key: 'danger', title: error.message, status: false }} />
21
- </div>
22
- ),
23
- headerColor: 'bg-red-700',
24
- titleColor: 'text-white',
25
- lang: 'en',
26
- })
27
- },
28
- onSuccess: (data) => {
29
- action()
30
- toast({
31
- variant: 'success',
32
- title: t('success'),
33
- description: data.message,
34
- })
35
-
36
- // Empty the form
37
- if (formRef.current) {
38
- formRef.current.reset()
39
- }
40
- },
41
- })
42
- const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
43
- e.preventDefault()
44
- newEmailMutation.mutate({
45
- email: e.currentTarget.username.value,
46
- password: e.currentTarget.password.value,
47
- quota: e.currentTarget.quota.value,
48
- })
49
-
50
- /*const data = new FormData(e.currentTarget)
51
- const values = Object.fromEntries(data.entries())
52
- values.operationType = 'newEmail'
53
- const response = await handleEmailSubmission(values, axiosPrivate, controller)
54
- if (response.error) {
55
- setModal({
56
- title: t('error'),
57
- body: (
58
- <div className='p-4'>
59
- <InfoCard result={{ key: 'danger', title: response.error.message, status: false }} />
60
- </div>
61
- ),
62
- headerColor: 'bg-red-700',
63
- titleColor: 'text-white',
64
- lang: 'en',
65
- })
66
- } else if (response.code === 200) {
67
- action()
68
- toast({
69
- variant: 'success',
70
- title: t('success'),
71
- description: response.message,
72
- })
73
- }*/
74
- }
75
-
76
- return (
77
- <form ref={formRef} onSubmit={handleSubmit} className='flex flex-col gap-2'>
78
- <div>
79
- <label htmlFor='username' className='block text-sm font-medium leading-6 text-foreground'>
80
- {t('email')}
81
- </label>
82
- <div className=''>
83
- <input
84
- id='username'
85
- name='username'
86
- type='text'
87
- autoComplete='username'
88
- required
89
- className='block w-full rounded-md border-0 bg-input p-2.5 text-foreground shadow-xs outline-0 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6'
90
- />
91
- </div>
92
- </div>
93
-
94
- <div>
95
- <label htmlFor='password' className='block text-sm font-medium leading-6 text-foreground'>
96
- {t('password')}
97
- </label>
98
- <div className=''>
99
- <input
100
- id='password'
101
- name='password'
102
- type='text'
103
- autoComplete='password'
104
- required
105
- className='block w-full rounded-md border-0 bg-input p-2.5 text-foreground shadow-xs outline-0 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6'
106
- />
107
- </div>
108
- </div>
109
- <div>
110
- <label htmlFor='quota' className='block text-sm font-medium leading-6 text-foreground'>
111
- {t('emailQuota')}
112
- </label>
113
- <div className=''>
114
- <input
115
- id='quota'
116
- name='quota'
117
- type='number'
118
- autoComplete='quota'
119
- required
120
- className='block rounded-md border-0 bg-input p-2.5 text-foreground shadow-xs outline-0 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6'
121
- />
122
- <Badge className='rounded-sm border-muted-foreground text-muted-foreground' variant='secondary'>
123
- 0 = {t('unlimited')}
124
- </Badge>
125
- </div>
126
- </div>
127
- <div className='mt-4'>
128
- <button className='rounded bg-blue-700 px-2 py-1 font-bold text-white'>{t('create')}</button>
129
- </div>
130
- </form>
131
- )
132
- }
@@ -1,57 +0,0 @@
1
- 'use client'
2
-
3
- import * as React from 'react'
4
- import dayjs from 'dayjs'
5
- import type { DateRange } from 'react-day-picker'
6
-
7
- import { cn } from '@/lib/utils'
8
- import { Button } from '@/components/ui/button'
9
- import { Calendar } from '@/components/ui/calendar'
10
- import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
11
- import { CalendarIcon } from '@radix-ui/react-icons'
12
-
13
- export function DatePickerWithRange({ className }: React.HTMLAttributes<HTMLDivElement>) {
14
- const [date, setDate] = React.useState<DateRange | undefined>({
15
- from: new Date(2020, 0, 20),
16
- to: dayjs(new Date(2023, 0, 20))
17
- .add(20, 'day')
18
- .toDate(),
19
- })
20
-
21
- return (
22
- <div className={cn('grid gap-2', className)}>
23
- <Popover>
24
- <PopoverTrigger asChild>
25
- <Button
26
- id='date'
27
- variant={'outline'}
28
- className={cn('justify-start text-left font-normal', !date && 'text-muted-foreground')}
29
- >
30
- <CalendarIcon className='mr-2 h-4 w-4' />
31
- {date?.from ? (
32
- date.to ? (
33
- <>
34
- {dayjs(date.from).format('MMM DD, YYYY')} - {dayjs(date.to).format('MMM DD, YYYY')}
35
- </>
36
- ) : (
37
- dayjs(date.from).format('MMM DD, YYYY')
38
- )
39
- ) : (
40
- <span>Pick a date</span>
41
- )}
42
- </Button>
43
- </PopoverTrigger>
44
- <PopoverContent className='w-auto p-0' align='start'>
45
- <Calendar
46
- autoFocus
47
- mode='range'
48
- defaultMonth={date?.from}
49
- selected={date}
50
- onSelect={setDate}
51
- numberOfMonths={2}
52
- />
53
- </PopoverContent>
54
- </Popover>
55
- </div>
56
- )
57
- }