https://github.com/civicdatalab/oci-assam-frontend

Frontend for Public Procurement Explorer - Assam. Developed by a collaboration between CivicDataLab and Open Contracting Partnership

https://github.com/civicdatalab/oci-assam-frontend

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.8%) to scientific vocabulary

Keywords

bem ckan nextjs react sass typescript
Last synced: 5 months ago · JSON representation

Repository

Frontend for Public Procurement Explorer - Assam. Developed by a collaboration between CivicDataLab and Open Contracting Partnership

Basic Info
Statistics
  • Stars: 4
  • Watchers: 6
  • Forks: 1
  • Open Issues: 5
  • Releases: 0
Topics
bem ckan nextjs react sass typescript
Created over 4 years ago · Last pushed about 1 year ago
Metadata Files
Readme Contributing License Code of conduct

README.md

Public Procurement Explorer - Assam

In collaboration between CivicDataLab and Open Contracting Partnership




MIT License

A data-driven tool to enable public officials in the state of Asaam to make smarter, data-informed decisions about public spending

Features

  • 🗺️ Unified sites: present data and content in one seamless site, pulling datasets from a DMS (e.g. CKAN) and content from a CMS (e.g. wordpress) with a common internal API.
  • ♿ Accessible: The platform is screen-reader friendly.
  • 👩‍💻 Developer friendly: built with NextJS, SASS, GraphQL to make the developer experience a treat.
  • 🚀 ITCSS & BEM: Combination of BEM methodology and ITCSS architecture to better organize the styling and make it scalable.
  • 📋 Typescript: Developed usign typescript to improve development experience by catching errors and providing fixes.
  • 🧱 Extensible: quickly extend and develop/import your own React components
  • 📝 Well documented: full set of documentation plus the documentation of NextJS and Apollo

Getting Started

Install a recent version of Node. Node 16 is recommended.

For error:0308010C:digital envelope routines::unsupported follow this

Guide

Styling 🎨

We use SASS preprocessor to manage styling. All of it can be found at /styles directory where it's managed by using ITCSS architecture to make it scalable. For naming, we use BEM methodology.

Backend

You can connect CMS and DMS backends easily via environment variables:

console $ export DMS=http://ckan:5000 $ export CMS=http://myblog.wordpress.com

Note that we don't yet have implementations for the following CKAN features:

  • Activities
  • Auth
  • Groups

Pages

  • Home /
  • Dataset lisitng /datasets
  • Tender /datasets/[tender]
  • KPI listing /kpi
  • KPI Analysis /kpi/[analysis]
  • Stories /stories
  • About /about

Data fetching

We use Apollo client which allows us to query data with GraphQL. We have setup CKAN API for the demo (it uses demo.ckan.org as DMS):

Note that we don't have Apollo Server but we connect CKAN API using apollo-link-rest module. You can see how it works in lib/apolloClient.ts and then have a look at pages/_app.tsx.

For development/debugging purposes, we suggest installing the Chrome extension - https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm.

i18n configuration

This is configured by default to support both English and French subpath for language translation. But for subsequent users, this following steps can be used to configure i18n for other languages;

  1. Update next.config.js, to add more languages to the i18n locales

js i18n: { locales: ['en', 'fr', 'nl-NL'], // add more language to the list defaultLocale: 'en', // set the default language to use },

  1. Create a folder for the language in locales --> locales/en-Us

  2. In the language folder, different namespace files (json) can be created for each translation. For the index.js use-case, I named it common.json

```json // locales/en/common.json { "title" : "Portal js in English", }

// locales/fr/common.json { "title" : "Portal js in French", } ```

  1. To use on pages using Server-side Props.

```js import { loadNamespaces } from './_app'; import useTranslation from 'next-translate/useTranslation';

const Home: React.FC = ()=> { const { t } = useTranslation(); return (

{t(common:title)}
// we use common and title base on the common.json data ); };

export const getServerSideProps: GetServerSideProps = async ({ locale }) => { ........ ........ return { props : { _ns: await loadNamespaces(['common'], locale), } }; };

```

  1. Go to the browser and view the changes using language subpath like this http://localhost:3000 and http://localhost:3000/fr. Note The subpath also activate chrome language Translator

Pre-fetch data in the server-side

When visiting a dataset page, you may want to fetch the dataset metadata in the server-side. To do so, you can use getServerSideProps function from NextJS:

```javascript import { GetServerSideProps } from 'next'; import { initializeApollo } from '../lib/apolloClient'; import gql from 'graphql-tag';

const QUERY = gql query dataset($id: String) { dataset(id: $id) @rest(type: "Response", path: "package_show?{args}") { result } } ;

...

export const getServerSideProps: GetServerSideProps = async (context) => { const apolloClient = initializeApollo();

await apolloClient.query({ query: QUERY, variables: { id: 'my-dataset' }, });

return { props: { initialApolloState: apolloClient.cache.extract(), }, }; }; ```

This would fetch the data from DMS and save it in the Apollo cache so that we can query it again from the components.

Access data from a component

Consider situation when rendering a component for org info on the dataset page. We already have pre-fetched dataset metadata that includes organization property with attributes such as name, title etc. We can now query only organization part for our Org component:

```javascript import { useQuery } from '@apollo/react-hooks'; import gql from 'graphql-tag';

export const GETORGQUERY = gql query dataset($id: String) { dataset(id: $id) @rest(type: "Response", path: "package_show?{args}") { result { organization { name title image_url } } } } ;

export default function Org({ variables }) { const { loading, error, data } = useQuery( GETORGQUERY, { variables: { id: 'my-dataset' } } );

...

const { organization } = data.dataset.result;

return ( <> {organization ? ( <> {organization.title || organization.name} </> ) : ( '' )} </> ); } ```

Developers

Boot the local instance

Install the dependencies:

bash npm i

Boot the demo frontend:

console npm run dev

Open http://localhost:3000 to see the home page 🎉

You can start editing the page by modifying /pages/index.tsx. The page auto-updates as you edit the file.

Architecture

  • Language: Javascript
  • Framework: Next.js
  • Styling: SASS with BEM and ITCSS

Contributing

For any new feature or bug reports, please request it in issues.

See CONTRIBUTING.md for ways to get started.

Please adhere to Code of Conduct.

Credits

This is based on a PortalJS.

Owner

  • Name: CivicDataLab
  • Login: CivicDataLab
  • Kind: organization
  • Email: info@civicdatalab.in
  • Location: India

Harnessing Data, Tech, Design and Social Science to strengthen the course of Civic Engagements in India.

GitHub Events

Total
  • Watch event: 2
  • Push event: 1
Last Year
  • Watch event: 2
  • Push event: 1

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 14
  • Total pull requests: 48
  • Average time to close issues: about 1 month
  • Average time to close pull requests: about 1 hour
  • Total issue authors: 6
  • Total pull request authors: 3
  • Average comments per issue: 0.93
  • Average comments per pull request: 0.0
  • Merged pull requests: 47
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 1
  • Average time to close issues: 7 minutes
  • Average time to close pull requests: 3 minutes
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • varun-ag42 (5)
  • Kabeer3 (4)
  • PixeledCode (2)
  • Abhi2102 (1)
  • sanjaypinna (1)
  • shreyaagrawal0809 (1)
Pull Request Authors
  • PixeledCode (45)
  • sanjaypinna (2)
  • shreyaagrawal0809 (1)
Top Labels
Issue Labels
bug (4) enhancement (4)
Pull Request Labels
enhancement (1)

Dependencies

package-lock.json npm
  • 1094 dependencies
package.json npm
  • @testing-library/jest-dom ^5.8.0 development
  • @types/lodash ^4.14.176 development
  • @types/react ^16.9.35 development
  • @typescript-eslint/eslint-plugin ^3.8.0 development
  • @typescript-eslint/parser ^3.8.0 development
  • cypress ^6.6.0 development
  • eslint ^7.6.0 development
  • eslint-config-prettier ^6.11.0 development
  • eslint-plugin-jsx-a11y ^6.3.1 development
  • eslint-plugin-prettier ^3.1.4 development
  • eslint-plugin-react ^7.20.5 development
  • husky >=4 development
  • jest ^26.1.0 development
  • lint-staged >=10 development
  • prettier ^2.0.5 development
  • @apollo/react-hooks ^3.1.5
  • @types/react-modal ^3.13.1
  • apollo-cache-inmemory ^1.6.6
  • apollo-client ^2.6.10
  • apollo-link ^1.2.14
  • apollo-link-rest 0.7.3
  • echart ^0.1.3
  • echarts ^5.2.2
  • echarts-for-react ^3.0.2
  • file-saver ^2.0.5
  • graphql ^15.1.0
  • graphql-anywhere ^4.2.7
  • graphql-tag ^2.10.3
  • html-react-parser ^0.13.0
  • lodash ^4.17.21
  • next ^12.0.1
  • next-translate ^0.20.2
  • next-transpile-modules ^9.0.0
  • nextjs-progressbar ^0.0.13
  • papaparse ^5.3.1
  • postcss ^8.4.5
  • qs ^6.9.4
  • react 17.0.2
  • react-dom 17.0.2
  • react-modal ^3.14.4
  • rss-parser ^3.12.0
  • sharp ^0.29.3
  • typescript ^4.5.4
.github/workflows/deploy.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • appleboy/scp-action master composite
  • appleboy/ssh-action v1.0.3 composite