@hed-hog/core 0.0.292 → 0.0.294

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,29 @@
1
- 'use client';
2
-
3
- import { Dashboard } from '@hed-hog/api-types';
4
- import { useApp, useQuery } from '@hed-hog/next-app-provider';
5
- import { useRouter } from 'next/navigation';
6
- import { useEffect } from 'react';
7
-
8
- export default function DashboardRedirectPage() {
9
- const router = useRouter();
10
- const { request, currentLocaleCode } = useApp();
11
-
12
- const { data: dashboardData, isLoading } = useQuery<Dashboard | null>({
13
- queryKey: ['dashboard-home-redirect', currentLocaleCode],
14
- queryFn: async () => {
15
- const response = await request<Dashboard>({
16
- url: '/dashboard-core/home',
17
- });
18
- return response.data ?? null;
19
- },
20
- });
21
-
22
- useEffect(() => {
23
- if (isLoading) return;
24
-
25
- router.replace(`/core/dashboard/${dashboardData?.slug ?? 'default'}`);
26
- }, [dashboardData?.slug, isLoading, router]);
27
-
28
- return null;
29
- }
1
+ 'use client';
2
+
3
+ import { Dashboard } from '@hed-hog/api-types';
4
+ import { useApp, useQuery } from '@hed-hog/next-app-provider';
5
+ import { useRouter } from 'next/navigation';
6
+ import { useEffect } from 'react';
7
+
8
+ export default function DashboardRedirectPage() {
9
+ const router = useRouter();
10
+ const { request, currentLocaleCode } = useApp();
11
+
12
+ const { data: dashboardData, isLoading } = useQuery<Dashboard | null>({
13
+ queryKey: ['dashboard-home-redirect', currentLocaleCode],
14
+ queryFn: async () => {
15
+ const response = await request<Dashboard>({
16
+ url: '/dashboard-core/home',
17
+ });
18
+ return response.data ?? null;
19
+ },
20
+ });
21
+
22
+ useEffect(() => {
23
+ if (isLoading) return;
24
+
25
+ router.replace(`/core/dashboard/${dashboardData?.slug ?? 'default'}`);
26
+ }, [dashboardData?.slug, isLoading, router]);
27
+
28
+ return null;
29
+ }
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import dynamic from 'next/dynamic';
3
4
  import type React from 'react';
4
5
 
5
6
  import {
@@ -9,7 +10,6 @@ import {
9
10
  PaginationFooter,
10
11
  SearchBar,
11
12
  } from '@/components/entity-list';
12
- import { RichTextEditor } from '@/components/rich-text-editor';
13
13
  import {
14
14
  AlertDialog,
15
15
  AlertDialogAction,
@@ -70,6 +70,19 @@ import { useTranslations } from 'next-intl';
70
70
  import { useEffect, useState } from 'react';
71
71
  import { toast } from 'sonner';
72
72
 
73
+ const RichTextEditor = dynamic(
74
+ () =>
75
+ import('@/components/rich-text-editor').then((mod) => ({
76
+ default: mod.RichTextEditor,
77
+ })),
78
+ {
79
+ ssr: false,
80
+ loading: () => (
81
+ <div className="min-h-48 bg-muted rounded-md animate-pulse" />
82
+ ),
83
+ }
84
+ );
85
+
73
86
  interface Mail {
74
87
  id: number;
75
88
  slug: string;
@@ -779,7 +792,9 @@ export default function EmailTemplatesPage() {
779
792
  <TableHead>{t('tableSubject')}</TableHead>
780
793
  <TableHead>{t('tableVariables')}</TableHead>
781
794
  <TableHead>{t('tableUpdated')}</TableHead>
782
- <TableHead className="text-right">{t('tableActions')}</TableHead>
795
+ <TableHead className="text-right">
796
+ {t('tableActions')}
797
+ </TableHead>
783
798
  </TableRow>
784
799
  </TableHeader>
785
800
  <TableBody>
@@ -17,10 +17,30 @@ import { useApp, useQuery } from '@hed-hog/next-app-provider';
17
17
  import { zodResolver } from '@hookform/resolvers/zod';
18
18
  import { Loader } from 'lucide-react';
19
19
  import { useTranslations } from 'next-intl';
20
- import { useForm } from 'react-hook-form';
21
- import { z } from 'zod';
22
-
23
- export default function PreferencesPage() {
20
+ import { useForm } from 'react-hook-form';
21
+ import { z } from 'zod';
22
+
23
+ const THEME_SOURCE_STORAGE_KEY = 'theme-source';
24
+
25
+ const getStoredThemeSource = (): 'explicit' | 'fallback' | null => {
26
+ if (typeof window === 'undefined') return null;
27
+
28
+ const rawThemeSource = window.localStorage.getItem(THEME_SOURCE_STORAGE_KEY);
29
+ if (rawThemeSource === null) return null;
30
+
31
+ try {
32
+ const parsedThemeSource = JSON.parse(rawThemeSource);
33
+ return parsedThemeSource === 'explicit' || parsedThemeSource === 'fallback'
34
+ ? parsedThemeSource
35
+ : null;
36
+ } catch {
37
+ return rawThemeSource === 'explicit' || rawThemeSource === 'fallback'
38
+ ? rawThemeSource
39
+ : null;
40
+ }
41
+ };
42
+
43
+ export default function PreferencesPage() {
24
44
  const {
25
45
  currentTheme,
26
46
  setCurrentTheme,
@@ -73,23 +93,32 @@ export default function PreferencesPage() {
73
93
  theme: '',
74
94
  },
75
95
  });
76
-
77
- const handleThemeChange = async (value: 'light' | 'dark' | 'system') => {
78
- const previousTheme = currentTheme;
79
- setCurrentTheme(value);
80
-
81
- try {
96
+
97
+ const handleThemeChange = async (value: 'light' | 'dark' | 'system') => {
98
+ const previousTheme = currentTheme;
99
+ const previousThemeSource = getStoredThemeSource();
100
+ setCurrentTheme(value);
101
+
102
+ try {
82
103
  await request({
83
104
  url: '/profile/preferences',
84
105
  method: 'PUT',
85
106
  data: { theme: value },
86
107
  });
87
108
  await refetchUser();
88
- } catch (error) {
89
- setCurrentTheme(previousTheme);
90
- await refetchUser();
91
- showToastHandler(
92
- 'error',
109
+ } catch {
110
+ setCurrentTheme(previousTheme);
111
+
112
+ if (
113
+ typeof window !== 'undefined' &&
114
+ previousThemeSource !== 'explicit'
115
+ ) {
116
+ window.localStorage.removeItem(THEME_SOURCE_STORAGE_KEY);
117
+ }
118
+
119
+ await refetchUser();
120
+ showToastHandler(
121
+ 'error',
93
122
  t('themeUpdateError') || 'Failed to update theme'
94
123
  );
95
124
  }
@@ -103,7 +132,7 @@ export default function PreferencesPage() {
103
132
  data: { language: code },
104
133
  });
105
134
  await refetchUser();
106
- } catch (error) {
135
+ } catch {
107
136
  showToastHandler(
108
137
  'error',
109
138
  t('languageUpdateError') || 'Failed to update language'
@@ -119,7 +148,7 @@ export default function PreferencesPage() {
119
148
  'success',
120
149
  t('dateFormatUpdated') || 'Date format updated successfully'
121
150
  );
122
- } catch (error) {
151
+ } catch {
123
152
  showToastHandler(
124
153
  'error',
125
154
  t('dateFormatUpdateError') || 'Failed to update date format'
@@ -134,7 +163,7 @@ export default function PreferencesPage() {
134
163
  'success',
135
164
  t('timeFormatUpdated') || 'Time format updated successfully'
136
165
  );
137
- } catch (error) {
166
+ } catch {
138
167
  showToastHandler(
139
168
  'error',
140
169
  t('timeFormatUpdateError') || 'Failed to update time format'
@@ -149,7 +178,7 @@ export default function PreferencesPage() {
149
178
  'success',
150
179
  t('timezoneUpdated') || 'Timezone updated successfully'
151
180
  );
152
- } catch (error) {
181
+ } catch {
153
182
  showToastHandler(
154
183
  'error',
155
184
  t('timezoneUpdateError') || 'Failed to update timezone'
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@hed-hog/core",
3
- "version": "0.0.292",
3
+ "version": "0.0.294",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
7
- "@aws-sdk/client-s3": "^3.918.0",
8
- "@aws-sdk/s3-request-presigner": "^3.918.0",
7
+ "@aws-sdk/client-s3": "^3.1014.0",
8
+ "@aws-sdk/s3-request-presigner": "^3.1014.0",
9
9
  "@azure/storage-blob": "^12.27.0",
10
10
  "@google-cloud/storage": "^7.16.0",
11
11
  "@nestjs/axios": "*",
@@ -30,11 +30,11 @@
30
30
  "sharp": "^0.34.2",
31
31
  "speakeasy": "^2.0.0",
32
32
  "uuid": "^11.1.0",
33
- "@hed-hog/api-mail": "0.0.8",
34
- "@hed-hog/api-types": "0.0.1",
35
33
  "@hed-hog/api-pagination": "0.0.6",
36
34
  "@hed-hog/api-locale": "0.0.13",
37
35
  "@hed-hog/api": "0.0.4",
36
+ "@hed-hog/api-types": "0.0.1",
37
+ "@hed-hog/api-mail": "0.0.8",
38
38
  "@hed-hog/api-prisma": "0.0.5"
39
39
  },
40
40
  "exports": {
@@ -1,5 +1,5 @@
1
- import { PaginationDTO } from '@hed-hog/api-pagination';
2
- import { Prisma, PrismaService } from '@hed-hog/api-prisma';
1
+ import { PaginationDTO } from '@hed-hog/api-pagination';
2
+ import { Prisma, PrismaService } from '@hed-hog/api-prisma';
3
3
  import {
4
4
  BadRequestException,
5
5
  forwardRef,
@@ -8,7 +8,7 @@ import {
8
8
  Logger,
9
9
  NotFoundException,
10
10
  } from '@nestjs/common';
11
- import axios from 'axios';
11
+ import axios from 'axios';
12
12
  import { createHash } from 'crypto';
13
13
  import pdfParse from 'pdf-parse';
14
14
  import { DeleteDTO } from '../dto/delete.dto';
@@ -1,19 +1,19 @@
1
1
  import { Public, Role, User, UserOptional } from '@hed-hog/api';
2
2
  import { Locale } from '@hed-hog/api-locale';
3
- import {
4
- BadRequestException,
5
- Body,
6
- Controller,
7
- forwardRef,
3
+ import {
4
+ BadRequestException,
5
+ Body,
6
+ Controller,
7
+ forwardRef,
8
8
  Get,
9
9
  Headers,
10
10
  Inject,
11
- Ip,
12
- Post,
13
- Req,
14
- Res,
15
- UnauthorizedException,
16
- } from '@nestjs/common';
11
+ Ip,
12
+ Post,
13
+ Req,
14
+ Res,
15
+ UnauthorizedException,
16
+ } from '@nestjs/common';
17
17
  import { TokenService } from '../token/token.service';
18
18
  import { CreateWithEmailAndPasswordDTO } from '../user/dto/create-with-email-and-password.dto';
19
19
  import { UserService } from '../user/user.service';
@@ -1,14 +1,14 @@
1
1
  import { getLocaleText } from '@hed-hog/api-locale';
2
2
  import { PrismaService } from '@hed-hog/api-prisma';
3
3
  import { User } from '@hed-hog/api-types';
4
- import {
5
- BadRequestException,
6
- forwardRef,
7
- Inject,
8
- Injectable,
9
- NotFoundException,
10
- UnauthorizedException,
11
- } from '@nestjs/common';
4
+ import {
5
+ BadRequestException,
6
+ forwardRef,
7
+ Inject,
8
+ Injectable,
9
+ NotFoundException,
10
+ UnauthorizedException,
11
+ } from '@nestjs/common';
12
12
  import { ChallengeService } from '../challenge/challenge.service';
13
13
  import { MailService as MailManagerService } from '../mail/mail.service';
14
14
  import { SecurityService } from '../security/security.service';
@@ -1,7 +1,7 @@
1
- import { Prisma, PrismaService } from '@hed-hog/api-prisma';
2
- import { Injectable, Logger } from '@nestjs/common';
3
- import { Cron, CronExpression } from '@nestjs/schedule';
4
- import { SettingService } from '../setting/setting.service';
1
+ import { Prisma, PrismaService } from '@hed-hog/api-prisma';
2
+ import { Injectable, Logger } from '@nestjs/common';
3
+ import { Cron, CronExpression } from '@nestjs/schedule';
4
+ import { SettingService } from '../setting/setting.service';
5
5
 
6
6
  @Injectable()
7
7
  export class TasksService {
@@ -225,4 +225,4 @@ export class TasksService {
225
225
  `Unverified MFA with expired challenges cleaned up in ${Date.now() - startAt}ms`,
226
226
  );
227
227
  }
228
- }
228
+ }