create-nextjs-cms 0.9.22 → 0.9.24

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 (127) hide show
  1. package/package.json +3 -3
  2. package/templates/default/app/(auth)/auth/login/LoginPage.tsx +2 -2
  3. package/templates/default/app/(auth)/layout.tsx +1 -1
  4. package/templates/default/app/(rootLayout)/(plugins)/[...slug]/page.tsx +47 -40
  5. package/templates/default/app/(rootLayout)/(plugins)/[...slug]/plugin-server-registry.ts +16 -16
  6. package/templates/default/app/(rootLayout)/admins/page.tsx +2 -2
  7. package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +2 -2
  8. package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +2 -2
  9. package/templates/default/app/(rootLayout)/dashboard/page.tsx +10 -3
  10. package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +2 -2
  11. package/templates/default/app/(rootLayout)/layout.tsx +3 -3
  12. package/templates/default/app/(rootLayout)/loading.tsx +1 -1
  13. package/templates/default/app/(rootLayout)/log/page.tsx +1 -1
  14. package/templates/default/app/(rootLayout)/new/[section]/page.tsx +2 -2
  15. package/templates/default/app/(rootLayout)/section/[section]/page.tsx +2 -2
  16. package/templates/default/app/(rootLayout)/settings/page.tsx +2 -2
  17. package/templates/default/app/_trpc/client.tsx +6 -0
  18. package/templates/default/app/_trpc/server.ts +9 -0
  19. package/templates/default/app/_trpc/types.ts +6 -0
  20. package/templates/default/app/api/document/route.ts +1 -1
  21. package/templates/default/app/api/photo/route.ts +1 -1
  22. package/templates/default/app/api/trpc/[trpc]/route.ts +3 -33
  23. package/templates/default/app/api/video/route.ts +1 -1
  24. package/templates/default/app/providers.tsx +20 -152
  25. package/templates/default/cms.config.ts +4 -2
  26. package/templates/default/components/{AdminCard.tsx → admin/admin-card.tsx} +4 -4
  27. package/templates/default/components/{AdminEditPage.tsx → admin/admin-edit-page.tsx} +3 -3
  28. package/templates/default/components/{AdminPrivilegeCard.tsx → admin/admin-privilege-card.tsx} +1 -1
  29. package/templates/default/components/{NewAdminForm.tsx → admin/new-admin-form.tsx} +4 -4
  30. package/templates/default/components/{ContainerBox.tsx → container-box.tsx} +1 -1
  31. package/templates/default/components/{ErrorComponent.tsx → feedback/error-component.tsx} +1 -1
  32. package/templates/default/{context/ModalProvider.tsx → components/feedback/modal-context.tsx} +56 -53
  33. package/templates/default/components/{Modal.tsx → feedback/modal.tsx} +1 -1
  34. package/templates/default/components/form/{FormInputs.tsx → form-inputs.tsx} +17 -17
  35. package/templates/default/components/form/{Form.tsx → form.tsx} +17 -11
  36. package/templates/default/components/form/helpers/_section-hot-reload.js +1 -1
  37. package/templates/default/components/form/inputs/{CheckboxFormInput.tsx → checkbox-form-input.tsx} +1 -1
  38. package/templates/default/components/form/inputs/{ColorFormInput.tsx → color-form-input.tsx} +1 -1
  39. package/templates/default/components/form/inputs/{DateFormInput.tsx → date-form-input.tsx} +1 -1
  40. package/templates/default/components/form/inputs/{DateRangeFormInput.tsx → date-range-form-input.tsx} +1 -1
  41. package/templates/default/components/form/inputs/{DocumentFormInput.tsx → document-form-input.tsx} +3 -3
  42. package/templates/default/components/form/inputs/{MapFormInput.tsx → map-form-input.tsx} +5 -4
  43. package/templates/default/components/form/inputs/{MultipleSelectFormInput.tsx → multiple-select-form-input.tsx} +1 -1
  44. package/templates/default/components/form/inputs/{NumberFormInput.tsx → number-form-input.tsx} +1 -1
  45. package/templates/default/components/form/inputs/{PasswordFormInput.tsx → password-form-input.tsx} +1 -1
  46. package/templates/default/components/form/inputs/{PhotoFormInput.tsx → photo-form-input.tsx} +3 -3
  47. package/templates/default/components/form/inputs/{RichTextFormInput.tsx → rich-text-form-input.tsx} +3 -3
  48. package/templates/default/components/form/inputs/{SelectFormInput.tsx → select-form-input.tsx} +4 -4
  49. package/templates/default/components/form/inputs/{SlugFormInput.tsx → slug-form-input.tsx} +1 -1
  50. package/templates/default/components/form/inputs/{TagsFormInput.tsx → tags-form-input.tsx} +1 -1
  51. package/templates/default/components/form/inputs/{TextFormInput.tsx → text-form-input.tsx} +3 -3
  52. package/templates/default/components/form/inputs/{TextareaFormInput.tsx → textarea-form-input.tsx} +2 -2
  53. package/templates/default/components/form/inputs/{VideoFormInput.tsx → video-form-input.tsx} +3 -3
  54. package/templates/default/components/{Layout.tsx → layout/layout.tsx} +4 -4
  55. package/templates/default/components/{Navbar.tsx → layout/navbar.tsx} +2 -2
  56. package/templates/default/components/{SidebarDropdownItem.tsx → layout/sidebar-dropdown-item.tsx} +1 -1
  57. package/templates/default/components/{SidebarItem.tsx → layout/sidebar-item.tsx} +1 -1
  58. package/templates/default/components/layout/sidebar-plugin-group.tsx +63 -0
  59. package/templates/default/components/{Sidebar.tsx → layout/sidebar.tsx} +28 -3
  60. package/templates/default/components/{LocaleSwitcher.tsx → locale/locale-switcher.tsx} +2 -2
  61. package/templates/default/components/{Dropzone.tsx → media/dropzone.tsx} +1 -1
  62. package/templates/default/components/{GalleryPhoto.tsx → media/gallery-photo.tsx} +2 -2
  63. package/templates/default/components/{PhotoGallery.tsx → media/photo-gallery.tsx} +2 -2
  64. package/templates/default/components/{ProtectedImage.tsx → media/protected-image.tsx} +1 -1
  65. package/templates/default/components/multi-select.tsx +8 -4
  66. package/templates/default/components/{AdminsPage.tsx → pages/admins-page.tsx} +4 -4
  67. package/templates/default/components/{BrowsePage.tsx → pages/browse-page.tsx} +7 -7
  68. package/templates/default/components/{CategorizedSectionPage.tsx → pages/categorized-section-page.tsx} +2 -2
  69. package/templates/default/components/{ItemEditPage.tsx → pages/item-edit-page.tsx} +8 -34
  70. package/templates/default/components/{LogPage.tsx → pages/log-page.tsx} +1 -1
  71. package/templates/default/components/{NewPage.tsx → pages/new-page.tsx} +28 -51
  72. package/templates/default/components/{SectionPage.tsx → pages/section-page.tsx} +7 -7
  73. package/templates/default/components/{SettingsPage.tsx → pages/settings-page.tsx} +4 -4
  74. package/templates/default/components/pagination/{Pagination.tsx → pagination.tsx} +1 -1
  75. package/templates/default/components/{CategoryDeleteConfirmPage.tsx → sections/category-delete-confirm-page.tsx} +4 -4
  76. package/templates/default/components/{CategorySectionSelectInput.tsx → sections/category-section-select-input.tsx} +5 -5
  77. package/templates/default/components/{ConditionalFields.tsx → sections/conditional-fields.tsx} +1 -1
  78. package/templates/default/components/{SectionItemCard.tsx → sections/section-item-card.tsx} +4 -4
  79. package/templates/default/components/{SelectInputButtons.tsx → sections/select-input-buttons.tsx} +4 -4
  80. package/templates/default/dynamic-schemas/schema.ts +44 -2
  81. package/templates/default/env/env.ts +42 -0
  82. package/templates/default/next.config.ts +1 -0
  83. package/templates/default/package.json +2 -1
  84. package/templates/default/app/_trpc/client.ts +0 -3
  85. package/templates/default/components/AnalyticsPage.tsx +0 -144
  86. package/templates/default/components/BarChartBox.tsx +0 -42
  87. package/templates/default/components/NewVariantComponent.tsx +0 -229
  88. package/templates/default/components/PieChartBox.tsx +0 -101
  89. package/templates/default/components/VariantCard.tsx +0 -124
  90. package/templates/default/components/VariantEditPage.tsx +0 -230
  91. package/templates/default/components/analytics/BounceRate.tsx +0 -70
  92. package/templates/default/components/analytics/LivePageViews.tsx +0 -55
  93. package/templates/default/components/analytics/LiveUsersCount.tsx +0 -33
  94. package/templates/default/components/analytics/MonthlyPageViews.tsx +0 -42
  95. package/templates/default/components/analytics/TopCountries.tsx +0 -52
  96. package/templates/default/components/analytics/TopDevices.tsx +0 -46
  97. package/templates/default/components/analytics/TopMediums.tsx +0 -58
  98. package/templates/default/components/analytics/TopSources.tsx +0 -45
  99. package/templates/default/components/analytics/TotalPageViews.tsx +0 -41
  100. package/templates/default/components/analytics/TotalSessions.tsx +0 -41
  101. package/templates/default/components/analytics/TotalUniqueUsers.tsx +0 -41
  102. package/templates/default/components/custom/RightHomeRoomVariantCard.tsx +0 -138
  103. package/templates/default/env/env.js +0 -130
  104. package/templates/default/hooks/useModal.ts +0 -8
  105. package/templates/default/lib/apiHelpers.ts +0 -92
  106. /package/templates/default/components/{dndKit/Draggable.tsx → dnd-kit/draggable.tsx} +0 -0
  107. /package/templates/default/components/{dndKit/Droppable.tsx → dnd-kit/droppable.tsx} +0 -0
  108. /package/templates/default/components/{dndKit/SortableItem.tsx → dnd-kit/sortable-item.tsx} +0 -0
  109. /package/templates/default/components/{InfoCard.tsx → feedback/info-card.tsx} +0 -0
  110. /package/templates/default/components/{LoadingSpinners.tsx → feedback/loading-spinners.tsx} +0 -0
  111. /package/templates/default/components/{ProgressBar.tsx → feedback/progress-bar.tsx} +0 -0
  112. /package/templates/default/components/{TooltipComponent.tsx → feedback/tooltip-component.tsx} +0 -0
  113. /package/templates/default/components/form/{ContentLocaleContext.tsx → content-locale-context.tsx} +0 -0
  114. /package/templates/default/components/form/{FormInputElement.tsx → form-input-element.tsx} +0 -0
  115. /package/templates/default/components/{language-dropdown.tsx → i18n/language-dropdown.tsx} +0 -0
  116. /package/templates/default/components/{language-picker.tsx → i18n/language-picker.tsx} +0 -0
  117. /package/templates/default/components/{login-language-dropdown.tsx → i18n/login-language-dropdown.tsx} +0 -0
  118. /package/templates/default/components/{DefaultNavItems.tsx → layout/default-nav-items.tsx} +0 -0
  119. /package/templates/default/components/{ThemeProvider.tsx → layout/theme-provider.tsx} +0 -0
  120. /package/templates/default/components/{theme-toggle.tsx → layout/theme-toggle.tsx} +0 -0
  121. /package/templates/default/components/{ProtectedDocument.tsx → media/protected-document.tsx} +0 -0
  122. /package/templates/default/components/{ProtectedVideo.tsx → media/protected-video.tsx} +0 -0
  123. /package/templates/default/components/{DashboardPageAlt.tsx → pages/dashboard-page-alt.tsx} +0 -0
  124. /package/templates/default/components/pagination/{PaginationButtons.tsx → pagination-buttons.tsx} +0 -0
  125. /package/templates/default/components/{SectionIcon.tsx → sections/section-icon.tsx} +0 -0
  126. /package/templates/default/components/{SectionItemStatusBadge.tsx → sections/section-item-status-badge.tsx} +0 -0
  127. /package/templates/default/components/{SelectBox.tsx → select-box.tsx} +0 -0
@@ -1,58 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import { BarChartDataItem } from 'nextjs-cms/core/types'
3
- import { Badge } from '@/components/ui/badge'
4
- import { formatNumber } from 'nextjs-cms/utils'
5
- import ContainerBox from '@/components/ContainerBox'
6
- import React, { useEffect } from 'react'
7
- import { useAxiosPrivate } from 'nextjs-cms/auth/hooks'
8
- import { useQuery } from '@tanstack/react-query'
9
- import { getAnalytics } from '@/lib/apiHelpers'
10
- import LoadingSpinners from '@/components/LoadingSpinners'
11
-
12
- export const TopMediums = ({ fromDate, toDate }: { fromDate: Date | string | null; toDate: Date | string | null }) => {
13
- const t = useI18n()
14
- const axiosPrivate = useAxiosPrivate()
15
- let controller = new AbortController()
16
-
17
- const { isLoading, isError, data, error } = useQuery({
18
- queryKey: ['analyticsPage', 'topMediums', fromDate, toDate],
19
- queryFn: () => {
20
- // Abort the previous request
21
- controller.abort()
22
-
23
- // Create a new AbortController for the new request
24
- controller = new AbortController()
25
- return getAnalytics({
26
- requestType: 'topMediums',
27
- axiosPrivate,
28
- controller,
29
- fromDate,
30
- toDate,
31
- })
32
- },
33
- })
34
-
35
- useEffect(() => {
36
- return () => {
37
- controller.abort()
38
- }
39
- }, [])
40
-
41
- return (
42
- <ContainerBox title={t('mediums')}>
43
- <div className='w-full mb-6'>
44
- <h1 className='font-bold border-b pb-1 my-1'>{t('topMediums')}</h1>
45
- {isLoading && <LoadingSpinners single={true} />}
46
- {data?.topMediums?.length > 0 &&
47
- data.topMediums.map((medium: BarChartDataItem, index: number) => (
48
- <div key={`${index}-${medium.name}`} className='w-full text-sm flex justify-between'>
49
- <span className='font-bold text-foreground'>{medium.name}:</span>
50
- <Badge variant='outline' className='ms-2'>
51
- {formatNumber(medium.value)}
52
- </Badge>
53
- </div>
54
- ))}
55
- </div>
56
- </ContainerBox>
57
- )
58
- }
@@ -1,45 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import { BarChartDataItem } from 'nextjs-cms/core/types'
3
- import { Badge } from '@/components/ui/badge'
4
- import { formatNumber } from 'nextjs-cms/utils'
5
- import ContainerBox from '@/components/ContainerBox'
6
- import React from 'react'
7
- import { useAxiosPrivate } from 'nextjs-cms/auth/hooks'
8
- import { useQuery } from '@tanstack/react-query'
9
- import { getAnalytics } from '@/lib/apiHelpers'
10
- import LoadingSpinners from '@/components/LoadingSpinners'
11
-
12
- export const TopSources = ({ fromDate, toDate }: { fromDate: Date | string | null; toDate: Date | string | null }) => {
13
- const t = useI18n()
14
- const axiosPrivate = useAxiosPrivate()
15
- const controller = new AbortController()
16
-
17
- const { isLoading, isError, data, error } = useQuery({
18
- queryKey: ['analyticsPage', 'topSources', fromDate, toDate],
19
- queryFn: () =>
20
- getAnalytics({
21
- requestType: 'topSources',
22
- axiosPrivate,
23
- controller,
24
- fromDate,
25
- toDate,
26
- }),
27
- })
28
- return (
29
- <ContainerBox title={t('sources')}>
30
- <div className='w-full mb-6'>
31
- <h1 className='font-bold border-b pb-1 my-1'>{t('topSources')}</h1>
32
- {isLoading && <LoadingSpinners single={true} />}
33
- {data?.topSources?.length > 0 &&
34
- data.topSources.map((source: BarChartDataItem, index: number) => (
35
- <div key={`${index}-${source.name}`} className='w-full text-sm flex justify-between'>
36
- <span className='font-bold text-foreground'>{source.name}:</span>
37
- <Badge variant='outline' className='ms-2'>
38
- {formatNumber(source.value)}
39
- </Badge>
40
- </div>
41
- ))}
42
- </div>
43
- </ContainerBox>
44
- )
45
- }
@@ -1,41 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import { formatNumber } from 'nextjs-cms/utils'
3
- import ContainerBox from '@/components/ContainerBox'
4
- import React from 'react'
5
- import { useAxiosPrivate } from 'nextjs-cms/auth/hooks'
6
- import { useQuery } from '@tanstack/react-query'
7
- import { getAnalytics } from '@/lib/apiHelpers'
8
- import LoadingSpinners from '@/components/LoadingSpinners'
9
-
10
- export const TotalPageViews = ({
11
- fromDate,
12
- toDate,
13
- }: {
14
- fromDate: Date | string | null
15
- toDate: Date | string | null
16
- }) => {
17
- const t = useI18n()
18
- const axiosPrivate = useAxiosPrivate()
19
- const controller = new AbortController()
20
-
21
- const { isLoading, isError, data, error } = useQuery({
22
- queryKey: ['analyticsPage', 'statistics', fromDate, toDate],
23
- queryFn: () =>
24
- getAnalytics({
25
- requestType: 'statistics',
26
- axiosPrivate,
27
- controller,
28
- fromDate,
29
- toDate,
30
- }),
31
- })
32
- return (
33
- <ContainerBox title={t('totalPageViews')}>
34
- {isLoading ? (
35
- <LoadingSpinners single={true} />
36
- ) : (
37
- <div className='text-4xl'>{formatNumber(data?.totalPageViews)}</div>
38
- )}
39
- </ContainerBox>
40
- )
41
- }
@@ -1,41 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import { formatNumber } from 'nextjs-cms/utils'
3
- import ContainerBox from '@/components/ContainerBox'
4
- import React from 'react'
5
- import { useAxiosPrivate } from 'nextjs-cms/auth/hooks'
6
- import { useQuery } from '@tanstack/react-query'
7
- import { getAnalytics } from '@/lib/apiHelpers'
8
- import LoadingSpinners from '@/components/LoadingSpinners'
9
-
10
- export const TotalSessions = ({
11
- fromDate,
12
- toDate,
13
- }: {
14
- fromDate: Date | string | null
15
- toDate: Date | string | null
16
- }) => {
17
- const t = useI18n()
18
- const axiosPrivate = useAxiosPrivate()
19
- const controller = new AbortController()
20
-
21
- const { isLoading, isError, data, error } = useQuery({
22
- queryKey: ['analyticsPage', 'statistics', fromDate, toDate],
23
- queryFn: () =>
24
- getAnalytics({
25
- requestType: 'statistics',
26
- axiosPrivate,
27
- controller,
28
- fromDate,
29
- toDate,
30
- }),
31
- })
32
- return (
33
- <ContainerBox title={t('totalSessions')}>
34
- {isLoading ? (
35
- <LoadingSpinners single={true} />
36
- ) : (
37
- <div className='text-4xl'>{formatNumber(data?.totalSessions)}</div>
38
- )}
39
- </ContainerBox>
40
- )
41
- }
@@ -1,41 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import { formatNumber } from 'nextjs-cms/utils'
3
- import ContainerBox from '@/components/ContainerBox'
4
- import React from 'react'
5
- import { useAxiosPrivate } from 'nextjs-cms/auth/hooks'
6
- import { useQuery } from '@tanstack/react-query'
7
- import { getAnalytics } from '@/lib/apiHelpers'
8
- import LoadingSpinners from '@/components/LoadingSpinners'
9
-
10
- export const TotalUniqueUsers = ({
11
- fromDate,
12
- toDate,
13
- }: {
14
- fromDate: Date | string | null
15
- toDate: Date | string | null
16
- }) => {
17
- const t = useI18n()
18
- const axiosPrivate = useAxiosPrivate()
19
- const controller = new AbortController()
20
-
21
- const { isLoading, isError, data, error } = useQuery({
22
- queryKey: ['analyticsPage', 'statistics', fromDate, toDate],
23
- queryFn: () =>
24
- getAnalytics({
25
- requestType: 'statistics',
26
- axiosPrivate,
27
- controller,
28
- fromDate,
29
- toDate,
30
- }),
31
- })
32
- return (
33
- <ContainerBox title={t('totalUniqueUsers')}>
34
- {isLoading ? (
35
- <LoadingSpinners single={true} />
36
- ) : (
37
- <div className='text-4xl'>{formatNumber(data?.totalUniqueUsers)}</div>
38
- )}
39
- </ContainerBox>
40
- )
41
- }
@@ -1,138 +0,0 @@
1
- import { useI18n } from 'nextjs-cms/translations/client'
2
- import ContainerBox from '@/components/ContainerBox'
3
- import React from 'react'
4
- import { Variant } from 'nextjs-cms/core/types'
5
- import useModal from '@/hooks/useModal'
6
- import { useAxiosPrivate } from 'nextjs-cms/auth/hooks'
7
- import { handleVariantDeletion } from '@/lib/apiHelpers'
8
- import { useToast } from '@/components/ui/use-toast'
9
- import { Button } from '@/components/ui/button'
10
- import VariantEditPage from '@/components/VariantEditPage'
11
-
12
- const RightHomeRoomVariantCard = ({
13
- variant,
14
- variantItem,
15
- sectionItemId,
16
- action,
17
- }: {
18
- variant: Variant
19
- variantItem: any
20
- sectionItemId: string
21
- action: any
22
- }) => {
23
- const t = useI18n()
24
- const { setModal, modal, modalResponse, setModalResponse } = useModal()
25
- const axiosPrivate = useAxiosPrivate()
26
- const controller = new AbortController()
27
- const { toast } = useToast()
28
-
29
- const handleDelete = async () => {
30
- const response = await handleVariantDeletion(variant.variant_name, variantItem.id, axiosPrivate, controller)
31
- if (response.error) {
32
- toast({
33
- variant: 'destructive',
34
- title: t('deleteAdmin'),
35
- description: response.error.message,
36
- })
37
- } else if (response.code === 200) {
38
- action ? action() : null
39
- setModal(null)
40
- setModalResponse(null)
41
- toast({
42
- variant: 'success',
43
- title: t('itemDeletedSuccessfully'),
44
- description: response.message,
45
- })
46
- }
47
- }
48
- return (
49
- <ContainerBox title={variantItem.display_name} key={variantItem.id}>
50
- <div className='flex flex-col gap-4'>
51
- <div className='flex flex-col gap-1'>
52
- <div className='flex justify-between'>
53
- <span className='font-bold'>Size From:</span>
54
- <span>{variantItem.size_from}</span>
55
- </div>
56
- <div className='flex justify-between'>
57
- <span className='font-bold'>Size To:</span>
58
- <span>{variantItem.size_to}</span>
59
- </div>
60
- <div className='flex justify-between'>
61
- <span className='font-bold'>Price:</span>
62
- <span>{variantItem.price}</span>
63
- </div>
64
- </div>
65
- <div className='flex flex-row gap-2'>
66
- <Button
67
- size='sm'
68
- type='button'
69
- variant='default'
70
- onClick={() => {
71
- setModal({
72
- size: 'lg',
73
- title: t('edit'),
74
- body: (
75
- <div className='p-4'>
76
- <VariantEditPage
77
- section={variant.section_name}
78
- variant={variant.variant_name}
79
- sectionItemId={sectionItemId}
80
- itemId={variantItem.id}
81
- action={action}
82
- />
83
- </div>
84
- ),
85
- headerColor: 'bg-sky-700',
86
- titleColor: 'text-white',
87
- lang: 'en',
88
- })
89
- }}
90
- >
91
- {t('edit')}
92
- </Button>
93
- {/* Delete Button */}
94
- <Button
95
- size='sm'
96
- type='button'
97
- variant='destructive'
98
- onClick={() => {
99
- setModal({
100
- title: t('delete'),
101
- body: (
102
- <div className='p-4'>
103
- <div className='flex flex-col gap-4'>
104
- <div>{t('deleteItemText')}</div>
105
- <div className='flex gap-2'>
106
- <button
107
- className='rounded bg-green-600 px-2 py-1 text-white'
108
- onClick={handleDelete}
109
- >
110
- Yes
111
- </button>
112
- <button
113
- className='rounded bg-red-800 px-2 py-1 text-white'
114
- onClick={() => {
115
- setModal(null)
116
- }}
117
- >
118
- No
119
- </button>
120
- </div>
121
- </div>
122
- </div>
123
- ),
124
- headerColor: 'bg-red-700',
125
- titleColor: 'text-white',
126
- lang: 'en',
127
- })
128
- }}
129
- >
130
- {t('delete')}
131
- </Button>
132
- </div>
133
- </div>
134
- </ContainerBox>
135
- )
136
- }
137
-
138
- export default RightHomeRoomVariantCard
@@ -1,130 +0,0 @@
1
- import * as z from 'zod'
2
- import { object } from 'zod';
3
-
4
- function createEnv$1(opts) {
5
- const runtimeEnv = opts.runtimeEnvStrict ?? opts.runtimeEnv ?? process.env;
6
- const emptyStringAsUndefined = opts.emptyStringAsUndefined ?? false;
7
- if (emptyStringAsUndefined) {
8
- for (const [key, value] of Object.entries(runtimeEnv)){
9
- if (value === "") {
10
- delete runtimeEnv[key];
11
- }
12
- }
13
- }
14
- const skip = !!opts.skipValidation;
15
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
16
- if (skip) return runtimeEnv;
17
- const _client = typeof opts.client === "object" ? opts.client : {};
18
- const _server = typeof opts.server === "object" ? opts.server : {};
19
- const _shared = typeof opts.shared === "object" ? opts.shared : {};
20
- const client = object(_client);
21
- const server = object(_server);
22
- const shared = object(_shared);
23
- const isServer = opts.isServer ?? (typeof window === "undefined" || "Deno" in window);
24
- const allClient = client.merge(shared);
25
- const allServer = server.merge(shared).merge(client);
26
- const parsed = isServer ? allServer.safeParse(runtimeEnv) // on server we can validate all env vars
27
- : allClient.safeParse(runtimeEnv); // on client we can only validate the ones that are exposed
28
- const onValidationError = opts.onValidationError ?? ((error)=>{
29
- console.error("❌ Invalid environment variables:", error.flatten().fieldErrors);
30
- throw new Error("Invalid environment variables");
31
- });
32
- const onInvalidAccess = opts.onInvalidAccess ?? ((_variable)=>{
33
- throw new Error("❌ Attempted to access a server-side environment variable on the client");
34
- });
35
- if (parsed.success === false) {
36
- return onValidationError(parsed.error);
37
- }
38
- const isServerAccess = (prop)=>{
39
- if (!opts.clientPrefix) return true;
40
- return !prop.startsWith(opts.clientPrefix) && !(prop in shared.shape);
41
- };
42
- const isValidServerAccess = (prop)=>{
43
- return isServer || !isServerAccess(prop);
44
- };
45
- const ignoreProp = (prop)=>{
46
- return prop === "__esModule" || prop === "$$typeof";
47
- };
48
- const extendedObj = (opts.extends ?? []).reduce((acc, curr)=>{
49
- return Object.assign(acc, curr);
50
- }, {});
51
- const fullObj = Object.assign(parsed.data, extendedObj);
52
- const env = new Proxy(fullObj, {
53
- get (target, prop) {
54
- if (typeof prop !== "string") return undefined;
55
- if (ignoreProp(prop)) return undefined;
56
- if (!isValidServerAccess(prop)) return onInvalidAccess(prop);
57
- return Reflect.get(target, prop);
58
- }
59
- });
60
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
61
- return env;
62
- }
63
-
64
- const CLIENT_PREFIX = "NEXT_PUBLIC_";
65
- function createEnv(opts) {
66
- const client = typeof opts.client === "object" ? opts.client : {};
67
- const server = typeof opts.server === "object" ? opts.server : {};
68
- const shared = opts.shared;
69
- const runtimeEnv = opts.runtimeEnv ? opts.runtimeEnv : {
70
- ...process.env,
71
- ...opts.experimental__runtimeEnv
72
- };
73
- return createEnv$1({
74
- ...opts,
75
- shared,
76
- client,
77
- server,
78
- clientPrefix: CLIENT_PREFIX,
79
- runtimeEnv
80
- });
81
- }
82
-
83
- export const env = createEnv({
84
- /**
85
- * Specify your server-side environment variables schema here. This way you can ensure the app
86
- * isn't built with invalid env vars.
87
- */
88
- server: {
89
- ACCESS_TOKEN_SECRET: z.string(),
90
- REFRESH_TOKEN_SECRET: z.string(),
91
- CSRF_TOKEN_SECRET: z.string(),
92
- ACCESS_TOKEN_EXPIRATION: z.string(),
93
- REFRESH_TOKEN_EXPIRATION: z.string(),
94
- NODE_ENV: z
95
- .enum(["development", "test", "production"])
96
- .default("development"),
97
- },
98
-
99
- /**
100
- * Specify your client-side environment variables schema here. This way you can ensure the app
101
- * isn't built with invalid env vars. To expose them to the client, prefix them with
102
- * `NEXT_PUBLIC_`.
103
- */
104
- client: {
105
- NEXT_PUBLIC_RICHTEXT_INLINE_PUBLIC_URL: z.string().optional(),
106
- },
107
-
108
- /**
109
- * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
110
- * middlewares) or client-side so we need to destruct manually.
111
- */
112
- runtimeEnv: {
113
- ACCESS_TOKEN_SECRET: process.env.ACCESS_TOKEN_SECRET,
114
- REFRESH_TOKEN_SECRET: process.env.REFRESH_TOKEN_SECRET,
115
- CSRF_TOKEN_SECRET: process.env.CSRF_TOKEN_SECRET,
116
- ACCESS_TOKEN_EXPIRATION: process.env.ACCESS_TOKEN_EXPIRATION,
117
- REFRESH_TOKEN_EXPIRATION: process.env.REFRESH_TOKEN_EXPIRATION,
118
- NODE_ENV: process.env.NODE_ENV,
119
- },
120
- /**
121
- * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
122
- * useful for Docker builds.
123
- */
124
- skipValidation: !!process.env.SKIP_ENV_VALIDATION,
125
- /**
126
- * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
127
- * `SOME_VAR=''` will throw an error.
128
- */
129
- emptyStringAsUndefined: true,
130
- });
@@ -1,8 +0,0 @@
1
- import { useContext } from 'react'
2
- import ModalContext from '@/context/ModalProvider'
3
-
4
- const useModal = () => {
5
- return useContext(ModalContext)
6
- }
7
-
8
- export default useModal
@@ -1,92 +0,0 @@
1
- import type { AxiosInstance } from 'axios';
2
- import type { AxiosError } from 'axios'
3
- import type { AdminDetails, NewVariantPageRequestResponse, VariantEditPageRequestResponse } from 'nextjs-cms/core/types'
4
-
5
- export const handleVariantDeletion = async (
6
- variant: string,
7
- id: string,
8
- axiosPrivate: AxiosInstance,
9
- controller?: AbortController,
10
- ): Promise<any> => {
11
- try {
12
- const res = await axiosPrivate.post(
13
- `/api-variant-delete`,
14
- { variant: variant, id: id },
15
- {
16
- signal: controller?.signal,
17
- headers: {
18
- 'Content-Type': 'application/x-www-form-urlencoded',
19
- },
20
- },
21
- )
22
- return res.data
23
- } catch (error: AxiosError | any) {
24
- return error?.response?.data
25
- }
26
- }
27
-
28
- export async function getNewVariantPage(
29
- section: string,
30
- variant: string,
31
- axiosPrivate: AxiosInstance,
32
- controller?: AbortController,
33
- ): Promise<NewVariantPageRequestResponse | null> {
34
- try {
35
- const res = await axiosPrivate.get(`/api-variant-new?section=${section}&variant=${variant}`, {
36
- signal: controller?.signal,
37
- })
38
- return res.data
39
- } catch (error) {
40
- return null
41
- }
42
- }
43
-
44
- export async function getVariantPage(
45
- section: string,
46
- variant: string,
47
- sectionItemId: string,
48
- id: string,
49
- axiosPrivate: AxiosInstance,
50
- controller?: AbortController,
51
- ): Promise<VariantEditPageRequestResponse | null> {
52
- try {
53
- const res = await axiosPrivate.get(
54
- `/api-variant-edit?section=${section}&variant=${variant}&sectionItemId=${sectionItemId}&id=${id}`,
55
- {
56
- signal: controller?.signal,
57
- },
58
- )
59
- return res.data
60
- } catch (error: AxiosError | any) {
61
- return error.response.data
62
- }
63
- }
64
-
65
- export const getAnalytics = async ({
66
- requestType,
67
- axiosPrivate,
68
- controller,
69
- fromDate,
70
- toDate,
71
- }: {
72
- requestType: string
73
- axiosPrivate: AxiosInstance
74
- controller?: AbortController
75
- fromDate?: Date | string | null
76
- toDate?: Date | string | null
77
- }) => {
78
- return null
79
- try {
80
- const res = await axiosPrivate.get('/api-g-a', {
81
- params: {
82
- requestType: requestType,
83
- fromDate: fromDate,
84
- toDate: toDate,
85
- },
86
- signal: controller?.signal,
87
- })
88
- return res.data
89
- } catch (error) {
90
- return null
91
- }
92
- }