Skip to content

Commit 0f823c9

Browse files
committed
Add useConfig hook & adjust imports
1 parent 38cda43 commit 0f823c9

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/core/email/templates/formatted-date-time.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { useModuleRef } from '@seedcompany/nestjs-email/templates';
21
import { DateTime, type Zone } from 'luxon';
3-
import { ConfigService } from '~/core';
2+
import { useConfig } from './useConfig';
43

54
type ZoneLike = string | Zone;
65

@@ -10,7 +9,7 @@ export interface FormattedDateTimeProps {
109
}
1110

1211
export const FormattedDateTime = (props: FormattedDateTimeProps) => {
13-
const config = useModuleRef().get(ConfigService);
12+
const config = useConfig();
1413
const formatted = props.value
1514
.setZone(props.timezone ?? config.defaultTimeZone)
1615
.toLocaleString(DateTime.DATETIME_FULL);
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { useModuleRef } from '@seedcompany/nestjs-email/templates';
2-
import { ConfigService } from '~/core/config/config.service';
1+
import { useConfig } from './useConfig';
32

43
export const useFrontendUrl = (path: string) => {
54
path = path.startsWith('/') ? path.slice(1) : path;
6-
const config = useModuleRef().get(ConfigService);
5+
const config = useConfig();
76
return new URL(path, config.frontendUrl).toString();
87
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { useModuleRef } from '@seedcompany/nestjs-email/templates';
2+
import type { ConfigService } from '~/core';
3+
4+
export const useConfig = () =>
5+
useModuleRef().get<ConfigService>('CONFIG', { strict: false });

0 commit comments

Comments
 (0)