Skip to content

Commit

Permalink
chore: Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Dec 10, 2024
1 parent f73707b commit 74ef1c9
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 19 deletions.
1 change: 0 additions & 1 deletion apps/frontend/src/plugins/admin/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@
"label": "Code",
"placeholder": "en",
"desc": "This code uses as a language identifier in your URL, like: /en/page",
"cannot_find_language_file_in_plugin": "Cannot find the language file in the plugin. You have to add the language file to the plugin first in dev mode.",
"already_exists": "Language with this code already exists."
},
"timezone": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ConflictException,
Injectable,
InternalServerErrorException,
NotFoundException,
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { existsSync } from 'fs';
Expand All @@ -24,6 +23,7 @@ export class CreateLanguagesAdminService {
) {}

private async cloneLangInPlugins(pluginCode: string) {
if (!this.configService.get('dev_mode')) return;
const plugins = await this.databaseService.db.query.core_plugins.findMany({
orderBy: (table, { desc }) => desc(table.updated_at),
columns: {
Expand All @@ -41,13 +41,6 @@ export class CreateLanguagesAdminService {
return;
}

// Throw error if language file not found in production
if (!this.configService.get('dev_mode')) {
throw new NotFoundException(
`CANNOT_FIND_LANGUAGE_FILE_IN_PLUGIN:${plugin.code}`,
);
}

await cp(join(pathToPluginLang, 'en.json'), path, {
recursive: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export const createMutationApi = async (body: CreateLanguagesAdminBody) => {
} catch (err) {
const { message } = err as Error;

if (message.includes('CANNOT_FIND_LANGUAGE_FILE_IN_PLUGIN')) {
return { message: 'CANNOT_FIND_LANGUAGE_FILE_IN_PLUGIN' };
}

if (message.includes('ALREADY_EXISTS')) {
return { message: 'ALREADY_EXISTS' };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ export const useCreateEditLangAdmin = ({
});

if (mutation?.message) {
if (mutation.message === 'CANNOT_FIND_LANGUAGE_FILE_IN_PLUGIN') {
form.setError('code', {
message: t('create.code.cannot_find_language_file_in_plugin'),
});
}

if (mutation.message === 'ALREADY_EXISTS') {
form.setError('code', {
message: t('create.code.already_exists'),
Expand Down

0 comments on commit 74ef1c9

Please sign in to comment.