Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Reports] New project starter template (v1) #1930

Merged
merged 4 commits into from
Mar 26, 2024
Merged
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
21 changes: 21 additions & 0 deletions Reports/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Node modules and dependencies
node_modules
/.pnp
.pnp.js

# dotenv environment variables file
.env

# Ignore IDE/Editor folders
.idea
.vscode
*.swp
3 changes: 3 additions & 0 deletions Reports/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_API_BASE_URL=
VITE_API_ACCESS_TOKEN=
VITE_API_AUTHORIZATION_TOKEN=
18 changes: 18 additions & 0 deletions Reports/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
50 changes: 50 additions & 0 deletions Reports/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Dependencies
node_modules

# Build
dist
dist-ssr

# Local
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# OS or Editor files
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Environment variables
.env
.env.local
.env.development
.env.test
.env.production

# Yarn Integrity file
.yarn-integrity
.yarn/cache

# TypeScript
*.tsbuildinfo
6 changes: 6 additions & 0 deletions Reports/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "all",
"semi": false
}
Binary file added Reports/.yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions Reports/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
23 changes: 23 additions & 0 deletions Reports/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Node runtime as the base image
FROM node:18.19.1

# Setting the working directory in the container to /app
WORKDIR /app

# Coping package.json and yarn.lock into the root directory of the app
COPY package.json yarn.lock ./

# Installing project dependencies
RUN yarn install --frozen-lockfile

# Copy the rest of the project into the app directory
COPY . .

# Build the app
RUN yarn build

# Exposing the port 5173 for Vite
EXPOSE 5173

# Starting the app
CMD ["yarn", "dev"]
33 changes: 33 additions & 0 deletions Reports/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Auto Report Generator

Welcome to the Auto Report Generator project! This application is built using React, TypeScript, and Vite. It provides a streamlined setup to kickstart your development process, including Hot Module Replacement (HMR) for a seamless development experience and a set of basic ESLint rules to ensure code quality.

## Prerequisites

- Node.js version 18.19.1 or higher
- Yarn version 4.1.1

## Plugins

The template currently uses two official plugins:

- @vitejs/plugin-react: This plugin uses Babel for Fast Refresh.
- @vitejs/plugin-react-swc: This plugin uses SWC for Fast Refresh.

## ESLint Configuration

The template comes with a basic ESLint configuration. If you are developing a production application, we recommend expanding the configuration to enable type-aware lint rules. Here's how you can do it:

## Getting Started

To get started with this template, clone the repository and install the dependencies:

git clone <repository-url>
cd <repository-name>
yarn install

Then, you can start the development server:

yarn dev

Open http://localhost:5173 to view your application in the browser. The page will automatically reload if you make changes to the code.
13 changes: 13 additions & 0 deletions Reports/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/images/airqo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AQ Report Generator</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
68 changes: 68 additions & 0 deletions Reports/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "aq-report-generator",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"format": "prettier --write \"src/**/*.js\""
},
"dependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@react-pdf/renderer": "^3.3.8",
"@reduxjs/toolkit": "^2.2.1",
"@types/file-saver": "^2.0.7",
"@vitejs/plugin-react-refresh": "^1.3.6",
"axios": "^1.6.7",
"buffer": "^6.0.3",
"chart.js": "^4.4.2",
"chartjs-to-image": "^1.2.2",
"dayjs": "^1.11.10",
"file-saver": "^2.0.5",
"flowbite-react": "^0.7.2",
"html-to-image": "^1.11.11",
"jspdf": "^2.5.1",
"react": "^18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-loading-skeleton": "^3.4.0",
"react-redux": "^9.1.0",
"react-router-dom": "^6.22.3",
"react-select": "^5.8.0",
"react-spinners": "^0.13.8",
"react-tailwindcss-datepicker": "^1.6.6",
"react-toastify": "^10.0.4",
"redux": "^5.0.1",
"redux-devtools-extension": "^2.13.9",
"redux-persist": "^6.0.0",
"redux-thunk": "^3.1.0"
},
"devDependencies": {
"@types/chart.js": "^2.9.41",
"@types/jspdf": "^2.0.0",
"@types/node": "^20.11.25",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@types/react-redux": "^7.1.33",
"@types/redux": "^3.6.0",
"@types/redux-thunk": "^2.1.0",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.18",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.35",
"sass": "^1.71.1",
"sass-loader": "^14.1.1",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.1.4",
"vite-tsconfig-paths": "^4.3.1"
},
"packageManager": "[email protected]"
}
6 changes: 6 additions & 0 deletions Reports/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file added Reports/public/images/AQI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Reports/public/images/LOGO.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Reports/public/images/airqo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Reports/public/images/makerere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Reports/public/images/templateLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions Reports/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { lazy, Suspense } from 'react'
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'
import { Provider } from 'react-redux'
import { PersistGate } from 'redux-persist/integration/react'
import { store, persistor } from '@services/redux/store'
import BounceLoader from 'react-spinners/BounceLoader'

// Use React.lazy for code splitting
const Reports = lazy(() => import('./pages/Reports'))
const ReportForm = lazy(() => import('./components/reports'))
const ReportView = lazy(() => import('./components/reports/ReportView'))
const Files = lazy(() => import('./pages/Files'))
const Settings = lazy(() => import('./pages/settings'))

const App = () => {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Router>
<Suspense
fallback={
<div className="flex items-center justify-center h-screen">
<BounceLoader color="#006583" />
</div>
}
>
<Routes>
<Route path="/*" element={<Reports />}>
<Route index element={<ReportForm />} />
<Route path="view" element={<ReportView />} />
</Route>
<Route path="files" element={<Files />} />
<Route path="settings" element={<Settings />} />
</Routes>
</Suspense>
</Router>
</PersistGate>
</Provider>
)
}

export default App
33 changes: 33 additions & 0 deletions Reports/src/assets/icons/BackArrow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react'

interface BackArrowProps {
width?: number
height?: number
fill?: string
}

const BackArrow: React.FC<BackArrowProps> = ({
width = 24,
height = 24,
fill,
}) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={width}
height={height}
viewBox="0 0 24 24"
fill={fill || 'none'}
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
className="back-icon back-icon-tabler icons-tabler-outline back-icon-tabler-arrow-left"
>
<path d="M0 0h24v24H0z" stroke="none" />
<path d="M5 12h14M5 12l6 6M5 12l6-6" />
</svg>
)
}

export default BackArrow
29 changes: 29 additions & 0 deletions Reports/src/assets/icons/DocIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'

interface Props {
width?: number
height?: number
}

const DocIcon: React.FC<Props> = ({ width = 20, height = 20 }) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={width}
height={height}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
className="icon icon-tabler icons-tabler-outline icon-tabler-file-type-docx"
>
<path d="M0 0h24v24H0z" stroke="none" />
<path d="M14 3v4a1 1 0 001 1h4" />
<path d="M5 12V5a2 2 0 012-2h7l5 5v4M2 15v6h1a2 2 0 002-2v-2a2 2 0 00-2-2H2zM17 16.5a1.5 1.5 0 00-3 0v3a1.5 1.5 0 003 0M9.5 15a1.5 1.5 0 011.5 1.5v3a1.5 1.5 0 01-3 0v-3A1.5 1.5 0 019.5 15zM19.5 15l3 6M19.5 21l3-6" />
</svg>
)
}

export default DocIcon
30 changes: 30 additions & 0 deletions Reports/src/assets/icons/DownloadIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'

interface DownloadIconProps {
width?: number
height?: number
}

const DownloadIcon: React.FC<DownloadIconProps> = ({
width = 24,
height = 24,
}) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={width}
height={height}
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={1.5}
strokeLinecap="round"
strokeLinejoin="round"
className="icon icon-tabler icons-tabler-outline icon-tabler-server-cog"
>
<path d="M8 17l4 4m0 0l4-4m-4 4v-9m8 4.743A5.5 5.5 0 0016.5 7a.62.62 0 01-.534-.302 7.5 7.5 0 10-11.78 9.096" />
</svg>
)
}

export default DownloadIcon
Loading
Loading