merged with main
This commit is contained in:
parent
6141e6d1d9
commit
3bcbe4cd6b
1 changed files with 60 additions and 37 deletions
|
|
@ -130,6 +130,7 @@ const AssignmentPage = () => {
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
if (!user.userId) return alert("Please login to submit an assignment.");
|
if (!user.userId) return alert("Please login to submit an assignment.");
|
||||||
|
|
||||||
|
|
@ -143,13 +144,14 @@ const AssignmentPage = () => {
|
||||||
formData.append("description", description);
|
formData.append("description", description);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (editingIndex !== null) {
|
//replace with api
|
||||||
const updatedProjects = [...projects];
|
// if (editingIndex !== null) {
|
||||||
updatedProjects[editingIndex] = newProject;
|
// const updatedProjects = [...projects];
|
||||||
setProjects(updatedProjects);
|
// updatedProjects[editingIndex] = newProject;
|
||||||
} else {
|
// setProjects(updatedProjects);
|
||||||
setProjects([...projects, newProject]);
|
// } else {
|
||||||
}
|
// setProjects([...projects, newProject]);
|
||||||
|
// }
|
||||||
|
|
||||||
alert(editingIndex !== null ? "Assignment updated!" : "Assignment submitted!");
|
alert(editingIndex !== null ? "Assignment updated!" : "Assignment submitted!");
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
@ -280,15 +282,6 @@ const AssignmentPage = () => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="assignment-search-box">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="🔍︎ Search"
|
|
||||||
value={searchTerm}
|
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{showModal && (
|
{showModal && (
|
||||||
<div className="modal-overlay">
|
<div className="modal-overlay">
|
||||||
<div className="modal">
|
<div className="modal">
|
||||||
|
|
@ -338,19 +331,22 @@ const AssignmentPage = () => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div className="password-field">
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} required />
|
<div className="input-wrapper">
|
||||||
</div>
|
<input
|
||||||
|
type={showPassword ? "text" : "password"}
|
||||||
<div>
|
value={password}
|
||||||
<label>Password</label>
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
<input
|
required
|
||||||
type="password"
|
/>
|
||||||
value={password}
|
<span
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
className="eye-icon"
|
||||||
required
|
onClick={() => setShowPassword((prev) => !prev)}
|
||||||
/>
|
>
|
||||||
|
{showPassword ? "Hide" : "Show"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -367,9 +363,20 @@ const AssignmentPage = () => {
|
||||||
<input type="file" onChange={(e) => setFile(e.target.files[0])} />
|
<input type="file" onChange={(e) => setFile(e.target.files[0])} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{loading && (
|
||||||
|
<div className="spinner-container">
|
||||||
|
<div className="spinner"></div>
|
||||||
|
<p>Uploading...</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="modal-buttons">
|
<div className="modal-buttons">
|
||||||
<button type="submit">{editingIndex !== null ? "Update" : "Submit"}</button>
|
<button type="submit" disabled={loading}>
|
||||||
<button type="button" onClick={() => { resetForm(); setShowModal(false); }}>Cancel</button>
|
{editingIndex !== null ? "Update" : "Submit"}
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={() => { resetForm(); setShowModal(false); }} disabled={loading}>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -378,13 +385,29 @@ const AssignmentPage = () => {
|
||||||
|
|
||||||
{projects.length > 0 && (
|
{projects.length > 0 && (
|
||||||
<div className="project-list">
|
<div className="project-list">
|
||||||
{projects.map((project, index) => (
|
{projects
|
||||||
<div key={index} className="project-item">
|
.filter((project) => {
|
||||||
<div className="project-meta">
|
if (!searchTerm.trim()) return true;
|
||||||
<strong>Student Name:</strong> {project.studentname || project.studentName} |{" "}
|
const regex = new RegExp(searchTerm, "i");
|
||||||
<strong>CampID:</strong> {project.campid || project.campID} |{" "}
|
return (
|
||||||
<strong>ProgramID:</strong> {project.programid || project.programID}
|
regex.test(project.studentname || project.studentName || "") ||
|
||||||
</div>
|
regex.test(project.campid || project.campID || "") ||
|
||||||
|
regex.test(project.programid || project.programID || "") ||
|
||||||
|
regex.test(project.title || "") ||
|
||||||
|
regex.test(project.description || "") ||
|
||||||
|
regex.test(project.fileName || "") ||
|
||||||
|
regex.test(project.assignmenturl || "") ||
|
||||||
|
regex.test(project.originalfile || "") ||
|
||||||
|
regex.test(project.editablefile || "")
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.map((project, index) => (
|
||||||
|
<div key={index} className="project-item">
|
||||||
|
<div className="project-meta">
|
||||||
|
<p><strong>Student Name:</strong> {project.studentname || project.studentName}</p>
|
||||||
|
<p><strong>CampID:</strong> {project.campid || project.campID}</p>
|
||||||
|
<p><strong>ProgramID:</strong> {project.programid || project.programID}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
{project.title && <h4>{project.title}</h4>}
|
{project.title && <h4>{project.title}</h4>}
|
||||||
{project.description && <p>{project.description}</p>}
|
{project.description && <p>{project.description}</p>}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue