@devvistatech/devvista-kit 0.0.10 → 0.0.13
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.
- package/CHANGELOG.md +12 -12
- package/LICENSE +6 -6
- package/README.md +55 -15
- package/app/ClientLayout.tsx +66 -0
- package/app/about/page.tsx +61 -298
- package/app/adRequest/page.tsx +625 -549
- package/app/admin-profile/page.tsx +123 -0
- package/app/analytics/page.tsx +382 -346
- package/app/api/about/route.ts +290 -306
- package/app/api/adRequest/route.ts +547 -567
- package/app/api/analytics/[reportType]/route.ts +274 -337
- package/app/api/bio/route.ts +297 -313
- package/app/api/blog/route.ts +288 -306
- package/app/api/chat/route.ts +14 -14
- package/app/api/contact/route.ts +409 -409
- package/app/api/contacts/route.ts +179 -224
- package/app/api/files/route.ts +415 -429
- package/app/api/gallery-data/route.ts +727 -735
- package/app/api/schedule/route.ts +439 -455
- package/app/api/signup/route.ts +129 -0
- package/app/api/sync-user/route.ts +306 -132
- package/app/api/trial-request/route.ts +297 -297
- package/app/api/verify-admin/route.ts +46 -0
- package/app/blog/[id]/page.tsx +307 -288
- package/app/blog/page.tsx +249 -216
- package/app/contact/page.tsx +284 -284
- package/app/faq/page.tsx +191 -191
- package/app/favicon.ico +0 -0
- package/app/gallery/page.tsx +336 -315
- package/app/globals.css +58 -58
- package/app/layout.tsx +59 -110
- package/app/not-found.tsx +20 -20
- package/app/page.tsx +47 -338
- package/app/products/constants/product.ts +27 -0
- package/app/products/page.tsx +296 -0
- package/app/products/productOne/page.tsx +266 -0
- package/app/products/productTwo/page.tsx +272 -0
- package/app/schedule/page.tsx +698 -660
- package/bin/init.js +207 -219
- package/components/addOns/functional/CalendlyWidget.tsx +107 -107
- package/components/addOns/functional/ClassList.tsx +149 -145
- package/components/addOns/functional/ClassPopup.tsx +398 -398
- package/components/addOns/functional/ContactForm.tsx +284 -284
- package/components/addOns/functional/NewUserAnalytics.tsx +100 -100
- package/components/addOns/functional/ProductList.tsx +1027 -0
- package/components/addOns/functional/aboutSections/AboutSection.tsx +581 -544
- package/components/addOns/functional/aboutSections/constants/aboutSection.ts +70 -65
- package/components/addOns/functional/banner/Banner.tsx +150 -0
- package/components/addOns/functional/banner/BannerDashboard.tsx +283 -0
- package/components/addOns/functional/bioSections/BioEditor.tsx +471 -0
- package/components/addOns/functional/bioSections/constants/bioEditor.ts +36 -0
- package/components/addOns/functional/blogSections/BlogDashboard.tsx +184 -184
- package/components/addOns/functional/blogSections/BlogFormPopUp.tsx +555 -554
- package/components/addOns/functional/blogSections/BlogList.tsx +148 -148
- package/components/addOns/functional/blogSections/BlogSidebar.tsx +58 -58
- package/components/addOns/functional/blogSections/constants/blogDashboard.ts +28 -28
- package/components/addOns/functional/blogSections/constants/blogFormPopUp.ts +97 -97
- package/components/addOns/functional/blogSections/constants/blogList.ts +22 -22
- package/components/addOns/functional/blogSections/constants/blogSidebar.ts +15 -15
- package/components/addOns/functional/{ImageDescCarousel.tsx → carousels/ImageDescCarousel.tsx} +839 -730
- package/components/addOns/functional/carousels/ProductDescCarousel.tsx +1129 -0
- package/components/addOns/functional/{ScheduleCarousel.tsx → carousels/ScheduleCarousel.tsx} +231 -171
- package/components/addOns/functional/carousels/constants.ts/productDescCarousel.ts +197 -0
- package/components/addOns/functional/carousels/constants.ts/scheduleCarousel.ts +20 -0
- package/components/addOns/functional/contactsDashboard/ContactsDashboard.tsx +366 -366
- package/components/addOns/functional/contactsDashboard/constants/contactsDashboard.ts +70 -70
- package/components/addOns/functional/fileUploaders/FileUploader.tsx +437 -0
- package/components/addOns/functional/fileUploaders/constants/fileUploader.ts +45 -0
- package/components/addOns/functional/galleries/GalleryComplex.tsx +1037 -836
- package/components/addOns/functional/galleries/GallerySimple.tsx +537 -509
- package/components/addOns/functional/galleries/ThreeSetGallery.tsx +260 -0
- package/components/addOns/functional/galleries/constants/galleryComplex.ts +106 -106
- package/components/addOns/functional/galleries/constants/gallerySimple.ts +76 -76
- package/components/addOns/functional/schedules/ScheduleGridOne.tsx +276 -262
- package/components/addOns/functional/schedules/ScheduleGridTwo.tsx +299 -294
- package/components/addOns/functional/schedules/ScheduleGridTwoBasic.tsx +293 -288
- package/components/addOns/functional/schedules/SchedulerForm.tsx +428 -428
- package/components/addOns/functional/schedules/constants/ScheduleGridTwo.ts +40 -40
- package/components/addOns/functional/schedules/constants/ScheduleGridTwoBasic.ts +40 -40
- package/components/addOns/functional/schedules/constants/SchedulerForm.ts +65 -65
- package/components/addOns/functional/schedules/constants/scheduleGridOne.ts +54 -54
- package/components/addOns/non-functional/AnnouncementBanner.tsx +46 -46
- package/components/addOns/non-functional/IconBubble.tsx +49 -49
- package/components/addOns/non-functional/SampleCarousel.tsx +204 -204
- package/components/addOns/non-functional/Testimonials.tsx +334 -334
- package/components/addOns/non-functional/ThreeSetGallery.tsx +63 -63
- package/components/addOns/non-functional/aboutSections/AboutSection.tsx +62 -62
- package/components/addOns/non-functional/aboutSections/constants/aboutSection.ts +24 -24
- package/components/addOns/non-functional/featureSections/FeaturesSection.tsx +74 -0
- package/components/addOns/non-functional/featureSections/constants/featuresSection.ts +30 -0
- package/components/addOns/non-functional/{Heros/HeroSection.tsx → heros/HomeHero.tsx} +144 -142
- package/components/addOns/non-functional/heros/ProductHero.tsx +111 -0
- package/components/addOns/non-functional/heros/constants/hero.ts +62 -0
- package/components/addOns/non-functional/imageCarousels/ProductSlider.tsx +117 -117
- package/components/addOns/non-functional/imageCarousels/ProgramCarousel.tsx +232 -232
- package/components/addOns/non-functional/imageCarousels/constants/programCarousel.ts +39 -39
- package/components/addOns/non-functional/imageCarousels/constants/programSlider.ts +36 -36
- package/components/addOns/non-functional/spinner.tsx +21 -21
- package/components/footers/footer.tsx +416 -453
- package/components/navBars/navbar.tsx +310 -310
- package/components/other/accordion.tsx +58 -58
- package/components/other/admin-menu.tsx +68 -68
- package/components/other/alert-dialog.tsx +141 -141
- package/components/other/alert.tsx +59 -59
- package/components/other/aspect-ratio.tsx +7 -7
- package/components/other/avatar.tsx +50 -50
- package/components/other/badge.tsx +36 -36
- package/components/other/breadcrumb.tsx +115 -115
- package/components/other/button.tsx +738 -738
- package/components/other/calendar.tsx +66 -66
- package/components/other/card.tsx +86 -86
- package/components/other/carousel.tsx +274 -274
- package/components/other/chart.tsx +363 -363
- package/components/other/checkbox.tsx +30 -30
- package/components/other/collapsible.tsx +11 -11
- package/components/other/command.tsx +155 -155
- package/components/other/context-menu.tsx +200 -200
- package/components/other/dialog.tsx +122 -122
- package/components/other/drawer.tsx +118 -118
- package/components/other/dropdown-menu.tsx +200 -200
- package/components/other/form.tsx +179 -179
- package/components/other/hover-card.tsx +29 -29
- package/components/other/input-otp.tsx +71 -71
- package/components/other/input.tsx +25 -25
- package/components/other/label.tsx +26 -26
- package/components/other/menubar.tsx +236 -236
- package/components/other/mobile-icon.tsx +21 -21
- package/components/other/navigation-menu.tsx +128 -128
- package/components/other/pagination.tsx +117 -117
- package/components/other/popover.tsx +31 -31
- package/components/other/progress.tsx +28 -28
- package/components/other/radio-group.tsx +44 -44
- package/components/other/resizable.tsx +45 -45
- package/components/other/scroll-area.tsx +48 -48
- package/components/other/select.tsx +160 -160
- package/components/other/separator.tsx +31 -31
- package/components/other/sheet.tsx +140 -140
- package/components/other/skeleton.tsx +15 -15
- package/components/other/slider.tsx +28 -28
- package/components/other/social-icons.tsx +39 -39
- package/components/other/sonner.tsx +31 -31
- package/components/other/switch.tsx +29 -29
- package/components/other/table.tsx +117 -117
- package/components/other/tabs.tsx +55 -55
- package/components/other/textarea.tsx +24 -24
- package/components/other/toast.tsx +122 -122
- package/components/other/toaster.tsx +35 -35
- package/components/other/toggle-group.tsx +61 -61
- package/components/other/toggle.tsx +45 -45
- package/components/other/tooltip.tsx +30 -30
- package/components/theme-provider.tsx +8 -8
- package/hooks/use-toast.ts +188 -188
- package/lib/auth/auth-context.tsx +225 -0
- package/lib/auth/auth-utils.tsx +30 -0
- package/lib/constants/about.ts +34 -34
- package/lib/constants/adRequest.ts +256 -113
- package/lib/constants/admin-profile.ts +12 -0
- package/lib/constants/contact.ts +40 -40
- package/lib/constants/faq.ts +34 -34
- package/lib/constants/gallery.ts +42 -42
- package/lib/constants/page.ts +69 -69
- package/lib/constants/schedule.ts +71 -71
- package/lib/google/google-analytics-tracking.tsx +44 -0
- package/lib/{google-analytics.tsx → google/google-analytics.tsx} +97 -97
- package/lib/types.ts +235 -0
- package/lib/utils/compressImage.tsx +32 -0
- package/middleware.ts +46 -42
- package/netlify.toml +5 -5
- package/next.config.js +10 -10
- package/package.json +117 -116
- package/public/images/test.png +0 -0
- package/tailwind.config.ts +89 -89
- package/tsconfig.json +23 -23
- package/components/addOns/functional/BioEditor.tsx +0 -447
- package/components/addOns/functional/FileUploader.tsx +0 -295
- package/components/addOns/non-functional/FeaturesSection.tsx +0 -63
- package/components/types.ts +0 -50
- package/dist/.next/types/app/api/about/route.js +0 -52
- package/dist/.next/types/app/api/blog/route.js +0 -52
- package/dist/.next/types/app/api/files/route.js +0 -52
- package/dist/.next/types/app/api/schedule/route.js +0 -52
- package/dist/.next/types/app/api/sync-user/route.js +0 -52
- package/dist/.next/types/app/layout.js +0 -22
- package/dist/.next/types/app/page.js +0 -22
- package/dist/app/about/page.jsx +0 -258
- package/dist/app/adRequest/page.jsx +0 -531
- package/dist/app/analytics/page.jsx +0 -298
- package/dist/app/api/about/route.js +0 -285
- package/dist/app/api/adRequest/route.js +0 -440
- package/dist/app/api/analytics/[reportType]/route.js +0 -357
- package/dist/app/api/bio/route.js +0 -293
- package/dist/app/api/blog/route.js +0 -366
- package/dist/app/api/chat/route.js +0 -58
- package/dist/app/api/contact/route.js +0 -163
- package/dist/app/api/contacts/route.js +0 -234
- package/dist/app/api/files/route.js +0 -444
- package/dist/app/api/gallery-data/route.js +0 -719
- package/dist/app/api/schedule/route.js +0 -461
- package/dist/app/api/sync-user/route.js +0 -186
- package/dist/app/api/trial-request/route.js +0 -165
- package/dist/app/blog/[id]/page.jsx +0 -312
- package/dist/app/blog/page.jsx +0 -210
- package/dist/app/constants/about.js +0 -32
- package/dist/app/constants/adRequest.js +0 -113
- package/dist/app/constants/contact.js +0 -40
- package/dist/app/constants/faq.js +0 -36
- package/dist/app/constants/gallery.js +0 -42
- package/dist/app/constants/page.js +0 -69
- package/dist/app/constants/schedule.js +0 -71
- package/dist/app/contact/page.jsx +0 -119
- package/dist/app/faq/page.jsx +0 -97
- package/dist/app/gallery/page.jsx +0 -281
- package/dist/app/layout.jsx +0 -45
- package/dist/app/not-found.jsx +0 -14
- package/dist/app/page.jsx +0 -324
- package/dist/app/schedule/page.jsx +0 -500
- package/dist/components/addOns/functional/BioEditor.jsx +0 -187
- package/dist/components/addOns/functional/CalendlyWidget.jsx +0 -61
- package/dist/components/addOns/functional/ClassList.jsx +0 -158
- package/dist/components/addOns/functional/ClassPopup.jsx +0 -300
- package/dist/components/addOns/functional/ContactForm.jsx +0 -219
- package/dist/components/addOns/functional/FileUploader.jsx +0 -222
- package/dist/components/addOns/functional/ImageDescCarousel.jsx +0 -491
- package/dist/components/addOns/functional/NewUserAnalytics.jsx +0 -71
- package/dist/components/addOns/functional/ScheduleCarousel.jsx +0 -68
- package/dist/components/addOns/functional/aboutSections/AboutSection.jsx +0 -372
- package/dist/components/addOns/functional/aboutSections/constants/aboutSection.js +0 -65
- package/dist/components/addOns/functional/blogSections/BlogDashboard.jsx +0 -111
- package/dist/components/addOns/functional/blogSections/BlogFormPopUp.jsx +0 -465
- package/dist/components/addOns/functional/blogSections/BlogList.jsx +0 -170
- package/dist/components/addOns/functional/blogSections/BlogSidebar.jsx +0 -35
- package/dist/components/addOns/functional/blogSections/constants/blogDashboard.js +0 -28
- package/dist/components/addOns/functional/blogSections/constants/blogFormPopUp.js +0 -97
- package/dist/components/addOns/functional/blogSections/constants/blogList.js +0 -22
- package/dist/components/addOns/functional/blogSections/constants/blogSidebar.js +0 -15
- package/dist/components/addOns/functional/contactsDashboard/ContactsDashboard.jsx +0 -355
- package/dist/components/addOns/functional/contactsDashboard/constants/contactsDashboard.js +0 -70
- package/dist/components/addOns/functional/galleries/GalleryComplex.jsx +0 -605
- package/dist/components/addOns/functional/galleries/GallerySimple.jsx +0 -363
- package/dist/components/addOns/functional/galleries/constants/galleryComplex.js +0 -106
- package/dist/components/addOns/functional/galleries/constants/gallerySimple.js +0 -76
- package/dist/components/addOns/functional/schedules/ScheduleGridOne.jsx +0 -167
- package/dist/components/addOns/functional/schedules/ScheduleGridTwo.jsx +0 -100
- package/dist/components/addOns/functional/schedules/ScheduleGridTwoBasic.jsx +0 -97
- package/dist/components/addOns/functional/schedules/SchedulerForm.jsx +0 -188
- package/dist/components/addOns/functional/schedules/constants/ScheduleGridTwo.js +0 -40
- package/dist/components/addOns/functional/schedules/constants/ScheduleGridTwoBasic.js +0 -40
- package/dist/components/addOns/functional/schedules/constants/SchedulerForm.js +0 -65
- package/dist/components/addOns/functional/schedules/constants/scheduleGridOne.js +0 -54
- package/dist/components/addOns/non-functional/AnnouncementBanner.jsx +0 -24
- package/dist/components/addOns/non-functional/FeaturesSection.jsx +0 -38
- package/dist/components/addOns/non-functional/HeroSection.jsx +0 -71
- package/dist/components/addOns/non-functional/Heros/HeroSection.jsx +0 -71
- package/dist/components/addOns/non-functional/IconBubble.jsx +0 -36
- package/dist/components/addOns/non-functional/SampleCarousel.jsx +0 -114
- package/dist/components/addOns/non-functional/Testimonials.jsx +0 -177
- package/dist/components/addOns/non-functional/ThreeSetGallery.jsx +0 -40
- package/dist/components/addOns/non-functional/aboutSections/AboutSection.jsx +0 -35
- package/dist/components/addOns/non-functional/aboutSections/constants/aboutSection.js +0 -24
- package/dist/components/addOns/non-functional/imageCarousels/ProductSlider.jsx +0 -80
- package/dist/components/addOns/non-functional/imageCarousels/ProgramCarousel.jsx +0 -155
- package/dist/components/addOns/non-functional/imageCarousels/constants/programCarousel.js +0 -39
- package/dist/components/addOns/non-functional/imageCarousels/constants/programSlider.js +0 -36
- package/dist/components/addOns/non-functional/spinner.jsx +0 -13
- package/dist/components/footers/footer.jsx +0 -217
- package/dist/components/navBars/navbar.jsx +0 -159
- package/dist/components/other/accordion.jsx +0 -40
- package/dist/components/other/admin-menu.jsx +0 -34
- package/dist/components/other/alert-dialog.jsx +0 -64
- package/dist/components/other/alert.jsx +0 -41
- package/dist/components/other/aspect-ratio.jsx +0 -4
- package/dist/components/other/avatar.jsx +0 -31
- package/dist/components/other/badge.jsx +0 -32
- package/dist/components/other/breadcrumb.jsx +0 -57
- package/dist/components/other/button.jsx +0 -322
- package/dist/components/other/calendar.jsx +0 -43
- package/dist/components/other/card.jsx +0 -44
- package/dist/components/other/carousel.jsx +0 -140
- package/dist/components/other/chart.jsx +0 -182
- package/dist/components/other/checkbox.jsx +0 -26
- package/dist/components/other/collapsible.jsx +0 -6
- package/dist/components/other/command.jsx +0 -68
- package/dist/components/other/context-menu.jsx +0 -88
- package/dist/components/other/dialog.jsx +0 -60
- package/dist/components/other/drawer.jsx +0 -60
- package/dist/components/other/dropdown-menu.jsx +0 -90
- package/dist/components/other/form.jsx +0 -89
- package/dist/components/other/hover-card.jsx +0 -23
- package/dist/components/other/input-otp.jsx +0 -46
- package/dist/components/other/input.jsx +0 -19
- package/dist/components/other/label.jsx +0 -23
- package/dist/components/other/login-popup.jsx +0 -1
- package/dist/components/other/menubar.jsx +0 -96
- package/dist/components/other/mobile-icon.jsx +0 -11
- package/dist/components/other/navigation-menu.jsx +0 -62
- package/dist/components/other/pagination.jsx +0 -63
- package/dist/components/other/popover.jsx +0 -25
- package/dist/components/other/progress.jsx +0 -23
- package/dist/components/other/radio-group.jsx +0 -31
- package/dist/components/other/resizable.jsx +0 -29
- package/dist/components/other/scroll-area.jsx +0 -36
- package/dist/components/other/select.jsx +0 -83
- package/dist/components/other/separator.jsx +0 -21
- package/dist/components/other/sheet.jsx +0 -74
- package/dist/components/other/signup-popup.jsx +0 -1
- package/dist/components/other/skeleton.jsx +0 -17
- package/dist/components/other/slider.jsx +0 -26
- package/dist/components/other/social-icons.jsx +0 -15
- package/dist/components/other/sonner.jsx +0 -27
- package/dist/components/other/switch.jsx +0 -23
- package/dist/components/other/table.jsx +0 -56
- package/dist/components/other/tabs.jsx +0 -32
- package/dist/components/other/textarea.jsx +0 -19
- package/dist/components/other/toast.jsx +0 -58
- package/dist/components/other/toaster.jsx +0 -31
- package/dist/components/other/toggle-group.jsx +0 -41
- package/dist/components/other/toggle.jsx +0 -39
- package/dist/components/other/tooltip.jsx +0 -24
- package/dist/components/theme-provider.jsx +0 -18
- package/dist/components/types.js +0 -1
- package/dist/hooks/use-toast.js +0 -135
- package/dist/lib/auth-context.jsx +0 -144
- package/dist/lib/constants/about.js +0 -32
- package/dist/lib/constants/adRequest.js +0 -113
- package/dist/lib/constants/contact.js +0 -40
- package/dist/lib/constants/faq.js +0 -36
- package/dist/lib/constants/gallery.js +0 -42
- package/dist/lib/constants/page.js +0 -69
- package/dist/lib/constants/schedule.js +0 -71
- package/dist/lib/google-analytics.jsx +0 -148
- package/dist/lib/utils.js +0 -9
- package/dist/lib/verify-user.js +0 -142
- package/dist/middleware.js +0 -37
- package/dist/tailwind.config.js +0 -86
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/lib/auth-context.tsx +0 -131
- package/lib/verify-user.ts +0 -118
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
import React, { useEffect, useRef, useCallback, useState } from 'react';
|
|
50
|
-
import { motion, AnimatePresence } from 'framer-motion';
|
|
51
|
-
import { CloseButton, ToggleButton, UpdateButton, CancelButton, ChatToggleButton, ChatSubmitButton, DeleteButton } from '@/components/other/button'; // Updated import
|
|
52
|
-
import { Input } from '@/components/other/input';
|
|
53
|
-
import { Label } from '@/components/other/label';
|
|
54
|
-
import { X, ChevronLeft, ChevronRight } from 'lucide-react';
|
|
55
|
-
import { useAuth, useUser } from '@clerk/nextjs';
|
|
56
|
-
import { useStrapiAuth } from '@/lib/auth-context';
|
|
57
|
-
import { useChat } from 'ai/react';
|
|
58
|
-
var BlogFormPopUp = function (_a) {
|
|
59
|
-
var isModalOpen = _a.isModalOpen, setIsModalOpen = _a.setIsModalOpen, isConfirmDeleteOpen = _a.isConfirmDeleteOpen, setIsConfirmDeleteOpen = _a.setIsConfirmDeleteOpen, postToDelete = _a.postToDelete, setPostToDelete = _a.setPostToDelete, isLoading = _a.isLoading, setIsLoading = _a.setIsLoading, formData = _a.formData, setFormData = _a.setFormData, setError = _a.setError, setShowSuccess = _a.setShowSuccess, fetchData = _a.fetchData;
|
|
60
|
-
var _b = useState(null), formError = _b[0], setFormError = _b[1];
|
|
61
|
-
var _c = useState(false), isChatbotOpen = _c[0], setIsChatbotOpen = _c[1];
|
|
62
|
-
var _d = useState(false), showKeywords = _d[0], setShowKeywords = _d[1];
|
|
63
|
-
var _e = useState(formData.title.length), titleCharCount = _e[0], setTitleCharCount = _e[1];
|
|
64
|
-
var _f = useState(formData.title.trim().split(/\s+/).filter(Boolean).length), titleWordCount = _f[0], setTitleWordCount = _f[1];
|
|
65
|
-
var _g = useState(formData.description.length), descriptionCharCount = _g[0], setDescriptionCharCount = _g[1];
|
|
66
|
-
var _h = useState(formData.description.trim().split(/\s+/).filter(Boolean).length), descriptionWordCount = _h[0], setDescriptionWordCount = _h[1];
|
|
67
|
-
var modalRef = useRef(null);
|
|
68
|
-
var descriptionRef = useRef(null);
|
|
69
|
-
var _j = useStrapiAuth(), user = _j.user, authLoading = _j.authLoading;
|
|
70
|
-
var _k = useAuth(), getToken = _k.getToken, isSignedIn = _k.isSignedIn;
|
|
71
|
-
var clerkUser = useUser().user;
|
|
72
|
-
var _l = useState(0), scrollPosition = _l[0], setScrollPosition = _l[1];
|
|
73
|
-
var seoKeywords = [
|
|
74
|
-
'fitness training',
|
|
75
|
-
'gym workout plans',
|
|
76
|
-
'strength exercises',
|
|
77
|
-
'cardio routines',
|
|
78
|
-
'weight loss tips',
|
|
79
|
-
'muscle building',
|
|
80
|
-
'home workouts',
|
|
81
|
-
'personal trainer',
|
|
82
|
-
'fitness motivation',
|
|
83
|
-
'healthy lifestyle',
|
|
84
|
-
'gym equipment',
|
|
85
|
-
'bodybuilding tips',
|
|
86
|
-
'HIIT workouts',
|
|
87
|
-
'nutrition for fitness',
|
|
88
|
-
'exercise routines',
|
|
89
|
-
];
|
|
90
|
-
var _m = useChat({
|
|
91
|
-
api: '/api/chat',
|
|
92
|
-
initialMessages: [
|
|
93
|
-
{
|
|
94
|
-
id: 'system-prompt',
|
|
95
|
-
role: 'system',
|
|
96
|
-
content: "You are an AI assistant helping with blog writing and SEO optimization. You are aware of the current blog post's title: \"".concat(formData.title, "\", description: \"").concat(formData.description, "\", and the following SEO keywords: ").concat(seoKeywords.join(', '), ". Provide suggestions to improve the blog post's SEO, such as keyword usage, content structure, or meta descriptions. Respond concisely and relevantly to user queries."),
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
}), messages = _m.messages, input = _m.input, handleInputChange = _m.handleInputChange, handleChatSubmit = _m.handleSubmit, isChatLoading = _m.isLoading, error = _m.error;
|
|
100
|
-
useEffect(function () {
|
|
101
|
-
}, [user, clerkUser]);
|
|
102
|
-
var handleClose = useCallback(function () {
|
|
103
|
-
setIsModalOpen(false);
|
|
104
|
-
setFormData({
|
|
105
|
-
id: 0,
|
|
106
|
-
documentId: '',
|
|
107
|
-
title: '',
|
|
108
|
-
description: '',
|
|
109
|
-
author: (user === null || user === void 0 ? void 0 : user.businessTitle) || (clerkUser === null || clerkUser === void 0 ? void 0 : clerkUser.username) || (user === null || user === void 0 ? void 0 : user.username) || 'Anonymous',
|
|
110
|
-
publishedAt: '',
|
|
111
|
-
});
|
|
112
|
-
setFormError(null);
|
|
113
|
-
setIsChatbotOpen(false);
|
|
114
|
-
setShowKeywords(false);
|
|
115
|
-
setTitleCharCount(0);
|
|
116
|
-
setTitleWordCount(0);
|
|
117
|
-
setDescriptionCharCount(0);
|
|
118
|
-
setDescriptionWordCount(0);
|
|
119
|
-
window.scrollTo({ top: scrollPosition, behavior: 'smooth' });
|
|
120
|
-
}, [setIsModalOpen, setFormData, user, clerkUser, scrollPosition]);
|
|
121
|
-
var handleKeywordClick = useCallback(function (keyword) {
|
|
122
|
-
var textarea = descriptionRef.current;
|
|
123
|
-
if (!textarea) {
|
|
124
|
-
setFormError('Text area not initialized');
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
var start = textarea.selectionStart;
|
|
128
|
-
var end = textarea.selectionEnd;
|
|
129
|
-
var text = formData.description;
|
|
130
|
-
var newText = text.substring(0, start) + "".concat(keyword, " ") + text.substring(end);
|
|
131
|
-
var truncatedText = newText.slice(0, 1500);
|
|
132
|
-
setFormData(__assign(__assign({}, formData), { description: truncatedText }));
|
|
133
|
-
setDescriptionCharCount(truncatedText.length);
|
|
134
|
-
setDescriptionWordCount(truncatedText.trim().split(/\s+/).filter(Boolean).length);
|
|
135
|
-
setTimeout(function () {
|
|
136
|
-
textarea.focus();
|
|
137
|
-
textarea.selectionStart = textarea.selectionEnd = start + keyword.length + 1;
|
|
138
|
-
}, 0);
|
|
139
|
-
}, [formData, setFormData]);
|
|
140
|
-
var handleConfirmDelete = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
-
var token, response, errorData, err_1;
|
|
142
|
-
return __generator(this, function (_a) {
|
|
143
|
-
switch (_a.label) {
|
|
144
|
-
case 0:
|
|
145
|
-
if (!postToDelete)
|
|
146
|
-
return [2 /*return*/];
|
|
147
|
-
setIsLoading(true);
|
|
148
|
-
setError(null);
|
|
149
|
-
_a.label = 1;
|
|
150
|
-
case 1:
|
|
151
|
-
_a.trys.push([1, 7, 8, 9]);
|
|
152
|
-
return [4 /*yield*/, getToken()];
|
|
153
|
-
case 2:
|
|
154
|
-
token = _a.sent();
|
|
155
|
-
return [4 /*yield*/, fetch('/api/blog', {
|
|
156
|
-
method: 'DELETE',
|
|
157
|
-
headers: {
|
|
158
|
-
'Content-Type': 'application/json',
|
|
159
|
-
Authorization: "Bearer ".concat(token),
|
|
160
|
-
},
|
|
161
|
-
body: JSON.stringify({ documentId: postToDelete.documentId }),
|
|
162
|
-
})];
|
|
163
|
-
case 3:
|
|
164
|
-
response = _a.sent();
|
|
165
|
-
if (!!response.ok) return [3 /*break*/, 5];
|
|
166
|
-
return [4 /*yield*/, response.json()];
|
|
167
|
-
case 4:
|
|
168
|
-
errorData = _a.sent();
|
|
169
|
-
throw new Error(errorData.error || 'Failed to delete blog post');
|
|
170
|
-
case 5: return [4 /*yield*/, fetchData()];
|
|
171
|
-
case 6:
|
|
172
|
-
_a.sent();
|
|
173
|
-
setIsConfirmDeleteOpen(false);
|
|
174
|
-
setPostToDelete(null);
|
|
175
|
-
return [3 /*break*/, 9];
|
|
176
|
-
case 7:
|
|
177
|
-
err_1 = _a.sent();
|
|
178
|
-
setError(err_1 instanceof Error ? err_1.message : 'An unknown error occurred');
|
|
179
|
-
return [3 /*break*/, 9];
|
|
180
|
-
case 8:
|
|
181
|
-
setIsLoading(false);
|
|
182
|
-
return [7 /*endfinally*/];
|
|
183
|
-
case 9: return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}); };
|
|
187
|
-
var handleCancelDelete = function () {
|
|
188
|
-
setIsConfirmDeleteOpen(false);
|
|
189
|
-
setPostToDelete(null);
|
|
190
|
-
window.scrollTo({ top: scrollPosition, behavior: 'smooth' });
|
|
191
|
-
};
|
|
192
|
-
useEffect(function () {
|
|
193
|
-
if (isModalOpen) {
|
|
194
|
-
if (authLoading) {
|
|
195
|
-
setFormError('Authentication is still loading, please wait...');
|
|
196
|
-
}
|
|
197
|
-
else if (!isSignedIn || !user || !(clerkUser === null || clerkUser === void 0 ? void 0 : clerkUser.id)) {
|
|
198
|
-
setFormError('You must be signed in to create or edit a blog post');
|
|
199
|
-
setFormData(__assign(__assign({}, formData), { author: 'Anonymous' }));
|
|
200
|
-
}
|
|
201
|
-
else if (user === null || user === void 0 ? void 0 : user.businessTitle) {
|
|
202
|
-
setFormData(__assign(__assign({}, formData), { author: user.businessTitle }));
|
|
203
|
-
setFormError(null);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
setFormData(__assign(__assign({}, formData), { author: (clerkUser === null || clerkUser === void 0 ? void 0 : clerkUser.username) || (user === null || user === void 0 ? void 0 : user.username) || 'Anonymous' }));
|
|
207
|
-
setFormError('Business title not found; using username or default author name');
|
|
208
|
-
}
|
|
209
|
-
setTitleCharCount(formData.title.length);
|
|
210
|
-
setTitleWordCount(formData.title.trim().split(/\s+/).filter(Boolean).length);
|
|
211
|
-
setDescriptionCharCount(formData.description.length);
|
|
212
|
-
setDescriptionWordCount(formData.description.trim().split(/\s+/).filter(Boolean).length);
|
|
213
|
-
}
|
|
214
|
-
}, [isModalOpen, user, isSignedIn, clerkUser, authLoading, setFormData, formData.title, formData.description]);
|
|
215
|
-
useEffect(function () {
|
|
216
|
-
if (isModalOpen && modalRef.current) {
|
|
217
|
-
setScrollPosition(window.scrollY);
|
|
218
|
-
var modal_1 = modalRef.current;
|
|
219
|
-
var focusableElements_1 = modal_1.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
220
|
-
var firstElement_1 = focusableElements_1[0];
|
|
221
|
-
if (firstElement_1) {
|
|
222
|
-
firstElement_1.focus({ preventScroll: true });
|
|
223
|
-
}
|
|
224
|
-
var handleKeyDown_1 = function (e) {
|
|
225
|
-
if (e.key === 'Tab') {
|
|
226
|
-
var lastElement = focusableElements_1[focusableElements_1.length - 1];
|
|
227
|
-
if (document.activeElement === lastElement && !e.shiftKey) {
|
|
228
|
-
e.preventDefault();
|
|
229
|
-
firstElement_1.focus({ preventScroll: true });
|
|
230
|
-
}
|
|
231
|
-
if (document.activeElement === firstElement_1 && e.shiftKey) {
|
|
232
|
-
e.preventDefault();
|
|
233
|
-
lastElement.focus({ preventScroll: true });
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (e.key === 'Escape') {
|
|
237
|
-
handleClose();
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
modal_1.addEventListener('keydown', handleKeyDown_1);
|
|
241
|
-
return function () { return modal_1.removeEventListener('keydown', handleKeyDown_1); };
|
|
242
|
-
}
|
|
243
|
-
}, [isModalOpen, handleClose]);
|
|
244
|
-
useEffect(function () {
|
|
245
|
-
if (isModalOpen || isConfirmDeleteOpen) {
|
|
246
|
-
var scrollY_1 = window.scrollY;
|
|
247
|
-
document.body.style.position = 'fixed';
|
|
248
|
-
document.body.style.top = "-".concat(scrollY_1, "px");
|
|
249
|
-
document.body.style.width = '100%';
|
|
250
|
-
document.body.classList.add('overflow-hidden');
|
|
251
|
-
setScrollPosition(scrollY_1);
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
var scrollY_2 = scrollPosition;
|
|
255
|
-
document.body.style.position = '';
|
|
256
|
-
document.body.style.top = '';
|
|
257
|
-
document.body.style.width = '';
|
|
258
|
-
document.body.classList.remove('overflow-hidden');
|
|
259
|
-
window.scrollTo({ top: scrollY_2, behavior: 'instant' });
|
|
260
|
-
}
|
|
261
|
-
return function () {
|
|
262
|
-
document.body.style.position = '';
|
|
263
|
-
document.body.style.top = '';
|
|
264
|
-
document.body.style.width = '';
|
|
265
|
-
document.body.classList.remove('overflow-hidden');
|
|
266
|
-
};
|
|
267
|
-
}, [isModalOpen, isConfirmDeleteOpen, scrollPosition]);
|
|
268
|
-
useEffect(function () {
|
|
269
|
-
var event = new CustomEvent('modalStateChange', {
|
|
270
|
-
detail: { isOpen: isModalOpen || isConfirmDeleteOpen },
|
|
271
|
-
});
|
|
272
|
-
window.dispatchEvent(event);
|
|
273
|
-
}, [isModalOpen, isConfirmDeleteOpen]);
|
|
274
|
-
var handleTitleChange = function (e) {
|
|
275
|
-
var value = e.target.value.slice(0, 50);
|
|
276
|
-
setFormData(__assign(__assign({}, formData), { title: value }));
|
|
277
|
-
setTitleCharCount(value.length);
|
|
278
|
-
setTitleWordCount(value.trim().split(/\s+/).filter(Boolean).length);
|
|
279
|
-
};
|
|
280
|
-
var handleDescriptionChange = function (e) {
|
|
281
|
-
var value = e.target.value.slice(0, 1500);
|
|
282
|
-
setFormData(__assign(__assign({}, formData), { description: value }));
|
|
283
|
-
setDescriptionCharCount(value.length);
|
|
284
|
-
setDescriptionWordCount(value.trim().split(/\s+/).filter(Boolean).length);
|
|
285
|
-
};
|
|
286
|
-
var onSubmit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
287
|
-
var token, response, errorData, err_2;
|
|
288
|
-
return __generator(this, function (_a) {
|
|
289
|
-
switch (_a.label) {
|
|
290
|
-
case 0:
|
|
291
|
-
e.preventDefault();
|
|
292
|
-
if (!isSignedIn || !user || !(clerkUser === null || clerkUser === void 0 ? void 0 : clerkUser.id)) {
|
|
293
|
-
setError('You must be signed in to submit a blog post');
|
|
294
|
-
return [2 /*return*/];
|
|
295
|
-
}
|
|
296
|
-
if (!formData.title || !formData.description || !formData.author) {
|
|
297
|
-
setFormError('Please fill in all required fields');
|
|
298
|
-
return [2 /*return*/];
|
|
299
|
-
}
|
|
300
|
-
setIsLoading(true);
|
|
301
|
-
setFormError(null);
|
|
302
|
-
_a.label = 1;
|
|
303
|
-
case 1:
|
|
304
|
-
_a.trys.push([1, 7, 8, 9]);
|
|
305
|
-
return [4 /*yield*/, getToken()];
|
|
306
|
-
case 2:
|
|
307
|
-
token = _a.sent();
|
|
308
|
-
return [4 /*yield*/, fetch('/api/blog', {
|
|
309
|
-
method: formData.id ? 'PUT' : 'POST',
|
|
310
|
-
headers: {
|
|
311
|
-
'Content-Type': 'application/json',
|
|
312
|
-
Authorization: "Bearer ".concat(token),
|
|
313
|
-
},
|
|
314
|
-
body: JSON.stringify({
|
|
315
|
-
documentId: formData.documentId,
|
|
316
|
-
data: {
|
|
317
|
-
title: formData.title,
|
|
318
|
-
description: formData.description,
|
|
319
|
-
author: formData.author,
|
|
320
|
-
publishedAt: formData.publishedAt || new Date().toISOString(),
|
|
321
|
-
},
|
|
322
|
-
}),
|
|
323
|
-
})];
|
|
324
|
-
case 3:
|
|
325
|
-
response = _a.sent();
|
|
326
|
-
if (!!response.ok) return [3 /*break*/, 5];
|
|
327
|
-
return [4 /*yield*/, response.json()];
|
|
328
|
-
case 4:
|
|
329
|
-
errorData = _a.sent();
|
|
330
|
-
throw new Error(errorData.error || 'Failed to submit blog post');
|
|
331
|
-
case 5: return [4 /*yield*/, fetchData()];
|
|
332
|
-
case 6:
|
|
333
|
-
_a.sent();
|
|
334
|
-
setShowSuccess(true);
|
|
335
|
-
setTimeout(function () { return setShowSuccess(false); }, 3000);
|
|
336
|
-
handleClose();
|
|
337
|
-
return [3 /*break*/, 9];
|
|
338
|
-
case 7:
|
|
339
|
-
err_2 = _a.sent();
|
|
340
|
-
setFormError(err_2 instanceof Error ? err_2.message : 'An unknown error occurred');
|
|
341
|
-
return [3 /*break*/, 9];
|
|
342
|
-
case 8:
|
|
343
|
-
setIsLoading(false);
|
|
344
|
-
return [7 /*endfinally*/];
|
|
345
|
-
case 9: return [2 /*return*/];
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
}); };
|
|
349
|
-
var modalVariants = {
|
|
350
|
-
hidden: { opacity: 0, y: '100vh' },
|
|
351
|
-
visible: { opacity: 1, y: 0, transition: { duration: 0.5, ease: [0.16, 1, 0.3, 1] } },
|
|
352
|
-
exit: { opacity: 0, y: '100vh', transition: { duration: 0.3, ease: 'easeIn' } },
|
|
353
|
-
};
|
|
354
|
-
return (<div>
|
|
355
|
-
{isModalOpen && (<motion.div variants={modalVariants} initial="hidden" animate="visible" exit="exit" className="fixed inset-0 flex items-center justify-center z-[10000] p-4" onClick={handleClose}>
|
|
356
|
-
<motion.div ref={modalRef} className="relative w-full max-w-5xl mx-4 bg-gray-800/90 backdrop-blur-lg rounded-2xl p-4 sm:p-6 max-h-[90vh] overflow-y-auto overflow-x-hidden flex flex-col sm:flex-row gap-4" onClick={function (e) { return e.stopPropagation(); }} role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
357
|
-
<div className="flex-1">
|
|
358
|
-
<div className="relative mb-6 pr-12">
|
|
359
|
-
<h3 id="modal-title" className="text-xl sm:text-2xl font-bold text-white">
|
|
360
|
-
{formData.id ? 'Edit Blog Post' : 'Add New Blog Post'}
|
|
361
|
-
</h3>
|
|
362
|
-
<CloseButton variant="close-form" onClick={handleClose}>
|
|
363
|
-
<X className="h-6 w-6 sm:h-8 sm:w-8"/>
|
|
364
|
-
</CloseButton>
|
|
365
|
-
</div>
|
|
366
|
-
<form onSubmit={onSubmit} className="space-y-4">
|
|
367
|
-
<div>
|
|
368
|
-
<Label htmlFor="title" className="block text-sm font-semibold text-gray-200 mb-2">
|
|
369
|
-
Title
|
|
370
|
-
</Label>
|
|
371
|
-
<Input id="title" type="text" placeholder="Enter post title" value={formData.title} onChange={handleTitleChange} maxLength={50} className="w-full bg-transparent text-white border-gray-400 rounded-md p-3 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500" required/>
|
|
372
|
-
<p className="text-sm text-gray-500 mt-1">
|
|
373
|
-
{titleCharCount}/50 characters, {titleWordCount} words
|
|
374
|
-
</p>
|
|
375
|
-
</div>
|
|
376
|
-
<div>
|
|
377
|
-
<Label htmlFor="author" className="block text-sm font-semibold text-gray-200 mb-2">
|
|
378
|
-
Author
|
|
379
|
-
</Label>
|
|
380
|
-
<Input id="author" type="text" value={formData.author} onChange={function (e) { return setFormData(__assign(__assign({}, formData), { author: e.target.value })); }} className="w-full bg-transparent text-white border-gray-400 rounded-md p-3 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500" required/>
|
|
381
|
-
</div>
|
|
382
|
-
<div>
|
|
383
|
-
<Label htmlFor="description" className="block text-sm font-semibold text-gray-200 mb-2">
|
|
384
|
-
Description
|
|
385
|
-
</Label>
|
|
386
|
-
<textarea ref={descriptionRef} id="description" placeholder="Enter post description" value={formData.description} onChange={handleDescriptionChange} maxLength={1500} className="w-full bg-transparent text-white border border-gray-400 rounded-md p-3 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 min-h-[150px]" required/>
|
|
387
|
-
<p className="text-sm text-gray-500 mt-1">
|
|
388
|
-
{descriptionCharCount}/1500 characters, {descriptionWordCount} words
|
|
389
|
-
</p>
|
|
390
|
-
</div>
|
|
391
|
-
<div>
|
|
392
|
-
<ToggleButton variant="toggle-keywords" onClick={function () { return setShowKeywords(!showKeywords); }} aria-expanded={showKeywords} aria-controls="seo-keywords">
|
|
393
|
-
{showKeywords ? 'Hide Keywords' : 'Show SEO Keywords'}
|
|
394
|
-
</ToggleButton>
|
|
395
|
-
{showKeywords && (<ul id="seo-keywords" className="mt-2 bg-gray-700 border border-gray-600 rounded-md p-4 max-h-40 overflow-y-auto text-white text-sm">
|
|
396
|
-
{seoKeywords.map(function (keyword, index) { return (<li key={index} onClick={function () { return handleKeywordClick(keyword); }} onKeyDown={function (e) {
|
|
397
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
398
|
-
e.preventDefault();
|
|
399
|
-
handleKeywordClick(keyword);
|
|
400
|
-
}
|
|
401
|
-
}} tabIndex={0} role="button" aria-label={"Insert keyword: ".concat(keyword)} className="cursor-pointer py-1 px-2 hover:bg-blue-500 hover:text-white rounded transition-colors break-words">
|
|
402
|
-
{keyword}
|
|
403
|
-
</li>); })}
|
|
404
|
-
</ul>)}
|
|
405
|
-
</div>
|
|
406
|
-
<div className="flex flex-col sm:flex-row gap-3 justify-end">
|
|
407
|
-
<UpdateButton type="submit" disabled={isLoading || !isSignedIn || !user || !(clerkUser === null || clerkUser === void 0 ? void 0 : clerkUser.id) || authLoading}>
|
|
408
|
-
{isLoading ? 'Saving...' : formData.id ? 'Update' : 'Submit'}
|
|
409
|
-
</UpdateButton>
|
|
410
|
-
<CancelButton type="button" onClick={handleClose}>
|
|
411
|
-
Cancel
|
|
412
|
-
</CancelButton>
|
|
413
|
-
</div>
|
|
414
|
-
{formError && <p className="text-red-500 text-sm font-semibold break-words">{formError}</p>}
|
|
415
|
-
</form>
|
|
416
|
-
</div>
|
|
417
|
-
<ChatToggleButton onClick={function () { return setIsChatbotOpen(!isChatbotOpen); }} aria-label={isChatbotOpen ? 'Close AI chatbot' : 'Open AI chatbot'}>
|
|
418
|
-
{isChatbotOpen ? (<ChevronLeft className="h-5 w-5 text-white"/>) : (<ChevronRight className="h-5 w-5 text-white"/>)}
|
|
419
|
-
</ChatToggleButton>
|
|
420
|
-
<AnimatePresence>
|
|
421
|
-
{isChatbotOpen && (<motion.div initial={{ opacity: 0, x: 50 }} animate={{ opacity: 1, x: 0 }} exit={{ opacity: 0, x: 50 }} transition={{ duration: 0.3, ease: 'easeInOut' }} className="hidden sm:flex flex-col w-72 bg-gray-700 border-l border-gray-600 p-4 max-h-[90vh] overflow-y-auto">
|
|
422
|
-
<h4 className="text-lg font-bold text-white mb-3">AI Chatbot is coming soon!</h4>
|
|
423
|
-
{error && <p className="text-red-500 text-sm bg-gray-800 p-2 rounded-md break-words">Error: {error.message}</p>}
|
|
424
|
-
<div className="flex-1 overflow-y-auto bg-gray-800 p-3 rounded-md border border-gray-600 break-words">
|
|
425
|
-
{messages
|
|
426
|
-
.filter(function (msg) { return msg.role !== 'system'; })
|
|
427
|
-
.map(function (msg, index) { return (<p key={index} className={"text-sm p-2 rounded-md mb-2 ".concat(msg.role === 'user' ? 'bg-blue-500 text-white text-right' : 'bg-gray-700 text-white text-left')}>
|
|
428
|
-
{msg.content}
|
|
429
|
-
</p>); })}
|
|
430
|
-
</div>
|
|
431
|
-
<form onSubmit={handleChatSubmit} className="flex gap-2 mt-3">
|
|
432
|
-
<Input value={input} onChange={handleInputChange} placeholder="Ask for suggestions..." disabled={isChatLoading} className="flex-1 bg-gray-800 text-white border-gray-600 rounded-md p-2 text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500"/>
|
|
433
|
-
<ChatSubmitButton type="submit" disabled={isChatLoading}>
|
|
434
|
-
{isChatLoading ? '⟳' : '➤'}
|
|
435
|
-
</ChatSubmitButton>
|
|
436
|
-
</form>
|
|
437
|
-
</motion.div>)}
|
|
438
|
-
</AnimatePresence>
|
|
439
|
-
</motion.div>
|
|
440
|
-
</motion.div>)}
|
|
441
|
-
|
|
442
|
-
{isConfirmDeleteOpen && postToDelete && (<motion.div variants={modalVariants} initial="hidden" animate="visible" exit="exit" className="fixed inset-0 bg-black/90 flex items-center justify-center z-[10000] p-4" onClick={handleCancelDelete} data-testid="confirm-modal-overlay">
|
|
443
|
-
<div className="relative w-full max-w-md mx-auto bg-gray-800/90 backdrop-blur-lg rounded-2xl p-4 sm:p-6 h-fit max-h-[90vh] overflow-y-auto" onClick={function (e) { return e.stopPropagation(); }}>
|
|
444
|
-
<CloseButton onClick={handleCancelDelete}>
|
|
445
|
-
<X className="h-6 w-6 sm:h-8 sm:w-8"/>
|
|
446
|
-
</CloseButton>
|
|
447
|
-
<h3 id="modal-title" className="text-xl font-bold text-white mb-4">
|
|
448
|
-
Confirm Deletion
|
|
449
|
-
</h3>
|
|
450
|
-
<p className="text-white text-sm mb-4">
|
|
451
|
-
Are you sure you want to delete the post "{postToDelete.title}"? This action cannot be undone.
|
|
452
|
-
</p>
|
|
453
|
-
<div className="flex flex-col sm:flex-row gap-3 justify-end">
|
|
454
|
-
<DeleteButton onClick={handleConfirmDelete} disabled={isLoading}>
|
|
455
|
-
{isLoading ? 'Deleting...' : 'Delete'}
|
|
456
|
-
</DeleteButton>
|
|
457
|
-
<CancelButton onClick={handleCancelDelete}>
|
|
458
|
-
Cancel
|
|
459
|
-
</CancelButton>
|
|
460
|
-
</div>
|
|
461
|
-
</div>
|
|
462
|
-
</motion.div>)}
|
|
463
|
-
</div>);
|
|
464
|
-
};
|
|
465
|
-
export default BlogFormPopUp;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import React, { useState, useEffect, useRef } from "react";
|
|
49
|
-
import { useRouter } from "next/navigation";
|
|
50
|
-
import { Card, CardContent, CardHeader, CardTitle } from "@/components/other/card";
|
|
51
|
-
import { Calendar } from "lucide-react";
|
|
52
|
-
import Spinner from "@/components/addOns/non-functional/spinner";
|
|
53
|
-
import { BLOG_LIST } from "./constants/blogList";
|
|
54
|
-
export default function BlogList() {
|
|
55
|
-
var _this = this;
|
|
56
|
-
var router = useRouter();
|
|
57
|
-
var _a = useState([]), posts = _a[0], setPosts = _a[1];
|
|
58
|
-
var _b = useState(true), isLoading = _b[0], setIsLoading = _b[1];
|
|
59
|
-
var _c = useState(null), error = _c[0], setError = _c[1];
|
|
60
|
-
var _d = useState(false), isMobile = _d[0], setIsMobile = _d[1];
|
|
61
|
-
var hasFetched = useRef(false);
|
|
62
|
-
useEffect(function () {
|
|
63
|
-
var handleResize = function () {
|
|
64
|
-
setIsMobile(window.innerWidth < 640);
|
|
65
|
-
};
|
|
66
|
-
handleResize();
|
|
67
|
-
window.addEventListener("resize", handleResize);
|
|
68
|
-
return function () { return window.removeEventListener("resize", handleResize); };
|
|
69
|
-
}, []);
|
|
70
|
-
useEffect(function () {
|
|
71
|
-
if (hasFetched.current)
|
|
72
|
-
return;
|
|
73
|
-
hasFetched.current = true;
|
|
74
|
-
var fetchPosts = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
75
|
-
var response, errorData, data, blogPosts, err_1;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
setIsLoading(true);
|
|
80
|
-
_a.label = 1;
|
|
81
|
-
case 1:
|
|
82
|
-
_a.trys.push([1, 6, 7, 8]);
|
|
83
|
-
return [4 /*yield*/, fetch("/api/blog", {
|
|
84
|
-
headers: { "Content-Type": "application/json" },
|
|
85
|
-
cache: "no-store",
|
|
86
|
-
})];
|
|
87
|
-
case 2:
|
|
88
|
-
response = _a.sent();
|
|
89
|
-
if (!!response.ok) return [3 /*break*/, 4];
|
|
90
|
-
return [4 /*yield*/, response.json()];
|
|
91
|
-
case 3:
|
|
92
|
-
errorData = _a.sent();
|
|
93
|
-
throw new Error(errorData.error || BLOG_LIST.ERRORS.FETCH_FAILED);
|
|
94
|
-
case 4: return [4 /*yield*/, response.json()];
|
|
95
|
-
case 5:
|
|
96
|
-
data = (_a.sent()).data;
|
|
97
|
-
blogPosts = data.blogPosts.map(function (p) { return (__assign(__assign({}, p), { publishedAt: new Date(p.publishedAt).toISOString() })); });
|
|
98
|
-
setPosts(blogPosts);
|
|
99
|
-
return [3 /*break*/, 8];
|
|
100
|
-
case 6:
|
|
101
|
-
err_1 = _a.sent();
|
|
102
|
-
setError(err_1 instanceof Error ? err_1.message : BLOG_LIST.ERRORS.UNKNOWN_ERROR);
|
|
103
|
-
return [3 /*break*/, 8];
|
|
104
|
-
case 7:
|
|
105
|
-
setIsLoading(false);
|
|
106
|
-
return [7 /*endfinally*/];
|
|
107
|
-
case 8: return [2 /*return*/];
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}); };
|
|
111
|
-
fetchPosts();
|
|
112
|
-
}, []);
|
|
113
|
-
var truncateText = function (text, field) {
|
|
114
|
-
var maxLength = isMobile ? (field === "authorDate" ? 30 : 20) : 50;
|
|
115
|
-
if (text.length <= maxLength)
|
|
116
|
-
return text;
|
|
117
|
-
return text.slice(0, maxLength - 3) + "...";
|
|
118
|
-
};
|
|
119
|
-
if (isLoading) {
|
|
120
|
-
return (<div className="py-8 text-center">
|
|
121
|
-
<Spinner />
|
|
122
|
-
</div>);
|
|
123
|
-
}
|
|
124
|
-
return (<div className="w-full bg-[#1E2A44] border-none outline-none z-0 px-0 py-8 sm:px-6 sm:py-16 md:p-8">
|
|
125
|
-
<style jsx>{"\n .file-item {\n z-index: 30;\n pointer-events: auto;\n cursor: pointer;\n }\n "}</style>
|
|
126
|
-
<section className="relative z-10">
|
|
127
|
-
<div className="w-full max-w-7xl mx-auto">
|
|
128
|
-
<Card className="w-full max-w-7xl mx-auto p-4 sm:p-8 text-white flex flex-col items-center space-y-6 bg-[#1E2A44] border-none rounded-none">
|
|
129
|
-
<CardHeader className="pb-4 text-center">
|
|
130
|
-
<CardTitle className="text-2xl sm:text-3xl md:text-4xl font-bold tracking-tight text-white">
|
|
131
|
-
{BLOG_LIST.UI.CARD_TITLE}
|
|
132
|
-
</CardTitle>
|
|
133
|
-
<p className="text-gray-300 text-base sm:text-lg md:text-xl">
|
|
134
|
-
{BLOG_LIST.UI.CARD_DESCRIPTION}
|
|
135
|
-
</p>
|
|
136
|
-
</CardHeader>
|
|
137
|
-
<CardContent className="w-full space-y-4">
|
|
138
|
-
{error && (<p className="text-red-400 text-base sm:text-lg md:text-xl text-center">
|
|
139
|
-
{error}
|
|
140
|
-
</p>)}
|
|
141
|
-
{posts.length > 0 ? (<div className="space-y-4 max-h-[400px] overflow-y-auto">
|
|
142
|
-
{posts.map(function (post) { return (<div key={post.id} className="file-item w-full flex flex-col sm:flex-row items-start sm:items-center justify-between p-3 sm:p-4 rounded-lg bg-[#2A3A66]/50 hover:bg-[#2A3A66]/70 hover:shadow-lg hover:border-[#FF69B4]/50 transition-all cursor-pointer" onClick={function () { return router.push("/blog/".concat(post.id)); }} role="link" aria-label={"View post: ".concat(post.title)}>
|
|
143
|
-
<div className="flex flex-col w-full">
|
|
144
|
-
<h4 className="font-bold text-base sm:text-lg md:text-xl text-white mb-1 truncate">
|
|
145
|
-
{truncateText(post.title, "title")}
|
|
146
|
-
</h4>
|
|
147
|
-
<div className="flex items-center gap-2 text-sm text-gray-300">
|
|
148
|
-
<Calendar className="h-4 w-4 sm:h-5 sm:w-5 text-[#FF69B4] flex-shrink-0"/>
|
|
149
|
-
<span>
|
|
150
|
-
{truncateText("By ".concat(post.author, " | ").concat(new Date(post.publishedAt).toLocaleDateString("en-US", {
|
|
151
|
-
year: "numeric",
|
|
152
|
-
month: "short",
|
|
153
|
-
day: "numeric",
|
|
154
|
-
})), "authorDate")}
|
|
155
|
-
</span>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
{/* <p className="text-sm text-gray-300 mt-2 sm:mt-0 sm:ml-4 w-full sm:w-auto flex-1 truncate">
|
|
159
|
-
{truncateText(post.description, "description")}
|
|
160
|
-
</p> */}
|
|
161
|
-
</div>); })}
|
|
162
|
-
</div>) : (<p className="text-gray-300 font-bold text-base sm:text-lg md:text-xl text-center">
|
|
163
|
-
{BLOG_LIST.UI.NO_POSTS_MESSAGE}
|
|
164
|
-
</p>)}
|
|
165
|
-
</CardContent>
|
|
166
|
-
</Card>
|
|
167
|
-
</div>
|
|
168
|
-
</section>
|
|
169
|
-
</div>);
|
|
170
|
-
}
|