-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
132 changed files
with
9,893 additions
and
6,096 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.