Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI/CD check

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]


defaults:
run:
working-directory: portal

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run eslint test
run: yarn lint

- name: Build
run: yarn build
23 changes: 23 additions & 0 deletions portal/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": ["plugin:react/recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react"],
"rules": {
"react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }],
"prefer-destructuring": ["error", { "object": true, "array": false }]
},
"globals": {
"window": true
}
}
72 changes: 36 additions & 36 deletions portal/components/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,41 @@ const resourceConfig = {
],
homepageCards: [
{
// title: {
// en: "Donate your smartphone",
// hi: "अपना स्मार्टफ़ोन दान करें",
// },
// target: "/donate",
// icon: "volunteer_activism",
// colour: "primary",
// },{
// title: {
// en: "Donate a Smartphone as an Individual Donor",
// hi: "व्यक्तिगत दाता",
// },
// target: process.env.NEXT_PUBLIC_DONATE_DEVICE_INDIV_FORM_URL,
// icon: "volunteer_activism",
// colour: "primary",
// },
// {
// title: {
// en: "Donate a smartphone as a Corporate Donor",
// hi: "कॉर्पोरेट दाता",
// },
// target: process.env.NEXT_PUBLIC_DONATE_DEVICE_CORP_FORM_URL,
// icon: "corporate_fare",
// colour: "primary",
// },
// {
// title: {
// en: "Frequently Asked Questions",
// hi: "जानकारी",
// },
// target: process.env.NEXT_PUBLIC_FAQ_DOCUMENT_URL,
// icon: "quiz",
// colour: "primary",
// },
// {
// title: {
// en: "Donate your smartphone",
// hi: "अपना स्मार्टफ़ोन दान करें",
// },
// target: "/donate",
// icon: "volunteer_activism",
// colour: "primary",
// },{
// title: {
// en: "Donate a Smartphone as an Individual Donor",
// hi: "व्यक्तिगत दाता",
// },
// target: process.env.NEXT_PUBLIC_DONATE_DEVICE_INDIV_FORM_URL,
// icon: "volunteer_activism",
// colour: "primary",
// },
// {
// title: {
// en: "Donate a smartphone as a Corporate Donor",
// hi: "कॉर्पोरेट दाता",
// },
// target: process.env.NEXT_PUBLIC_DONATE_DEVICE_CORP_FORM_URL,
// icon: "corporate_fare",
// colour: "primary",
// },
// {
// title: {
// en: "Frequently Asked Questions",
// hi: "जानकारी",
// },
// target: process.env.NEXT_PUBLIC_FAQ_DOCUMENT_URL,
// icon: "quiz",
// colour: "primary",
// },
// {
title: {
en: "Login for state officials",
hi: "राज्य के अधिकारियों के लिए लॉग इन",
Expand Down Expand Up @@ -115,7 +115,7 @@ const resourceConfig = {
statusChoices: [
{
id: "no-action-taken",
name: "Donation in Progress",//No Action Taken
name: "Donation in Progress", //No Action Taken
icon: "warning",
style: "error",
},
Expand Down
13 changes: 10 additions & 3 deletions portal/components/layout.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Head from "next/head";
import Image from "next/image";
import { useState, useEffect } from "react";
import React, { useState, useEffect } from "react";
import styles from "../styles/layout.module.css";
import PropTypes from "prop-types";

const Layout = ({ children, home }) => {
const Layout = ({ children }) => {
const transitionStages = {
FADE_OUT: "fadeOut",
FADE_IN: "fadeIn",
Expand Down Expand Up @@ -56,7 +57,9 @@ const Layout = ({ children, home }) => {
>
{activeChildren}
</main>
<span className={styles.credit}>For more details, contact 1800-180-8190 </span>
<span className={styles.credit}>
For more details, contact 1800-180-8190{" "}
</span>
<footer className={styles.footer}>
<div className={styles.logo}>
<Image
Expand All @@ -83,4 +86,8 @@ const Layout = ({ children, home }) => {
);
};

Layout.propTypes = {
children: PropTypes.element,
};

export default Layout;
29 changes: 23 additions & 6 deletions portal/components/login/login.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useState, useEffect } from "react";
import React, { useState, useEffect } from "react";
import { useToasts } from "react-toast-notifications";
import { signIn } from "next-auth/client";
import { useRouter } from "next/router";
import controls from "./form.config";
import styles from "../../styles/Login.module.css";
import PropTypes from "prop-types";

export default function Login(props) {
const Login = (props) => {
const { persona } = props;
const [input, setInput] = useState({});
const router = useRouter();
Expand Down Expand Up @@ -38,10 +39,13 @@ export default function Login(props) {

const signUserIn = async (e) => {
e.preventDefault();
console.log("person:",persona)
console.log("Env Variables",`${process.env.NEXT_PUBLIC_URL}/${persona.redirectUrl}`)
console.log("person:", persona);
console.log(
"Env Variables",
`${process.env.NEXT_PUBLIC_URL}/${persona.redirectUrl}`
);
const { error, url } = await signIn("fusionauth", {
loginId: input.username,
loginId: input.username,
password: input.password,
applicationId: persona.applicationId,
redirect: false,
Expand Down Expand Up @@ -92,4 +96,17 @@ export default function Login(props) {
</form>
</div>
);
}
};

Login.propTypes = {
persona: PropTypes.shape({
consonant: PropTypes.bool,
en: PropTypes.string,
hi: PropTypes.string,
credentials: PropTypes.string,
applicationId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
redirectUrl: PropTypes.string,
}).isRequired,
};

export default Login;
13 changes: 9 additions & 4 deletions portal/components/react-admin/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import React, { useState, useEffect } from "react";
import { AdminContext, AdminUI, Resource, useDataProvider } from "react-admin";
import buildHasuraProvider, { buildFields } from "ra-data-hasura";
import { ApolloClient, InMemoryCache } from "@apollo/client";
Expand All @@ -9,6 +9,7 @@ import customLayout from "./layout/";
import customFields from "./customHasura/customFields";
import customVariables from "./customHasura/customVariables";
import { resourceConfig } from "./layout/config";
import PropTypes from "prop-types";

const App = () => {
const [dataProvider, setDataProvider] = useState(null);
Expand Down Expand Up @@ -49,18 +50,18 @@ const App = () => {
);
};
function AsyncResources({ client }) {
console.log("Async")
console.log("Async");
let introspectionResultObjects =
client.cache?.data?.data?.ROOT_QUERY?.__schema.types
?.filter((obj) => obj.kind === "OBJECT")
?.map((elem) => elem.name);
?.map((elem) => elem.name);
const resources = resourceConfig;
let filteredResources = resources;
if (introspectionResultObjects) {
filteredResources = resources.filter((elem) =>
introspectionResultObjects.includes(elem.name)
);
console.log("introspectionResultObjects", filteredResources)
console.log("introspectionResultObjects", filteredResources);
}
if (!resources) return null;
return (
Expand All @@ -81,4 +82,8 @@ function AsyncResources({ client }) {
);
}

AsyncResources.propTypes = {
client: PropTypes.object,
};

export default App;
5 changes: 5 additions & 0 deletions portal/components/react-admin/base/components/BackButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import Button from "@material-ui/core/Button";
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
import { makeStyles } from "@material-ui/core";
import PropTypes from "prop-types";

const useStyles = makeStyles((theme) => ({
button: {
Expand All @@ -26,4 +27,8 @@ const BackButton = ({ history }) => {
);
};

BackButton.propTypes = {
history: PropTypes.any,
};

export default BackButton;
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from "react";
import { Toolbar, SaveButton } from "react-admin";
import PropTypes from "prop-types";

const EditNoDeleteToolbar = (props) => (
<Toolbar {...props}>
<SaveButton disabled={props.pristine} />
const EditNoDeleteToolbar = ({ pristine }) => (
<Toolbar>
<SaveButton disabled={pristine} />
</Toolbar>
);

EditNoDeleteToolbar.propTypes = {
pristine: PropTypes.bool,
};

export default EditNoDeleteToolbar;
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,45 @@ const SearchFilter = (props) => {
};
const exporter = (records) => {
const recordsForExport = records.map((record) => {
let age = getAge({
let age = getAge({
start: record.DOB,
end: null,
}).years;

return {
"Candidate Name": (record.name?record.name:'NONE'),
"Mobile Number": (record.mobile_number?record.mobile_number:"NONE"),
"Whatsapp Number": (record.whatsapp_mobile_number?record.whatsapp_mobile_number:'NONE'),
District: (record.district_name.name?record.district_name.name:"NONE"),
Pincode: (record.pincode?record.pincode:"NONE"),
"Max Qualification":
(record.highest_level_qualification.highest_level_qualification_name?record.highest_level_qualification.highest_level_qualification_name:"NONE"),
Qualification: (record.qualification_detail.qualification_name?record.qualification_detail.qualification_name:"NONE"),
Marks: (record.final_score_highest_qualification?record.final_score_highest_qualification:"NONE"),
"Candidate Name": record.name ? record.name : "NONE",
"Mobile Number": record.mobile_number ? record.mobile_number : "NONE",
"Whatsapp Number": record.whatsapp_mobile_number
? record.whatsapp_mobile_number
: "NONE",
District: record.district_name.name ? record.district_name.name : "NONE",
Pincode: record.pincode ? record.pincode : "NONE",
"Max Qualification": record.highest_level_qualification
.highest_level_qualification_name
? record.highest_level_qualification.highest_level_qualification_name
: "NONE",
Qualification: record.qualification_detail.qualification_name
? record.qualification_detail.qualification_name
: "NONE",
Marks: record.final_score_highest_qualification
? record.final_score_highest_qualification
: "NONE",
"Date of Birth": record.DOB,
Age: age,
Gender: record.gender.gender_name,
"Have you ever been employed": (record.ever_employment.employment_status?record.ever_employment.employment_status:"NONE"),
"Job Role": (record.job_role?record.job_role:"NONE"),
"Company Name": (record.employer_organization_name?record.employer_organization_name:"NONE"),
"Total work experience (months)": (record.work_experience_details?record.work_experience_details.work_experience_choices:"NONE"),
"Monthly salary (Rs.)": (record.monthly_salary_details?record.monthly_salary_details.salary_range:"NONE"),
"Have you ever been employed": record.ever_employment.employment_status
? record.ever_employment.employment_status
: "NONE",
"Job Role": record.job_role ? record.job_role : "NONE",
"Company Name": record.employer_organization_name
? record.employer_organization_name
: "NONE",
"Total work experience (months)": record.work_experience_details
? record.work_experience_details.work_experience_choices
: "NONE",
"Monthly salary (Rs.)": record.monthly_salary_details
? record.monthly_salary_details.salary_range
: "NONE",
"Driving License": record.driver_license.driver_license_choice,
"Distance willing to travel":
record.district_travel.district_travel_choice,
Expand Down
Loading