Skip to content

Commit

Permalink
Merge branch 'develop' into talawa-admin-t
Browse files Browse the repository at this point in the history
  • Loading branch information
Doraemon012 authored Sep 27, 2024
2 parents 8152c23 + 959399d commit b9d9c4c
Show file tree
Hide file tree
Showing 280 changed files with 19,085 additions and 31,981 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/compare_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ def compare_translations(default_translation,
errors.append(error_msg)
return errors

def flatten_json(nested_json, parent_key=""):
"""
Flattens a nested JSON, concatenating keys to represent the hierarchy.
Args:
nested_json (dict): The JSON object to flatten.
parent_key (str): The base key for recursion (used to track key hierarchy).
Returns:
dict: A flattened dictionary with concatenated keys.
"""
flat_dict = {}

for key, value in nested_json.items():
# Create the new key by concatenating parent and current key
new_key = f"{parent_key}.{key}" if parent_key else key

if isinstance(value, dict):
# Recursively flatten the nested dictionary
flat_dict.update(flatten_json(value, new_key))
else:
# Assign the value to the flattened key
flat_dict[new_key] = value

return flat_dict

def load_translation(filepath):
"""Load translation from a file.
Expand All @@ -104,7 +129,8 @@ def load_translation(filepath):
if not content.strip():
raise ValueError(f"File {filepath} is empty.")
translation = json.loads(content)
return translation
flattened_translation = flatten_json(translation)
return flattened_translation
except json.JSONDecodeError as e:
raise ValueError(f"Error decoding JSON from file {filepath}: {e}")

Expand Down Expand Up @@ -170,7 +196,7 @@ def main():
"--directory",
type=str,
nargs="?",
default=os.path.join(os.getcwd(), "locales"),
default=os.path.join(os.getcwd(), "public/locales"),
help="Directory containing translation files(relative to the root directory).",
)
args = parser.parse_args()
Expand Down
8 changes: 8 additions & 0 deletions config/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
presets: [
'@babel/preset-env', // Transforms modern JavaScript
'@babel/preset-typescript', // Transforms TypeScript
'@babel/preset-react', // Transforms JSX
],
plugins: ['babel-plugin-transform-import-meta'],
};
30 changes: 30 additions & 0 deletions config/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';
import EnvironmentPlugin from 'vite-plugin-environment';

export default defineConfig({
// depending on your application, base can also be "/"
build: {
outDir: 'build',
},
base: '',
plugins: [
react(),
viteTsconfigPaths(),
EnvironmentPlugin('all'),
svgrPlugin({
svgrOptions: {
icon: true,
// ...svgr options (https://react-svgr.com/docs/options/)
},
}),
],
server: {
// this ensures that the browser opens upon server start
open: true,
// this sets a default port to 3000
port: 4321,
},
});
15 changes: 10 additions & 5 deletions public/index.html → index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon_palisadoes.ico" />
<link rel="icon" href="/favicon_palisadoes.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="apple-touch-icon" href="/favicon.ico" />
<link rel="manifest" href="/manifest.json" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
Expand All @@ -18,10 +18,15 @@
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" referrerpolicy="no-referrer" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
referrerpolicy="no-referrer"
/>
<title>Talawa Admin</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
21 changes: 11 additions & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
export default {
roots: ['<rootDir>/src'],
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/index.tsx'],
setupFiles: ['react-app-polyfill/jsdom'],
// setupFiles: ['react-app-polyfill/jsdom'],
setupFiles: ['whatwg-fetch'],
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
],
testEnvironment: 'jsdom',
transform: {
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$':
'react-scripts/config/jest/babelTransform.js',
'^.+\\.(css|scss|sass|less)$': 'jest-preview/transforms/css',
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)':
'jest-preview/transforms/file',
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { configFile: "./config/babel.config.cjs" }], // Use babel-jest for JavaScript and TypeScript files
'^.+\\.(css|scss|sass|less)$': 'jest-preview/transforms/css', // CSS transformations
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': 'jest-preview/transforms/file', // File transformations
},
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$',
Expand All @@ -28,6 +27,8 @@ export default {
'^@dicebear/core$': '<rootDir>/scripts/__mocks__/@dicebear/core.ts',
'^@dicebear/collection$':
'<rootDir>/scripts/__mocks__/@dicebear/collection.ts',
'\\.svg\\?react$': '<rootDir>/scripts/__mocks__/fileMock.js',
'\\.svg$': '<rootDir>/scripts/__mocks__/fileMock.js',
},
moduleFileExtensions: [
'web.js',
Expand All @@ -41,10 +42,10 @@ export default {
'jsx',
'node',
],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
// watchPlugins: [
// 'jest-watch-typeahead/filename',
// 'jest-watch-typeahead/testname',
// ],
resetMocks: false,
coveragePathIgnorePatterns: [
'src/state/index.ts',
Expand Down
Loading

0 comments on commit b9d9c4c

Please sign in to comment.