Skip to content

Commit

Permalink
Merge pull request #35 from Aar-if/newaltv1
Browse files Browse the repository at this point in the history
removed reminder and added scroll bar
  • Loading branch information
snehal0904 authored Dec 13, 2023
2 parents 62ac884 + e006095 commit 4b50a58
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 109 deletions.
212 changes: 107 additions & 105 deletions packages/admin/src/components/StudentListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function StudentListView() {
const [rowData, setRowData] = useState([]);
const [currentPage, setCurrentPage] = useState(2);


const openPrompt = async (data) => {
let person = window.prompt(
`Enter a new password for user ${data.username}`
Expand Down Expand Up @@ -145,8 +144,6 @@ function StudentListView() {
{ field: "noOfSiblings" },
]);



//Download username and pass with prompt

// const onBtnExportFields = useCallback(() => {
Expand Down Expand Up @@ -192,50 +189,43 @@ function StudentListView() {
console.log("cellClicked", event);
}, []);

const onBtnExportFields = async() => {

let person = window.prompt(
`Enter a School Udise`
);
const onBtnExportFields = async () => {
let person = window.prompt(`Enter a School Udise`);
if (person == null || person == "") {
alert("Please enter a valid password");
} else {
console.log(person)


console.log(person);

const result = await studentUsernamePasswordAPI(person);
if (result) {

const filteredData = result.data.data;
console.log(filteredData);

const selectedFieldsData = filteredData.map((row) => ({
Name: row.name,
UserName: row.username,
Password: row.password,
}));

// Convert the data to CSV format using PapaParse
const csvData = Papa.unparse(selectedFieldsData);

// Create a Blob containing the CSV data
const blob = new Blob([csvData], { type: "text/csv;charset=utf-8;" });

// Create a download link and trigger the download
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "student_data_filtered_user_password.csv";
link.style.display = "none";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
const selectedFieldsData = filteredData.map((row) => ({
Name: row.name,
UserName: row.username,
Password: row.password,
}));

// Convert the data to CSV format using PapaParse
const csvData = Papa.unparse(selectedFieldsData);

// Create a Blob containing the CSV data
const blob = new Blob([csvData], { type: "text/csv;charset=utf-8;" });

// Create a download link and trigger the download
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "student_data_filtered_user_password.csv";
link.style.display = "none";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
};



useEffect(() => {
useEffect(() => {
const token = sessionStorage.getItem("token");
setToken(token);
}, []);
Expand All @@ -256,7 +246,9 @@ function StudentListView() {
filters: {},
};

const response = await axios.post(studentSearch, requestData, { headers });
const response = await axios.post(studentSearch, requestData, {
headers,
});
setRowData(response.data.data);
} catch (error) {
console.error("Error fetching data:", error);
Expand All @@ -266,73 +258,71 @@ function StudentListView() {
fetchData();
}, [token]);


const handlePaginationChanged = () => {
// Increment the current page when the "Next Page" button is clicked
console.log('clicked');

const fetchData = async () => {
try {
const headers = {
Accept: "*/*",
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};

const requestData = {
limit: "5",
page: currentPage,
filters: {},
};

const response = await axios.post(studentSearch, requestData, { headers });
setRowData(response.data.data);
setCurrentPage(currentPage + 1);
} catch (error) {
console.error("Error fetching data:", error);
}
};
console.log("clicked");

fetchData();

};
const fetchData = async () => {
try {
const headers = {
Accept: "*/*",
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};

const requestData = {
limit: "5",
page: currentPage,
filters: {},
};

const response = await axios.post(studentSearch, requestData, {
headers,
});
setRowData(response.data.data);
setCurrentPage(currentPage + 1);
} catch (error) {
console.error("Error fetching data:", error);
}
};

fetchData();
};

const handlePaginationChanged2 = () => {
// Increment the current page when the "Next Page" button is clicked
console.log('clicked');

const fetchData = async () => {
try {
const headers = {
Accept: "*/*",
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};

const requestData = {
limit: "5",
page: currentPage,
filters: {},
};

const response = await axios.post(studentSearch, requestData, { headers });
setRowData(response.data.data);
setCurrentPage(currentPage - 1);
} catch (error) {
console.error("Error fetching data:", error);
}
};
console.log("clicked");

fetchData();

const fetchData = async () => {
try {
const headers = {
Accept: "*/*",
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
};

const requestData = {
limit: "5",
page: currentPage,
filters: {},
};

const response = await axios.post(studentSearch, requestData, {
headers,
});
setRowData(response.data.data);
setCurrentPage(currentPage - 1);
} catch (error) {
console.error("Error fetching data:", error);
}
};

fetchData();
};


return (
<div className="ag-theme-material" style={{ height: 400, width: "100%" }}>
<div style={{ display: "flex", flexDirection: "row" }}>

<div style={{ display: "flex", flexDirection: "row" }}>
<button
onClick={onBtnExportFields}
style={{
Expand All @@ -353,27 +343,39 @@ function StudentListView() {
/>
<H4 style={{ color: "white" }}> Download username & password </H4>
</button>
</div>
<div style={{display: "flex", flexDirection: "row",justifyContent: "flex-end", paddingBottom: "10px", cursor: "pointer", zIndex: "1"}}>
<Button style={{cursor: "pointer"}}
onPress={handlePaginationChanged}>Previous Page</Button>
<Button style={{cursor: "pointer", marginLeft:"20px"}}
onPress={handlePaginationChanged2}>Next Page</Button>

</div>

<div
style={{
display: "flex",
flexDirection: "row",
justifyContent: "flex-end",
paddingBottom: "10px",
cursor: "pointer",
zIndex: "1",
}}
>
<Button style={{ cursor: "pointer" }} onPress={handlePaginationChanged}>
Previous Page
</Button>
<Button
style={{ cursor: "pointer", marginLeft: "20px" }}
onPress={handlePaginationChanged2}
>
Next Page
</Button>
</div>
<AgGridReact
ref={gridRef}
rowData={rowData}
columnDefs={columnDefs}
animateRows={true}
onCellClicked={cellClickedListener}
overlayNoRowsTemplate={'<span>Loading Student records....</span>'}

pagination={true}
paginationAutoPageSize={true}
overlayNoRowsTemplate={"<span>Loading Student records....</span>"}
></AgGridReact>{" "}


</div>
);
}

export default StudentListView;
export default StudentListView;
8 changes: 4 additions & 4 deletions packages/core/src/pages/StudentLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default function StudentLogin({ swPath }) {
let refreshToken = result.data.refresh_token;
console.log(refreshToken);
sessionStorage.setItem("refreshToken", refreshToken);
sessionStorage.setItem('token', token);
sessionStorage.setItem("token", token);

let resultTeacher = {};
// try {
Expand Down Expand Up @@ -266,16 +266,16 @@ export default function StudentLogin({ swPath }) {
<VStack overflow={"hidden"} space="" w="300px">
<Center>
<Box textAlign="center">
<H3 style={{ fontSize: "16px"}}>
<H3 style={{ fontSize: "16px" }}>
Accelerated Learning via Technology (ALT)
</H3>
<H3 style={{ fontSize: "16px", color : "red" }}>
{/* <H3 style={{ fontSize: "16px", color : "red" }}>
Reminder :
Dear Students,
Thank you for participating in the ALT Version 1 pilot.
We officially closed the pilot on 19th November, 2023.
</H3>
</H3> */}
</Box>
</Center>
<Center>
Expand Down

0 comments on commit 4b50a58

Please sign in to comment.