-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompany_profile.html
220 lines (202 loc) · 9.38 KB
/
company_profile.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Company Profile</title>
<!-- Add Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!--start of body put the nav bar in -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="home.html">
<img src="/art/ezSVG.svg" alt="Easy Intern" height="30" class="d-incline-block align-top">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="home.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.html">Register</a>
</li>
<li class="nav-item">
<a class="nav-link" href="login.html">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="faq.html">FAQ</a>
</li>
<!-- Add logout button -->
<li class="nav-item">
<button id="logout" name="logout" class="btn btn-primary">Log Out</button>
</li>
</ul>
</div>
</nav>
<script>
function logout() {
firebase.auth().signOut().then(() => {
alert("You have been logged out");
}).catch((error) => {
alert("Error: " + error.message);
});
}
document.getElementById("logout").addEventListener("click", logout);
</script>
<!--end of nav bar code-->
<div class="container">
<div class="card mt-5">
<div class="card-body">
<h1 class="card-title">Welcome to your Company Profile</h1>
<h4 class="card-subtitle mb-4 text-muted">About Us:</h4>
<p class="card-text" id="about-us">This is a place where you can write about your company...</p>
<button class="btn btn-primary" id="edit-about">Edit About Us</button>
</div>
</div>
<div class="card mt-5">
<div class="card-body">
<h4 class="card-title">Available Internships</h4>
<ul class="list-group list-group-flush" id="internships-list">
<!-- Your available internships will be listed here -->
</ul>
<button class="btn btn-primary mt-3" id="add-internship">Add Internship</button>
</div>
</div>
<div class="card mt-5">
<div class="card-body">
<h4 class="card-title">Matched Students</h4>
<ul class="list-group list-group-flush" id="matches-list">
<!-- Your matched students will be listed here -->
</ul>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-firestore-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.22.2/firebase-auth-compat.js"></script>
<script>
var firebaseConfig = {
apiKey: "AIzaSyD3uOK9dhNN_yV9Src3FHQoKFPIuqxzu8g",
authDomain: "easy-intern.firebaseapp.com",
projectId: "easy-intern",
storageBucket: "easy-intern.appspot.com",
messagingSenderId: "1032116527504",
appId: "1:1032116527504:web:7bb7fab99a11d5fae29315",
measurementId: "G-XMR4VMND5T"
};
// Initialize Firebase
const firebaseApp = firebase.initializeApp(firebaseConfig);
const db = firebase.firestore();
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
db.collection("companies").doc(user.uid)
.onSnapshot(function(doc) {
if (doc.exists) {
// Update the About Us section
$('#about-us').text(doc.data().aboutUs);
// Update the Internships list
$('#internships-list').empty();
if(doc.data().internships) {
doc.data().internships.forEach(function(internship) {
$('#internships-list').append('<li class="list-group-item">' + internship + '</li>');
});
}
}
});
}
});
// Add functionality to edit the About Us section
// Add functionality to edit the About Us section
$('#edit-about').click(function() {
var newAboutUs = prompt("Enter your new 'About Us':", "");
if (newAboutUs != null) {
var user = firebase.auth().currentUser;
db.collection("companies").doc(user.uid).set({
aboutUs: newAboutUs
}, { merge: true });
}
});
// Add functionality to add an internship
$('#add-internship').click(function() {
var newInternship = prompt("Enter the title of the new internship:", "");
if (newInternship != null) {
var user = firebase.auth().currentUser;
db.collection("companies").doc(user.uid).set({
internships: firebase.firestore.FieldValue.arrayUnion(newInternship)
}, { merge: true });
}
});
</script>
<!-- Add jQuery and Bootstrap JS -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<!--adding filtering-->
<div class="card mt-5" style="margin: 0 auto; width:50vw;">
<div class="card-body">
<h4 class="card-title">Filter Students</h4>
<div>
<input type="text" id="major-input" placeholder="Enter Major">
<input type="number" id="gpa-input" placeholder="Enter Minimum GPA">
<button class="btn btn-primary" id="filter-students">Filter Students</button>
</div>
<ul class="list-group list-group-flush" id="filtered-students-list">
<!-- Filtered students will be listed here -->
</ul>
</div>
</div>
<script>
$('#filter-students').click(function() {
var desiredMajor = $('#major-input').val();
var minGPA = $('#gpa-input').val();
// Validate inputs
if (desiredMajor === "" || minGPA === "") {
alert("Please fill in all fields.");
return;
}
$('#filtered-students-list').empty();
db.collection("students")
.where("major", "==", desiredMajor)
.where("gpa", ">=", Number(minGPA))
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.data().userId); // Add this line
// Here we assume that the 'userId' field in the students' document corresponds to the document ID in the users' collection
db.collection("users").doc(doc.data().userId)
.get()
.then((userDoc) => {
if (userDoc.exists) {
// Use 'firstName' and 'lastName' fields from the user's document
$('#filtered-students-list').append('<li class="list-group-item">' + userDoc.data().firstName + ' ' + userDoc.data().lastName + '</li>');
} else {
console.log("No such user document!");
}
}).catch((error) => {
console.log("Error getting user document:", error);
});
});
})
.catch((error) => {
console.log("Error getting documents: ", error);
});
});
</script>
<link rel="stylesheet" href="/homeStyles/styles.css">
<footer>
<div class="footerLinks">
<a href="/contact.html">Contact Us</a>
<div class="bar"></div>
<a href="/faq.html">FAQ</a>
</div>
<p>© 2023 Easy Intern. All rights reserved.</p>
</footer>
</body>
</html>