Snyk report fixes + offcanvas sidebar fix (#263)

Refactor:
- Improved consistency and robustness by standardizing file encoding arguments from 'utf-8' to 'utf8' across various file read/write operations.
- Simplified status mapping logic in billing components and services by replacing switch statements with direct mapping objects for clearer and more maintainable code.
- Enhanced type conversion and error handling in billing and internationalization components for improved reliability.
- Updated sorting logic in team member tables for more predictable member ordering.
- Improved error logging with sanitized output to prevent formatting issues.
- Adjusted environment variable whitelisting to use a more flexible matching pattern.
- Fix variables for sidebar style handling

Style:
- Refined spacing and layout in account selector and sidebar header components for better visual consistency.
This commit is contained in:
Giancarlo Buomprisco
2025-06-01 19:10:39 +07:00
committed by GitHub
parent cb80e4fdcf
commit fc2fda595a
18 changed files with 72 additions and 116 deletions

View File

@@ -37,7 +37,7 @@ export async function updateTranslationAction(props: z.infer<typeof Schema>) {
try {
// Read the current translations file
const translationsFile = readFileSync(filePath, 'utf-8');
const translationsFile = readFileSync(filePath, 'utf8');
const translations = JSON.parse(translationsFile) as Record<string, any>;
// Update the nested key value
@@ -60,7 +60,7 @@ export async function updateTranslationAction(props: z.infer<typeof Schema>) {
current[finalKey] = value;
// Write the updated translations back to the file
writeFileSync(filePath, JSON.stringify(translations, null, 2), 'utf-8');
writeFileSync(filePath, JSON.stringify(translations, null, 2), 'utf8');
revalidatePath(`/translations`);
@@ -95,7 +95,7 @@ export const translateWithAIAction = async (
if (!existsSync(filePath)) {
// create the file if it doesn't exist
writeFileSync(filePath, JSON.stringify({}, null, 2), 'utf-8');
writeFileSync(filePath, JSON.stringify({}, null, 2), 'utf8');
}
const results: Record<string, string> = {};

View File

@@ -265,12 +265,12 @@ export const envVariables: EnvVariableModel[] = [
{
name: 'NEXT_PUBLIC_SIDEBAR_COLLAPSIBLE_STYLE',
description:
'Defines sidebar collapse behavior. Options: offscreen, icon, or none.',
'Defines sidebar collapse behavior. Options: offcanvas, icon, or none.',
category: 'Navigation',
type: 'enum',
values: ['offscreen', 'icon', 'none'],
values: ['offcanvas', 'icon', 'none'],
validate: ({ value }) => {
return z.enum(['offscreen', 'icon', 'none']).optional().safeParse(value);
return z.enum(['offcanvas', 'icon', 'none']).optional().safeParse(value);
},
},
{

View File

@@ -53,10 +53,10 @@ export async function updateEnvironmentVariableAction(
const filePath = `${root}/apps/web/${source}`;
if (!existsSync(filePath)) {
writeFileSync(filePath, '', 'utf-8');
writeFileSync(filePath, '', 'utf8');
}
const sourceEnvFile = readFileSync(`${root}apps/web/${source}`, 'utf-8');
const sourceEnvFile = readFileSync(`${root}apps/web/${source}`, 'utf8');
let updatedEnvFile = '';
const isInSourceFile = sourceEnvFile.includes(name);
@@ -73,7 +73,7 @@ export async function updateEnvironmentVariableAction(
}
// write the updated content back to the file
writeFileSync(`${root}/apps/web/${source}`, updatedEnvFile, 'utf-8');
writeFileSync(`${root}/apps/web/${source}`, updatedEnvFile, 'utf8');
revalidatePath(`/variables`);