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
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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
}
}
12 changes: 9 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 All @@ -15,6 +16,7 @@ const Layout = ({ children, home }) => {
);

const compareElem = (a, b) => {
console.log("A B ele:", a, b);
return a.type.name === b.type.name;
};

Expand Down Expand Up @@ -81,4 +83,8 @@ const Layout = ({ children, home }) => {
);
};

export default Layout;
Layout.propTypes = {
children: PropTypes.node,
};

export default Layout;
23 changes: 19 additions & 4 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 { getSession, 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({});

Expand All @@ -19,7 +20,6 @@ export default function Login(props) {
);
const [formValidity, setFormValidity] = useState(false);
const { addToast } = useToasts();
const [role, setRole] = useState(null);

const handleInput = (e) => {
setInput({ ...input, [e.target.name]: e.target.value });
Expand Down Expand Up @@ -53,6 +53,7 @@ export default function Login(props) {
if (url) {
const session = await getSession();
if (!router.isFallback) {
console.log("Role:",session.role);
if (session?.role == "Admin") {
router.push(
persona.redirectUrl.search("http") < 0
Expand Down Expand Up @@ -102,4 +103,18 @@ 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,
redirectUrlAdmin: PropTypes.string,
}).isRequired,
};

export default Login;
19 changes: 12 additions & 7 deletions portal/components/react-admin/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { AdminContext, AdminUI, Resource, useDataProvider } from "react-admin";
import buildHasuraProvider, { buildFields } from "ra-data-hasura";
import React, { useState, useEffect } from "react";
import { AdminContext, AdminUI, Resource } from "react-admin";
import buildHasuraProvider from "ra-data-hasura";
import { ApolloClient, InMemoryCache } from "@apollo/client";
import { useSession } from "next-auth/client";
import { MuiThemeProvider, createMuiTheme } from "@material-ui/core";
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 All @@ -25,7 +26,7 @@ const App = () => {
cache: new InMemoryCache(),
headers: hasuraHeaders,
});
async function buildDataProvider() {
const buildDataProvider = async () => {
const hasuraProvider = await buildHasuraProvider(
{ client: tempClient },
{
Expand All @@ -35,7 +36,7 @@ const App = () => {
);
setDataProvider(() => hasuraProvider);
setApolloClient(tempClient);
}
};
buildDataProvider();
}, [session]);

Expand All @@ -46,7 +47,7 @@ const App = () => {
</AdminContext>
);
};
function AsyncResources({ client }) {
const AsyncResources = ({ client }) => {
let introspectionResultObjects =
client.cache?.data?.data?.ROOT_QUERY?.__schema.types
?.filter((obj) => obj.kind === "OBJECT")
Expand Down Expand Up @@ -75,6 +76,10 @@ function AsyncResources({ client }) {
</AdminUI>
</MuiThemeProvider>
);
}
};

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} />
</Toolbar>
);

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

export default EditNoDeleteToolbar;
13 changes: 12 additions & 1 deletion portal/components/react-admin/base/resources/assessments.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useMediaQuery } from "@material-ui/core";
import config from "@/components/config";
import axios from "axios";
import { useStyles } from "../styles";
import PropTypes from "prop-types";

const DevicesFilter = (props) => {
const classes = useStyles();
Expand Down Expand Up @@ -145,7 +146,7 @@ export const AssessmentsEdit = (props) => {
`${process.env.NEXT_PUBLIC_ASSESSMENTS_MODULE_FORM_URL}/getFormPrefilled/${props.id}`
)
.then((res) => setFormUrl(res))
.catch((err) => {});
.catch(() => {});
}, []);
return (
<>
Expand All @@ -170,3 +171,13 @@ export const AssessmentsEdit = (props) => {
</>
);
};

AssessmentsCreate.propTypes = {
options: PropTypes.object,
id: PropTypes.number,
};

AssessmentsEdit.propTypes = {
options: PropTypes.object,
id: PropTypes.number,
};
10 changes: 4 additions & 6 deletions portal/components/react-admin/base/resources/gradeAssessment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import {
DateField,
SelectInput,
SearchInput,
ReferenceInput,
AutocompleteInput,
DateInput,
Filter,
TextInput,
} from "react-admin";
import { useMediaQuery } from "@material-ui/core";
import { useStyles } from "../styles";

// school renderer
const schoolRenderer = (choice) => {
return choice ? `UDISE: ${choice.udise}, ${choice.name}` : "";
};
// const schoolRenderer = (choice) => {
// return choice ? `UDISE: ${choice.udise}, ${choice.name}` : "";
// };

const SearchFilter = (props) => (
<Filter {...props}>
Expand Down
19 changes: 9 additions & 10 deletions portal/components/react-admin/base/resources/schools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,23 @@ import {
List,
SimpleList,
Datagrid,
DateField,
TextField,
BooleanField,
FunctionField,
Edit,
SimpleForm,
TextInput,
SelectInput,
Filter,
SearchInput,
useRedirect,
useNotify,
FormDataConsumer,
AutocompleteInput,
ReferenceInput,
} from "react-admin";

import { useSession } from "next-auth/client";
import { Typography, useMediaQuery } from "@material-ui/core";
import { useMediaQuery } from "@material-ui/core";
import EditNoDeleteToolbar from "../components/EditNoDeleteToolbar";
import BackButton from "../components/BackButton";
import config from "@/components/config";
import sendSMS from "@/utils/sendSMS";
import buildGupshup from "@/utils/buildGupshup";
import { useStyles } from "../styles";
import PropTypes from "prop-types";

/**
* Donate Device Request List
Expand Down Expand Up @@ -158,3 +150,10 @@ export const SchoolEdit = (props) => {
</div>
);
};

SchoolEdit.propTypes = {
mutationMode: PropTypes.string,
basePath: PropTypes.string,
record: PropTypes.object,
history: PropTypes.any,
};
Loading