Skip to content

Commit

Permalink
feat: CSV download template
Browse files Browse the repository at this point in the history
  • Loading branch information
codaisa committed Jan 26, 2024
1 parent 1a4c53e commit 954767a
Show file tree
Hide file tree
Showing 8 changed files with 741 additions and 422 deletions.
462 changes: 447 additions & 15 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@rollup/plugin-dsv": "^3.0.4",
"@types/file-saver": "^2.0.7",
"@types/node": "^18.14.6",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
Expand Down
1 change: 0 additions & 1 deletion src/models/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/models/school_import.csv

This file was deleted.

4 changes: 3 additions & 1 deletion src/pages/Schools/SchoolImportModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const SchoolImportModal: React.FC<Props> = ({ isOpen, onClose }) => {
setResponse(undefined);
};

var csvBlob = new Blob(['emis_number,name,region,city,municipalities'], { type: 'text/csv;charset=utf-8' });

return (
<Modal isOpen={isOpen} onClose={onClose} scrollBehavior="inside" size="5xl">
<ModalOverlay />
Expand Down Expand Up @@ -145,7 +147,7 @@ const SchoolImportModal: React.FC<Props> = ({ isOpen, onClose }) => {
borderColor={'Primary.$200'}
color={'Primary.$200'}
mr={3}
onClick={() => saveAs(SchoolImportModal, 'School impor template')}
onClick={() => saveAs(csvBlob, 'School import template')}
>
Download template
</Button>
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"@/*": ["./src/*"]
}
},
"include": ["src"],
"include": ["src", "**/*.csv"],
"references": [{ "path": "./tsconfig.node.json" }]
}
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react-swc';
import dsv from '@rollup/plugin-dsv';
import path from 'path';

// https://vitejs.dev/config/
Expand All @@ -9,7 +10,7 @@ export default ({ mode }) => {

return defineConfig({
base: `/${process.env.VITE_COUNTRY}/admin/`,
plugins: [react()],
plugins: [react(), dsv()],
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
Expand Down
688 changes: 286 additions & 402 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 954767a

Please sign in to comment.