Skip to content

Commit 3c70158

Browse files
committed
Add useConfig hook & adjust imports
1 parent c71d0f6 commit 3c70158

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/core/email/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export * from './templates/base';
55
export * from './templates/formatted-date-time';
66
export * from './templates/frontend-url';
77
export * from './templates/user-ref';
8+
export * from './templates/useConfig';
89
export * from './templates/useResources';

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)