create-nextjs-cms 0.5.8

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 (187) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +395 -0
  6. package/dist/lib/utils.d.ts +11 -0
  7. package/dist/lib/utils.d.ts.map +1 -0
  8. package/dist/lib/utils.js +48 -0
  9. package/package.json +44 -0
  10. package/templates/default/.env +24 -0
  11. package/templates/default/.env.development +8 -0
  12. package/templates/default/.eslintrc.json +5 -0
  13. package/templates/default/.prettierignore +7 -0
  14. package/templates/default/.prettierrc.json +19 -0
  15. package/templates/default/CHANGELOG.md +77 -0
  16. package/templates/default/README.md +45 -0
  17. package/templates/default/app/(auth)/auth/login/LoginPage.tsx +175 -0
  18. package/templates/default/app/(auth)/auth/login/page.tsx +12 -0
  19. package/templates/default/app/(rootLayout)/admins/page.tsx +5 -0
  20. package/templates/default/app/(rootLayout)/advanced/page.tsx +5 -0
  21. package/templates/default/app/(rootLayout)/analytics/page.tsx +7 -0
  22. package/templates/default/app/(rootLayout)/browse/[section]/[page]/page.tsx +7 -0
  23. package/templates/default/app/(rootLayout)/categorized/[section]/page.tsx +7 -0
  24. package/templates/default/app/(rootLayout)/dashboard/page.tsx +7 -0
  25. package/templates/default/app/(rootLayout)/edit/[section]/[itemId]/page.tsx +7 -0
  26. package/templates/default/app/(rootLayout)/emails/page.tsx +6 -0
  27. package/templates/default/app/(rootLayout)/layout.tsx +5 -0
  28. package/templates/default/app/(rootLayout)/loading.tsx +10 -0
  29. package/templates/default/app/(rootLayout)/log/page.tsx +7 -0
  30. package/templates/default/app/(rootLayout)/new/[section]/page.tsx +7 -0
  31. package/templates/default/app/(rootLayout)/page.tsx +9 -0
  32. package/templates/default/app/(rootLayout)/section/[section]/page.tsx +7 -0
  33. package/templates/default/app/(rootLayout)/settings/page.tsx +7 -0
  34. package/templates/default/app/_trpc/client.ts +4 -0
  35. package/templates/default/app/api/auth/csrf/route.ts +25 -0
  36. package/templates/default/app/api/auth/refresh/route.ts +10 -0
  37. package/templates/default/app/api/auth/route.ts +23 -0
  38. package/templates/default/app/api/auth/session/route.ts +20 -0
  39. package/templates/default/app/api/editor/photo/route.ts +42 -0
  40. package/templates/default/app/api/photo/route.ts +27 -0
  41. package/templates/default/app/api/placeholder/route.ts +7 -0
  42. package/templates/default/app/api/submit/section/item/[slug]/route.ts +63 -0
  43. package/templates/default/app/api/submit/section/item/route.ts +53 -0
  44. package/templates/default/app/api/submit/section/simple/route.ts +54 -0
  45. package/templates/default/app/api/trpc/[trpc]/route.ts +33 -0
  46. package/templates/default/app/api/video/route.ts +174 -0
  47. package/templates/default/app/dictionaries.ts +14 -0
  48. package/templates/default/app/layout.tsx +28 -0
  49. package/templates/default/app/providers.tsx +151 -0
  50. package/templates/default/cli.ts +4 -0
  51. package/templates/default/components/AdminCard.tsx +163 -0
  52. package/templates/default/components/AdminEditPage.tsx +123 -0
  53. package/templates/default/components/AdminPrivilegeCard.tsx +184 -0
  54. package/templates/default/components/AdminsPage.tsx +43 -0
  55. package/templates/default/components/AdvancedSettingsPage.tsx +167 -0
  56. package/templates/default/components/AnalyticsPage.tsx +127 -0
  57. package/templates/default/components/BarChartBox.tsx +43 -0
  58. package/templates/default/components/BrowsePage.tsx +119 -0
  59. package/templates/default/components/CategorizedSectionPage.tsx +36 -0
  60. package/templates/default/components/CategoryDeleteConfirmPage.tsx +129 -0
  61. package/templates/default/components/CategorySectionSelectInput.tsx +139 -0
  62. package/templates/default/components/ConditionalFields.tsx +49 -0
  63. package/templates/default/components/ContainerBox.tsx +24 -0
  64. package/templates/default/components/DashboardPage.tsx +187 -0
  65. package/templates/default/components/DashboardPageAlt.tsx +43 -0
  66. package/templates/default/components/DefaultNavItems.tsx +3 -0
  67. package/templates/default/components/Dropzone.tsx +153 -0
  68. package/templates/default/components/EmailCard.tsx +137 -0
  69. package/templates/default/components/EmailPasswordForm.tsx +84 -0
  70. package/templates/default/components/EmailQuotaForm.tsx +72 -0
  71. package/templates/default/components/EmailsPage.tsx +48 -0
  72. package/templates/default/components/GalleryPhoto.tsx +93 -0
  73. package/templates/default/components/InfoCard.tsx +94 -0
  74. package/templates/default/components/ItemEditPage.tsx +217 -0
  75. package/templates/default/components/Layout.tsx +70 -0
  76. package/templates/default/components/LoadingSpinners.tsx +67 -0
  77. package/templates/default/components/LogPage.tsx +17 -0
  78. package/templates/default/components/Modal.tsx +99 -0
  79. package/templates/default/components/Navbar.tsx +29 -0
  80. package/templates/default/components/NavbarAlt.tsx +182 -0
  81. package/templates/default/components/NewAdminForm.tsx +172 -0
  82. package/templates/default/components/NewEmailForm.tsx +131 -0
  83. package/templates/default/components/NewPage.tsx +206 -0
  84. package/templates/default/components/NewVariantComponent.tsx +228 -0
  85. package/templates/default/components/PhotoGallery.tsx +35 -0
  86. package/templates/default/components/PieChartBox.tsx +101 -0
  87. package/templates/default/components/ProgressBar.tsx +24 -0
  88. package/templates/default/components/ProtectedDocument.tsx +78 -0
  89. package/templates/default/components/ProtectedImage.tsx +143 -0
  90. package/templates/default/components/ProtectedVideo.tsx +76 -0
  91. package/templates/default/components/SectionItemCard.tsx +143 -0
  92. package/templates/default/components/SectionItemStatusBadge.tsx +16 -0
  93. package/templates/default/components/SectionPage.tsx +124 -0
  94. package/templates/default/components/SelectBox.tsx +99 -0
  95. package/templates/default/components/SelectInputButtons.tsx +124 -0
  96. package/templates/default/components/SettingsPage.tsx +238 -0
  97. package/templates/default/components/Sidebar.tsx +209 -0
  98. package/templates/default/components/SidebarDropdownItem.tsx +74 -0
  99. package/templates/default/components/SidebarItem.tsx +19 -0
  100. package/templates/default/components/TempPage.tsx +12 -0
  101. package/templates/default/components/ThemeProvider.tsx +8 -0
  102. package/templates/default/components/TooltipComponent.tsx +27 -0
  103. package/templates/default/components/VariantCard.tsx +123 -0
  104. package/templates/default/components/VariantEditPage.tsx +229 -0
  105. package/templates/default/components/analytics/BounceRate.tsx +69 -0
  106. package/templates/default/components/analytics/LivePageViews.tsx +54 -0
  107. package/templates/default/components/analytics/LiveUsersCount.tsx +32 -0
  108. package/templates/default/components/analytics/MonthlyPageViews.tsx +41 -0
  109. package/templates/default/components/analytics/TopCountries.tsx +51 -0
  110. package/templates/default/components/analytics/TopDevices.tsx +45 -0
  111. package/templates/default/components/analytics/TopMediums.tsx +57 -0
  112. package/templates/default/components/analytics/TopSources.tsx +44 -0
  113. package/templates/default/components/analytics/TotalPageViews.tsx +40 -0
  114. package/templates/default/components/analytics/TotalSessions.tsx +40 -0
  115. package/templates/default/components/analytics/TotalUniqueUsers.tsx +40 -0
  116. package/templates/default/components/custom/RightHomeRoomVariantCard.tsx +137 -0
  117. package/templates/default/components/dndKit/Draggable.tsx +21 -0
  118. package/templates/default/components/dndKit/Droppable.tsx +20 -0
  119. package/templates/default/components/dndKit/SortableItem.tsx +18 -0
  120. package/templates/default/components/form/DateRangeFormInput.tsx +55 -0
  121. package/templates/default/components/form/Form.tsx +298 -0
  122. package/templates/default/components/form/FormInputElement.tsx +68 -0
  123. package/templates/default/components/form/FormInputs.tsx +108 -0
  124. package/templates/default/components/form/helpers/util.ts +20 -0
  125. package/templates/default/components/form/inputs/CheckboxFormInput.tsx +33 -0
  126. package/templates/default/components/form/inputs/ColorFormInput.tsx +44 -0
  127. package/templates/default/components/form/inputs/DateFormInput.tsx +107 -0
  128. package/templates/default/components/form/inputs/DocumentFormInput.tsx +124 -0
  129. package/templates/default/components/form/inputs/MapFormInput.tsx +139 -0
  130. package/templates/default/components/form/inputs/MultipleSelectFormInput.tsx +150 -0
  131. package/templates/default/components/form/inputs/NumberFormInput.tsx +42 -0
  132. package/templates/default/components/form/inputs/PasswordFormInput.tsx +47 -0
  133. package/templates/default/components/form/inputs/PhotoFormInput.tsx +218 -0
  134. package/templates/default/components/form/inputs/RichTextFormInput.tsx +133 -0
  135. package/templates/default/components/form/inputs/SelectFormInput.tsx +164 -0
  136. package/templates/default/components/form/inputs/TagsFormInput.tsx +63 -0
  137. package/templates/default/components/form/inputs/TextFormInput.tsx +48 -0
  138. package/templates/default/components/form/inputs/TextareaFormInput.tsx +47 -0
  139. package/templates/default/components/form/inputs/VideoFormInput.tsx +117 -0
  140. package/templates/default/components/pagination/Pagination.tsx +36 -0
  141. package/templates/default/components/pagination/PaginationButtons.tsx +145 -0
  142. package/templates/default/components/ui/accordion.tsx +57 -0
  143. package/templates/default/components/ui/alert.tsx +46 -0
  144. package/templates/default/components/ui/badge.tsx +33 -0
  145. package/templates/default/components/ui/button.tsx +57 -0
  146. package/templates/default/components/ui/calendar.tsx +68 -0
  147. package/templates/default/components/ui/card.tsx +76 -0
  148. package/templates/default/components/ui/checkbox.tsx +29 -0
  149. package/templates/default/components/ui/dropdown-menu.tsx +205 -0
  150. package/templates/default/components/ui/input.tsx +25 -0
  151. package/templates/default/components/ui/label.tsx +26 -0
  152. package/templates/default/components/ui/popover.tsx +31 -0
  153. package/templates/default/components/ui/scroll-area.tsx +42 -0
  154. package/templates/default/components/ui/select.tsx +164 -0
  155. package/templates/default/components/ui/sheet.tsx +107 -0
  156. package/templates/default/components/ui/switch.tsx +29 -0
  157. package/templates/default/components/ui/table.tsx +120 -0
  158. package/templates/default/components/ui/tabs.tsx +55 -0
  159. package/templates/default/components/ui/toast.tsx +113 -0
  160. package/templates/default/components/ui/toaster.tsx +35 -0
  161. package/templates/default/components/ui/tooltip.tsx +30 -0
  162. package/templates/default/components/ui/use-toast.ts +188 -0
  163. package/templates/default/components.json +16 -0
  164. package/templates/default/context/ModalProvider.tsx +53 -0
  165. package/templates/default/drizzle.config.ts +4 -0
  166. package/templates/default/dynamic-schemas/schema.ts +373 -0
  167. package/templates/default/env/env.js +130 -0
  168. package/templates/default/envConfig.ts +4 -0
  169. package/templates/default/hooks/useModal.ts +8 -0
  170. package/templates/default/lib/apiHelpers.ts +106 -0
  171. package/templates/default/lz.config.ts +40 -0
  172. package/templates/default/middleware.ts +33 -0
  173. package/templates/default/next.config.ts +46 -0
  174. package/templates/default/package.json +134 -0
  175. package/templates/default/postcss.config.js +6 -0
  176. package/templates/default/postinstall.js +14 -0
  177. package/templates/default/public/blank_avatar.png +0 -0
  178. package/templates/default/public/favicon.ico +0 -0
  179. package/templates/default/public/img/placeholder.svg +1 -0
  180. package/templates/default/public/lazemni_logo.png +0 -0
  181. package/templates/default/public/next.svg +1 -0
  182. package/templates/default/public/vercel.svg +1 -0
  183. package/templates/default/section-tests.ts +92 -0
  184. package/templates/default/styles/globals.css +88 -0
  185. package/templates/default/tailwind.config.js +95 -0
  186. package/templates/default/test.ts +77 -0
  187. package/templates/default/tsconfig.json +44 -0
@@ -0,0 +1,217 @@
1
+ 'use client'
2
+
3
+ import { useAxiosPrivate } from 'nextjs-cms/auth/hooks'
4
+ import React, { RefObject, useEffect, useRef, useState } from 'react'
5
+ import { SectionType } from 'nextjs-cms/core/types'
6
+ import getString from 'nextjs-cms/translations'
7
+ import useModal from '@/hooks/useModal'
8
+ import { AxiosError } from 'axios'
9
+ import InfoCard from '@/components/InfoCard'
10
+ import { useRouter } from 'next/navigation'
11
+ import LoadingSpinners from '@/components/LoadingSpinners'
12
+ import { useToast } from '@/components/ui/use-toast'
13
+ import { DropzoneHandles } from '@/components/Dropzone'
14
+ import { VariantHandles } from '@/components/NewVariantComponent'
15
+ import { trpc } from '@/app/_trpc/client'
16
+ import Form from '@/components/form/Form'
17
+
18
+ export default function ItemEditPage({
19
+ section,
20
+ sectionType,
21
+ itemId,
22
+ hiddenInputs,
23
+ action,
24
+ }: {
25
+ section: string
26
+ sectionType: SectionType
27
+ itemId: string
28
+ hiddenInputs?: {
29
+ name: string
30
+ value: any
31
+ }[]
32
+ action?: any
33
+ }) {
34
+ const [response, setResponse] = useState<any>(null)
35
+ const [progress, setProgress] = useState(0)
36
+ const [progressVariant, setProgressVariant] = useState<'determinate' | 'query'>('determinate')
37
+ const [isSubmitting, setIsSubmitting] = useState(false)
38
+ const { setModal } = useModal()
39
+ const axiosPrivate = useAxiosPrivate()
40
+ const controller = new AbortController()
41
+ const { toast } = useToast()
42
+ const router = useRouter()
43
+ const dropzoneRef: RefObject<DropzoneHandles | null> = useRef(null)
44
+ const variantRef: RefObject<VariantHandles[]> = useRef([])
45
+ const { isLoading, isError, data, error, refetch } = trpc.hasItemsSections.editItem.useQuery({
46
+ sectionName: section,
47
+ sectionItemId: itemId,
48
+ })
49
+
50
+ const handleSubmit = async (formData: FormData) => {
51
+ setIsSubmitting(true)
52
+ if (isSubmitting) return
53
+ setResponse(null)
54
+
55
+ formData.append('sectionName', section)
56
+ formData.append('formType', 'edit')
57
+ formData.append('sectionType', sectionType)
58
+
59
+ // Retrieve the files from the Dropzone's state
60
+ if (dropzoneRef.current) {
61
+ const files: File[] = dropzoneRef.current.getFiles()
62
+ // Add files to the body
63
+ files.forEach((file, index) => {
64
+ formData.append(`dropzoneFiles`, file)
65
+ })
66
+ }
67
+
68
+ // Retrieve the variants from the variants component
69
+ // For now, only one variant is allowed
70
+ const variantsObject: any[] = []
71
+ if (variantRef.current && data?.section?.variants?.length && data?.section?.variants[0]) {
72
+ // Add variants to the body
73
+ variantRef.current.map((ref, index) => {
74
+ variantsObject.push({
75
+ // @ts-ignore
76
+ variant: data.section.variants[index],
77
+ items: ref.getVariants(),
78
+ })
79
+ })
80
+
81
+ formData.append(`variantItems`, JSON.stringify(variantsObject))
82
+ }
83
+
84
+ // Check if there are any hidden inputs passed to the component
85
+ if (hiddenInputs) {
86
+ // Add hidden inputs to the body
87
+ hiddenInputs.forEach((input) => {
88
+ if (!input.value) return
89
+ formData.append(input.name, input.value)
90
+ })
91
+ }
92
+
93
+ // const body = Object.fromEntries(formData.entries())
94
+ try {
95
+ const res = await axiosPrivate.put(`/submit/section/item/${itemId}`, formData, {
96
+ signal: controller.signal,
97
+ onUploadProgress: (progressEvent) => {
98
+ if (!progressEvent.total) return
99
+ const progress = Math.round((progressEvent.loaded / progressEvent.total) * 100)
100
+ // Update progress bar value here
101
+ setProgress(progress)
102
+
103
+ if (progress === 100) {
104
+ setProgressVariant('query')
105
+ }
106
+ },
107
+ headers: {
108
+ 'Content-Type': 'multipart/form-data',
109
+ },
110
+ })
111
+
112
+ if (res) {
113
+ setIsSubmitting(false)
114
+ setProgress(0)
115
+ setProgressVariant('determinate')
116
+ if (res.status === 200) {
117
+ // Refetch the page
118
+ // Clear Dropzone
119
+ if (dropzoneRef.current) {
120
+ dropzoneRef.current.removeFiles()
121
+ }
122
+
123
+ // Clear Variants
124
+ if (variantRef.current) {
125
+ variantRef.current.map((ref) => {
126
+ ref.removeVariants()
127
+ })
128
+ }
129
+ await refetch()
130
+ switch (sectionType) {
131
+ case 'categorized':
132
+ // Just close the modal and refetch the page
133
+ setModal(null)
134
+ toast({
135
+ variant: 'success',
136
+ description: getString('itemUpdatedSuccessfully'),
137
+ })
138
+ if (action) {
139
+ await action().then(() => {
140
+ setModal(null)
141
+ router.refresh()
142
+ })
143
+ } else {
144
+ setModal(null)
145
+ }
146
+ break
147
+
148
+ case 'has_items':
149
+ setResponse(null)
150
+ toast({
151
+ variant: 'success',
152
+ description: getString('itemUpdatedSuccessfully'),
153
+ })
154
+
155
+ // Redirect to the edit page
156
+ // router.push(`/edit/${section}/${res.data.identifier}`)
157
+ // Or redirect to the browse page
158
+ break
159
+ }
160
+ }
161
+ }
162
+ } catch (error: AxiosError | any) {
163
+ setIsSubmitting(false)
164
+ setProgress(0)
165
+ setProgressVariant('determinate')
166
+ if (error?.response?.data) {
167
+ setResponse(<InfoCard result={{ key: 'danger', title: error.response.data.error, status: false }} />)
168
+ }
169
+ }
170
+ }
171
+
172
+ function cancelSubmit() {
173
+ controller.abort()
174
+ setIsSubmitting(false)
175
+ setProgress(0)
176
+ setProgressVariant('determinate')
177
+ }
178
+
179
+ useEffect(() => {
180
+ return () => {
181
+ cancelSubmit()
182
+ }
183
+ }, [])
184
+
185
+ return (
186
+ <div className='flex w-full flex-col overflow-hidden'>
187
+ {isLoading ? (
188
+ <div>
189
+ <LoadingSpinners />
190
+ </div>
191
+ ) : null}
192
+ {isError ? <div>{error?.message}</div> : null}
193
+ {data ? (
194
+ <div className='flex w-full flex-col'>
195
+ <div className='relative z-[1] border-b-2 p-8 pt-12 font-extrabold text-foreground'>
196
+ <div className='absolute left-0 top-0 z-[2] h-4 w-full bg-gradient-to-r from-emerald-800 via-emerald-400 to-sky-600'></div>
197
+ <h1 className='pb-4 text-4xl'>{data.section?.title.section}</h1>
198
+ <span>
199
+ /{getString('edit')} {data.section?.title.singular}
200
+ </span>
201
+ </div>
202
+ <Form
203
+ formType='edit'
204
+ progressVariant={progressVariant}
205
+ response={response}
206
+ progress={progress}
207
+ data={data}
208
+ dropzoneRef={dropzoneRef}
209
+ variantRef={variantRef}
210
+ handleSubmit={handleSubmit}
211
+ isSubmitting={isSubmitting}
212
+ />
213
+ </div>
214
+ ) : null}
215
+ </div>
216
+ )
217
+ }
@@ -0,0 +1,70 @@
1
+ 'use client'
2
+
3
+ import classNames from 'classnames'
4
+ import React, { useState } from 'react'
5
+ import Navbar from '@/components/NavbarAlt'
6
+ import Sidebar from '@/components/Sidebar'
7
+ import Modal from '@/components/Modal'
8
+ import { Toaster } from '@/components/ui/toaster'
9
+ import { useSession } from 'nextjs-cms/auth/react'
10
+ import LoadingSpinners from '@/components/LoadingSpinners'
11
+
12
+ function Layout({ children }: { children: React.ReactNode }) {
13
+ const [showMobileSidebar, setShowMobileSidebar] = useState(false)
14
+ const session = useSession({
15
+ required: true,
16
+ })
17
+
18
+ return (
19
+ <div
20
+ className={classNames({
21
+ 'flex min-h-screen flex-col bg-background text-foreground': true,
22
+ 'overflow-hidden': true,
23
+ })}
24
+ >
25
+ <div>
26
+ {session.status === 'loading' ? (
27
+ <div className='align-center flex w-full flex-row items-center justify-center p-2'>
28
+ <LoadingSpinners />
29
+ </div>
30
+ ) : (
31
+ <>
32
+ <Sidebar
33
+ closeSideBar={() => {
34
+ setShowMobileSidebar(false)
35
+ }}
36
+ mobileSidebar={showMobileSidebar}
37
+ />
38
+ {showMobileSidebar && (
39
+ // Display a black transparent div to close the sidebar when clicked outside
40
+ <div
41
+ className='fixed left-0 top-0 z-[15] h-full w-full bg-black/80 md:hidden'
42
+ onClick={() => setShowMobileSidebar(false)}
43
+ ></div>
44
+ )}
45
+ <div
46
+ className={classNames({
47
+ 'transition-all duration-100 ease-in-out': true,
48
+ 'float-right': true,
49
+ 'w-full md:w-[calc(100%-275px)]': true,
50
+ })}
51
+ >
52
+ <Navbar onMenuButtonClick={() => setShowMobileSidebar((prev) => !prev)} />
53
+ <div
54
+ className={classNames({
55
+ 'h-full w-full': true,
56
+ })}
57
+ >
58
+ {children}
59
+ </div>
60
+ </div>
61
+ <Modal />
62
+ <Toaster />
63
+ </>
64
+ )}
65
+ </div>
66
+ </div>
67
+ )
68
+ }
69
+
70
+ export default Layout
@@ -0,0 +1,67 @@
1
+ const LoadingSpinners = ({ single = false }: { single?: boolean }) => {
2
+ return (
3
+ <div className='flex justify-center'>
4
+ <div role='status'>
5
+ <svg
6
+ aria-hidden='true'
7
+ className='mr-2 inline h-8 w-8 animate-spin fill-blue-600 text-gray-200 dark:text-gray-600'
8
+ viewBox='0 0 100 101'
9
+ fill='none'
10
+ xmlns='http://www.w3.org/2000/svg'
11
+ >
12
+ <path
13
+ d='M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z'
14
+ fill='currentColor'
15
+ />
16
+ <path
17
+ d='M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z'
18
+ fill='currentFill'
19
+ />
20
+ </svg>
21
+ </div>
22
+ {!single && (
23
+ <>
24
+ <div role='status'>
25
+ <svg
26
+ aria-hidden='true'
27
+ className='mr-2 inline h-8 w-8 animate-spin fill-red-600 text-gray-200 dark:fill-gray-300 dark:text-gray-600'
28
+ viewBox='0 0 100 101'
29
+ fill='none'
30
+ xmlns='http://www.w3.org/2000/svg'
31
+ >
32
+ <path
33
+ d='M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z'
34
+ fill='currentColor'
35
+ />
36
+ <path
37
+ d='M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z'
38
+ fill='currentFill'
39
+ />
40
+ </svg>
41
+ </div>
42
+ <div role='status'>
43
+ <svg
44
+ aria-hidden='true'
45
+ className='mr-2 inline h-8 w-8 animate-spin fill-green-500 text-gray-200 dark:text-gray-600'
46
+ viewBox='0 0 100 101'
47
+ fill='none'
48
+ xmlns='http://www.w3.org/2000/svg'
49
+ >
50
+ <path
51
+ d='M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z'
52
+ fill='currentColor'
53
+ />
54
+ <path
55
+ d='M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z'
56
+ fill='currentFill'
57
+ />
58
+ </svg>
59
+ </div>
60
+ </>
61
+ )}
62
+ <span className='sr-only'>Loading...</span>
63
+ </div>
64
+ )
65
+ }
66
+
67
+ export default LoadingSpinners
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+
3
+ import getString from 'nextjs-cms/translations'
4
+ import React from 'react'
5
+
6
+ export default function LogPage() {
7
+ return (
8
+ <div className='w-full'>
9
+ <div className='bg-gradient-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'>
10
+ <h1 className='text-3xl'>{getString('logs')}</h1>
11
+ </div>
12
+
13
+ <div className='flex flex-col gap-2 p-4'>
14
+ </div>
15
+ </div>
16
+ )
17
+ }
@@ -0,0 +1,99 @@
1
+ 'use client'
2
+
3
+ import React, { Fragment, useEffect, useRef } from 'react'
4
+ import { Dialog, Transition } from '@headlessui/react'
5
+ import useModal from '@/hooks/useModal'
6
+ import classNames from 'classnames'
7
+ import { X } from 'lucide-react'
8
+
9
+ function Modal() {
10
+ const { setModal, modal, modalResponse, setModalResponse } = useModal()
11
+
12
+ const handleClose = () => {
13
+ setModal(null)
14
+ }
15
+
16
+ const cancelButtonRef = useRef(null)
17
+
18
+ useEffect(() => {
19
+ if (!modal) {
20
+ setModalResponse(null)
21
+ }
22
+ }, [modal])
23
+
24
+ return (
25
+ <Transition.Root show={modal !== null} as={Fragment}>
26
+ <Dialog as='div' className='relative z-50' initialFocus={cancelButtonRef} onClose={handleClose}>
27
+ <Transition.Child
28
+ as={Fragment}
29
+ enter='ease-out duration-300'
30
+ enterFrom='opacity-0'
31
+ enterTo='opacity-100'
32
+ leave='ease-in duration-200'
33
+ leaveFrom='opacity-100'
34
+ leaveTo='opacity-0'
35
+ >
36
+ <div className='fixed inset-0 bg-gray-500/50 backdrop-blur-md transition-opacity' />
37
+ </Transition.Child>
38
+
39
+ <div className='fixed inset-0 z-10 overflow-y-auto'>
40
+ <div className='flex min-h-full items-end justify-center p-4 text-start sm:items-start sm:p-0'>
41
+ <Transition.Child
42
+ as={Fragment}
43
+ enter='ease-out duration-300'
44
+ enterFrom='opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'
45
+ enterTo='opacity-100 translate-y-0 sm:scale-100'
46
+ leave='ease-in duration-200'
47
+ leaveFrom='opacity-100 translate-y-0 sm:scale-100'
48
+ leaveTo='opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'
49
+ >
50
+ <Dialog.Panel
51
+ className={classNames({
52
+ 'relative w-full rounded-lg bg-background text-start shadow-xl transition-all sm:my-8':
53
+ true,
54
+ 'max-w-lg': modal?.size === 'sm' || modal?.size === undefined,
55
+ 'max-w-2xl': modal?.size === 'md',
56
+ 'max-w-4xl': modal?.size === 'lg',
57
+ 'max-w-6xl': modal?.size === 'xl',
58
+ })}
59
+ >
60
+ <div className='rounded-lg bg-background'>
61
+ {modal && (
62
+ <div className='flex flex-col gap-1'>
63
+ <div className='w-full overflow-hidden rounded'>
64
+ <div
65
+ className={`flex items-center rounded-t-lg text-xl font-semibold leading-6 ${modal.titleColor} p-6 pb-4 pt-5 md:pe-20 ${modal.headerColor}`}
66
+ >
67
+ <Dialog.Title as='h3' className='pe-5'>
68
+ {modal.title}
69
+ </Dialog.Title>
70
+ <X
71
+ className={`absolute ${
72
+ modal.lang === 'ar' ? 'left-5' : 'right-5'
73
+ } hidden h-7 w-7 cursor-pointer rounded bg-white text-gray-500 hover:opacity-90 md:block`}
74
+ onClick={handleClose}
75
+ ref={cancelButtonRef}
76
+ />
77
+ </div>
78
+ <div className='flex w-full flex-col font-semibold'>
79
+ <div className='w-full text-foreground'>{modal.body}</div>
80
+ <div className='w-full'>
81
+ {modalResponse && (
82
+ <div className={`w-full p-3`}>{modalResponse.message}</div>
83
+ )}
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ )}
89
+ </div>
90
+ </Dialog.Panel>
91
+ </Transition.Child>
92
+ </div>
93
+ </div>
94
+ </Dialog>
95
+ </Transition.Root>
96
+ )
97
+ }
98
+
99
+ export default Modal
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+ import classNames from 'classnames'
3
+ import { HamburgerMenuIcon } from '@radix-ui/react-icons'
4
+ type Props = {
5
+ /**
6
+ * Allows the parent component to modify the state when the
7
+ * menu button is clicked.
8
+ */
9
+ onMenuButtonClick(): void
10
+ }
11
+ const Navbar = (props: Props) => {
12
+ return (
13
+ <nav
14
+ className={classNames({
15
+ 'bg-white text-zinc-500': true, // colors
16
+ 'flex items-center': true, // layout
17
+ 'w-full md:w-full sticky z-10 px-4 shadow-sm h-[73px] top-0 ': true, //positioning & styling
18
+ })}
19
+ >
20
+ <div className='font-bold text-lg'>Admin Panel</div>
21
+ <div className='flex-grow'></div>
22
+ <button className='md:hidden' onClick={props.onMenuButtonClick}>
23
+ <HamburgerMenuIcon className='h-6 w-6' />
24
+ </button>
25
+ </nav>
26
+ )
27
+ }
28
+
29
+ export default Navbar