Skip to content

Commit

Permalink
Merge pull request #15 from Aar-if/newaltv1
Browse files Browse the repository at this point in the history
Batching fix
  • Loading branch information
snehal0904 authored Oct 3, 2023
2 parents 145bb45 + bfee1bb commit 2ac592b
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 15 deletions.
44 changes: 44 additions & 0 deletions packages/admin/src/api/StudentResetPasswordAPI.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import axios from "axios";
import { studentReset } from "../routes/links";

const studentAPI = async (data) => {
const token = localStorage.getItem("token");

const headers = {
"Accept-Language": "en-GB,en;q=0.9",
Authorization: `Bearer ${token}`,
Connection: "keep-alive",
"Content-Type": "application/json",
};

const jsonData = {
username: data.username,
newPassword: data.newPassword,
};

let result;
await axios({
method: "POST",
url: studentReset,
data: jsonData,
headers: headers,
})
.then((res) => {
console.log(res);
console.log(res.data);
console.log(res.status);
if (res.status === 201) {
result = true;
} else {
result = false;
}
})
.catch(function (error) {
let err = 0;
return err;
});

return result;
};

export default studentAPI;
3 changes: 1 addition & 2 deletions packages/admin/src/components/SchoolListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function SchoolListView() {
},

{ field: "location" },
{ field: "groups" },
{ field: "management" },
{ field: "composition" },

Expand Down Expand Up @@ -104,8 +105,6 @@ function SchoolListView() {
},
{ field: "buildingIsFreeFromInflammableAndToxicMaterials" },
{ field: "roofAndWallsAreInGoodCondition" },
{ field: "createdAt" },
{ field: "updatedAt" },
]);

const cellClickedListener = useCallback((event) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/components/StudentCSV.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function CSVImportForm() {
students: [],
};

for (let i = 0; i < csvData.length; i++) {
for (let i = startIndex; i < endIndex; i++) {
const studentData = csvData[i];
if (studentData["name"] && studentData["name"].trim() !== "") {
const studentObject = {
Expand Down
70 changes: 58 additions & 12 deletions packages/admin/src/components/StudentListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,69 @@ import { useForm } from "react-hook-form";
import { useNavigate } from "react-router-dom";
import Papa from "papaparse";
import axios from "axios";
import { Button } from "native-base";
import Modal from "react-modal";
import StudentResetPassword from "./StudentResetPassword";

const customStyles = {
content: {
maxHeight: "90%",
maxWidth: "90%",
margin: 0,
padding: "20",
backgroundColor: "#fff",
},
scrollableContent: {
maxHeight: "90%",
overflowY: "auto",
},
};

function StudentListView() {
const [token, setToken] = useState([]);
const navigate = useNavigate();
const gridRef = useRef();
const [rowData, setRowData] = useState([]);
const [isOpen, setIsOpen] = useState(false);

useEffect(() => {
Modal.setAppElement("#root"); // Set the app element for modal
}, []);

const openModal = () => {
setIsOpen(true);
};

const closeModal = () => {
setIsOpen(false);
};

const [columnDefs] = useState([
{
width: 150,
cellRenderer: function () {
// Replace with your desired label
const combinedFunction = () => {
// openModal();
alert("Work in progress");
};

return (
<div>
<button onClick={combinedFunction}> Reset Password</button>
<Modal
isOpen={isOpen}
onRequestClose={closeModal}
contentLabel="Edit Modal"
// className={modalStyles.modalDiv}
style={customStyles.content}
>
Hello
</Modal>
</div>
);
},
},
// {
// headerName: "Delete",
// field: "actions",
Expand Down Expand Up @@ -60,8 +115,9 @@ function StudentListView() {
// },

{ field: "name" },
{ field: "dateOfBirth" },
{ field: "board" },
{ field: "dateOfBirth", width: 150 },
{ field: "board", width: 150 },
{ field: "schoolName", width: 250 },
{
field: "schoolUdise",
filter: true,
Expand All @@ -78,8 +134,6 @@ function StudentListView() {

{ field: "role" },

{ field: "createdBy" },
{ field: "updatedBy" },
{ field: "studentId" },
{ field: "groups" },
{ field: "religion" },
Expand All @@ -91,14 +145,8 @@ function StudentListView() {
{ field: "motherOccupation" },
{ field: "fatherOccupation" },
{ field: "noOfSiblings" },
{ field: "userId", filter: true, editable: true },
]);

const cellClickedListener = useCallback((event) => {
console.log("cellClicked", event.data);
localStorage.setItem("selectedRowData", JSON.stringify(event.data));
}, []);

const onBtnExport = useCallback(() => {
gridRef.current.api.exportDataAsCsv();
}, []);
Expand Down Expand Up @@ -235,8 +283,6 @@ function StudentListView() {
ref={gridRef}
rowData={rowData}
columnDefs={columnDefs}
animateRows={true}
onCellClicked={cellClickedListener}
pagination={true}
paginationAutoPageSize={true}
></AgGridReact>{" "}
Expand Down
7 changes: 7 additions & 0 deletions packages/admin/src/components/StudentResetPassword.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";

function StudentResetPassword() {
return <div>StudentResetPassword</div>;
}

export default StudentResetPassword;
1 change: 1 addition & 0 deletions packages/admin/src/routes/links.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export const studentBulk = baseLink + "/student/bulkupload";
export const schoolRegister = baseLink + "/school";
export const schoolBulk = baseLink + "/school/bulkupload";
export const teacherBulk = baseLink + "/teacher/bulkupload";
export const studentReset = baseLink + "/user/reset-password";

0 comments on commit 2ac592b

Please sign in to comment.