mirror of
https://github.com/hexastack/hexabot
synced 2025-05-09 07:09:42 +00:00
fix: delete translation and refresh
This commit is contained in:
parent
6652629995
commit
c174d9d145
@ -8,9 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
BadRequestException,
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
|
HttpCode,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
Param,
|
Param,
|
||||||
Patch,
|
Patch,
|
||||||
@ -25,6 +28,7 @@ import { CsrfInterceptor } from '@/interceptors/csrf.interceptor';
|
|||||||
import { LoggerService } from '@/logger/logger.service';
|
import { LoggerService } from '@/logger/logger.service';
|
||||||
import { SettingService } from '@/setting/services/setting.service';
|
import { SettingService } from '@/setting/services/setting.service';
|
||||||
import { BaseController } from '@/utils/generics/base-controller';
|
import { BaseController } from '@/utils/generics/base-controller';
|
||||||
|
import { DeleteResult } from '@/utils/generics/base-repository';
|
||||||
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
||||||
import { PageQueryPipe } from '@/utils/pagination/pagination-query.pipe';
|
import { PageQueryPipe } from '@/utils/pagination/pagination-query.pipe';
|
||||||
import { SearchFilterPipe } from '@/utils/pipes/search-filter.pipe';
|
import { SearchFilterPipe } from '@/utils/pipes/search-filter.pipe';
|
||||||
@ -138,4 +142,23 @@ export class TranslationController extends BaseController<Translation> {
|
|||||||
str: { $nin: strings },
|
str: { $nin: strings },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a translation by its ID.
|
||||||
|
* @param id - The ID of the translation to be deleted.
|
||||||
|
* @returns A Promise that resolves to the deletion result.
|
||||||
|
*/
|
||||||
|
@CsrfCheck(true)
|
||||||
|
@Delete(':id')
|
||||||
|
@HttpCode(204)
|
||||||
|
async deleteOne(@Param('id') id: string): Promise<DeleteResult> {
|
||||||
|
const result = await this.translationService.deleteOne(id);
|
||||||
|
if (result.deletedCount === 0) {
|
||||||
|
this.logger.warn(`Unable to delete Translation by id ${id}`);
|
||||||
|
throw new BadRequestException(
|
||||||
|
`Unable to delete Translation with ID ${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ export const Translations = () => {
|
|||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
},
|
},
|
||||||
onSuccess: (data) => {
|
onSuccess: () => {
|
||||||
if (data.acknowledged && data.deletedCount > 0) refreshTranslations();
|
refreshTranslations();
|
||||||
toast.success(t("message.success_translation_refresh"));
|
toast.success(t("message.success_translation_refresh"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user