Skip to content

Commit

Permalink
Merge branch 'main' into giveconomy
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadPCh committed Jul 26, 2023
2 parents 582fc93 + d4cb098 commit 0e513a1
Show file tree
Hide file tree
Showing 132 changed files with 9,893 additions and 6,096 deletions.
2,538 changes: 1,314 additions & 1,224 deletions lang/ca.json

Large diffs are not rendered by default.

2,538 changes: 1,312 additions & 1,226 deletions lang/en.json

Large diffs are not rendered by default.

2,560 changes: 1,319 additions & 1,241 deletions lang/es.json

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions lang/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const fs = require('fs');

// Read the JSON file
const enJsonData = fs.readFileSync('en.json');
const en = JSON.parse(enJsonData);

const esJsonData = fs.readFileSync('es.json');
const es = JSON.parse(esJsonData);

const caJsonData = fs.readFileSync('ca.json');
const ca = JSON.parse(caJsonData);

function sort(data) {
// Convert object to array of key-value pairs
const dataArray = Object.entries(data);

// Sort the array based on the key
dataArray.sort((a, b) => {
const keyA = a[0].toUpperCase();
const keyB = b[0].toUpperCase();

if (keyA < keyB) {
return -1;
}
if (keyA > keyB) {
return 1;
}
return 0;
});

// Convert the sorted array back to an object
return Object.fromEntries(dataArray);
}

function addMissingKeys(obj) {
const newObj = { ...obj }; // Create a new object to avoid modifying obj directly

for (let key in en) {
if (en.hasOwnProperty(key) && !obj.hasOwnProperty(key)) {
newObj[key] = en[key];
}
}

return newObj;
}

function fillEmptyValues(obj) {
for (let key in obj) {
if (obj.hasOwnProperty(key) && obj[key] === '') {
obj[key] = en[key];
}
}

return obj;
}

function save(obj, name) {
// Write the sorted data back to the JSON file
fs.writeFileSync(name, JSON.stringify(obj, null, 2));

console.log('Saving completed!');
}

function removeExtraKeys(obj) {
const newObj = {}; // Create a new object to avoid modifying obj directly
for (let key in obj) {
if (obj.hasOwnProperty(key) && en[key]) {
newObj[key] = obj[key];
}
}
return newObj;
}

const filteredEs = removeExtraKeys(es);
const filteredCa = removeExtraKeys(ca);

const updatedEs = addMissingKeys(filteredEs);
const updatedCa = addMissingKeys(filteredCa);

const sortedEn = sort(en);
const sortedEs = sort(updatedEs);
const sortedCa = sort(updatedCa);

const filledEs = fillEmptyValues(sortedEs);
const filledCa = fillEmptyValues(sortedCa);

save(sortedEn, 'en.json');
save(filledEs, 'es.json');
save(filledCa, 'ca.json');
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "givethdapp",
"version": "2.16.2",
"version": "2.17.2",
"private": true,
"scripts": {
"build": "next build",
Expand All @@ -21,7 +21,7 @@
"@ethersproject/contracts": "^5.5.0",
"@ethersproject/providers": "^5.5.0",
"@ethersproject/units": "^5.5.0",
"@giveth/ui-design-system": "^1.11.11",
"@giveth/ui-design-system": "^1.11.13",
"@gnosis.pm/safe-apps-web3-react": "^1.5.0",
"@reduxjs/toolkit": "^1.8.1",
"@segment/snippet": "^4.15.3",
Expand All @@ -35,7 +35,7 @@
"axios": "^0.25.0",
"bignumber.js": "^9.0.1",
"deepmerge": "^4.2.2",
"framer-motion": "^6.2.8",
"framer-motion": "^10.12.12",
"graphql": "^16.0.1",
"human-standard-token-abi": "^2.0.0",
"lodash.isequal": "^4.5.0",
Expand Down
13 changes: 12 additions & 1 deletion pages/donate/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react';
import React, { FC, useEffect } from 'react';
import { GetServerSideProps } from 'next/types';
import Head from 'next/head';
import { captureException } from '@sentry/nextjs';
Expand All @@ -14,12 +14,23 @@ import { transformGraphQLErrorsToStatusCode } from '@/helpers/requests';
import config from '@/configuration';
import { DonateProvider } from '@/context/donate.context';
import DonateIndex from '@/components/views/donate/DonateIndex';
import { useAppDispatch } from '@/features/hooks';
import { setShowFooter } from '@/features/general/general.slice';

export interface IDonateRouteProps {
project: IDonationProject;
}

const DonateRoute: FC<IDonateRouteProps> = ({ project }) => {
const dispatch = useAppDispatch();

useEffect(() => {
dispatch(setShowFooter(false));
return () => {
dispatch(setShowFooter(true));
};
}, []);

Check warning on line 32 in pages/donate/[slug].tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array

return (
<DonateProvider project={project}>
<Head>
Expand Down
20 changes: 20 additions & 0 deletions pages/passport.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Head from 'next/head';
import { useIntl } from 'react-intl';
import { PassportView } from '@/components/views/passport/passport.view';

const PassportRoute = () => {
const { formatMessage } = useIntl();

return (
<>
<Head>
<title>
{formatMessage({ id: 'label.passport_score' })} | Giveth
</title>
</Head>
<PassportView />
</>
);
};

export default PassportRoute;
132 changes: 132 additions & 0 deletions pages/qf/[slug].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { GetServerSideProps } from 'next/types';
import { IMainCategory } from '@/apollo/types/types';
import { transformGraphQLErrorsToStatusCode } from '@/helpers/requests';
import { initializeApollo } from '@/apollo/apolloClient';
import { OPTIONS_HOME_PROJECTS } from '@/apollo/gql/gqlOptions';
import {
FETCH_ALL_PROJECTS,
FETCH_MAIN_CATEGORIES,
} from '@/apollo/gql/gqlProjects';
import { GeneralMetatags } from '@/components/Metatag';
import ProjectsIndex from '@/components/views/projects/ProjectsIndex';
import { projectsMetatags } from '@/content/metatags';
import { ProjectsProvider } from '@/context/projects.context';
import { FETCH_QF_ROUNDS } from '@/apollo/gql/gqlQF';
import type { IQFProjectsRouteProps } from '.';

interface IQFProjectsCategoriesRouteProps extends IQFProjectsRouteProps {
selectedMainCategory: IMainCategory;
}

const QFProjectsCategoriesRoute = (props: IQFProjectsCategoriesRouteProps) => {
const {
projects,
mainCategories,
selectedMainCategory,
totalCount,
categories,
qfRounds,
} = props;

return (
<ProjectsProvider
mainCategories={mainCategories}
selectedMainCategory={selectedMainCategory}
isQF={true}
qfRounds={qfRounds}
>
<GeneralMetatags info={projectsMetatags} />
<ProjectsIndex
projects={projects}
totalCount={totalCount}
categories={categories}
/>
</ProjectsProvider>
);
};

export const getServerSideProps: GetServerSideProps = async context => {
const apolloClient = initializeApollo();
const { variables, notifyOnNetworkStatusChange } = OPTIONS_HOME_PROJECTS;
try {
const { query } = context;
const slug = query.slug;
if (!slug)
return {
redirect: {
destination: '/',
permanent: false,
},
};
const {
data: { mainCategories },
}: {
data: { mainCategories: IMainCategory[] };
} = await apolloClient.query({
query: FETCH_MAIN_CATEGORIES,
fetchPolicy: 'network-only',
});

const allCategoriesItem = {
title: 'All',
description: '',
banner: '',
slug: 'all',
categories: [],
selected: false,
};

const updatedMainCategory = [allCategoriesItem, ...mainCategories];
const selectedMainCategory = updatedMainCategory.find(mainCategory => {
return mainCategory.slug === slug;
});

if (selectedMainCategory) {
const updatedSelectedMainCategory = {
...selectedMainCategory,
selected: true,
};
const apolloClient = initializeApollo();
const { data } = await apolloClient.query({
query: FETCH_ALL_PROJECTS,
variables: {
...variables,
mainCategory: updatedSelectedMainCategory.slug,
notifyOnNetworkStatusChange,
},
fetchPolicy: 'network-only',
});
const { projects, totalCount, categories } = data.allProjects;
const {
data: { qfRounds },
} = await apolloClient.query({
query: FETCH_QF_ROUNDS,
fetchPolicy: 'network-only',
});
return {
props: {
projects,
mainCategories: updatedMainCategory,
selectedMainCategory: updatedSelectedMainCategory,
totalCount,
categories,
qfRounds,
},
};
}
return {
notFound: true,
};
} catch (error: any) {
const statusCode = transformGraphQLErrorsToStatusCode(
error?.graphQLErrors,
);
return {
props: {
errorStatus: statusCode,
},
};
}
};

export default QFProjectsCategoriesRoute;
Loading

0 comments on commit 0e513a1

Please sign in to comment.