Skip to content

Commit 5a70097

Browse files
committed
fix: Implement get total domains
1 parent 72f48d6 commit 5a70097

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/app/services/db-query-services/pg-database.service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,23 @@ SELECT domains.*, registrars.name AS registrar_name, tags.name AS tag_name, host
888888
throw error;
889889
}
890890
}
891+
892+
getTotalDomains(): Observable<number> {
893+
const query = `
894+
SELECT COUNT(*) AS total
895+
FROM domains
896+
`;
897+
898+
return this.pgApiUtil.postToPgExecutor<{ total: string }>(query).pipe(
899+
map(({ data }) => {
900+
if (!data || data.length === 0) {
901+
throw new Error('Failed to fetch total domains count');
902+
}
903+
return parseInt(data[0].total, 10) || 0;
904+
}),
905+
catchError((error) => this.handleError(error))
906+
);
907+
}
891908

892909
getDomainsByEppCodes(statuses: string[]): Observable<Record<string, { domainId: string; domainName: string }[]>> {
893910
const query = `

src/app/services/supabase.service.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,20 @@ export class SupabaseService {
320320
}
321321
}
322322

323+
async sendPasswordResetEmail(email: string): Promise<void> {
324+
const { error } = await this.supabase.auth.resetPasswordForEmail(email, {
325+
redirectTo: `${window.location.origin}/login?reset=true`,
326+
});
327+
328+
if (error) {
329+
this.errorHandler.handleError({
330+
message: 'Failed to send password reset email',
331+
error,
332+
location: 'SupabaseService.sendPasswordResetEmail',
333+
});
334+
}
335+
}
336+
323337
async verifyEmail() {
324338
// TODO: Implement email verification logic
325339
const { error } = await this.supabase.auth.getUser();
@@ -336,7 +350,8 @@ export class SupabaseService {
336350
/* Set password, used for when users have logged in via a social auth provider */
337351
async setPassword(newPassword: string): Promise<void> {
338352
const { error } = await this.supabase.auth.updateUser({ password: newPassword });
339-
if (error) { throw error; }
353+
if (error) throw error;
354+
340355
// Mark password as set, so we don't prompt user again
341356
const { error: metadataError } = await this.supabase.auth.updateUser({
342357
data: { has_password: true },

src/types/Database.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,5 @@ export abstract class DatabaseService {
149149
abstract updateDomain(domainId: string, domainData: SaveDomainData): Observable<DbDomain>;
150150
abstract checkAllTables(): Observable<{table: string; count: number | string; success: string;}[]>;
151151
abstract deleteAllData(userId: string, tables?: string[]): Promise<void>;
152+
abstract getTotalDomains(): Observable<number>;
152153
}

0 commit comments

Comments
 (0)