Skip to content

Commit cb3dbbf

Browse files
committed
first attempt to apply for jobs
1 parent 0f4c267 commit cb3dbbf

File tree

7 files changed

+265
-200
lines changed

7 files changed

+265
-200
lines changed

.firebase/hosting.ZGlzdA.cache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
favicon.png,1742999374775,e73ad37e8e066e7c600db58733033ab0b4e0b9ce7312e0c1e62435dedddfb108
22
404.html,1742999374775,41d1e074106979fb6591ec6953bfe5ace2788be22f0ed4189bd54905ebb5b44d
3-
index.html,1743123274320,bcbd84a56f93a1e3b4dba6c75afd3d00f775b01b919e9e10dc0804038ddd43b7
4-
assets/index-16017995.css,1743123274320,7fb4ae6c537fa9a71d93a9b3b46e47d7539915b1435cf64120ca9a20cdbbdca0
5-
assets/index-57a8abc9.js,1743123274321,e8d70a5be0ba1b39061042379106346bce25b00d0651e83a987c2eec0e1f5c26
3+
index.html,1743366134142,5f5044d3b53b852323546d26c4b44ab77dfdf0bd7414aa73031e28ff43afad08
4+
assets/index-16017995.css,1743366134136,7fb4ae6c537fa9a71d93a9b3b46e47d7539915b1435cf64120ca9a20cdbbdca0
5+
assets/index-051a4a8c.js,1743366134144,402976b5562491bc71166349178e16ab9cced59f9df882c4978810c8c0ed273a
Lines changed: 187 additions & 187 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
88
<title>ResearchFinder</title>
9-
<script type="module" crossorigin src="/assets/index-e1b95173.js"></script>
9+
<script type="module" crossorigin src="/assets/index-860cd27c.js"></script>
1010
<link rel="stylesheet" href="/assets/index-16017995.css">
1111
</head>
1212
<body>

src/App.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Footer from './components/Footer';
1111
import AddPostForm from './components/AddPostForm';
1212
import AdminDashboard from './components/AdminDashboard';
1313
import Terms from './components/Terms';
14+
import Apply from './components/Apply';
1415

1516
import { auth, db } from './config/firebase';
1617
import { onAuthStateChanged, signOut } from 'firebase/auth';
@@ -106,6 +107,14 @@ function App() {
106107
}
107108
/>
108109
<Route
110+
path="/apply/:id"
111+
element={
112+
<ProtectedRoute user={user}>
113+
<Apply assistantId={user?.uid} />
114+
</ProtectedRoute>
115+
}
116+
/>
117+
<Route
109118
path="/AddPostForm"
110119
element={
111120
<ProtectedRoute user={user}>

src/components/AddPostForm.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ const AddPostForm = ({ researcherID }) => {
3636

3737
try {
3838
const response = await axios.post(
39-
`https://research-finder-server.vercel.app/researcher/${researcherID}/posts`,
40-
formData
41-
);
39+
`https://research-finder-server.vercel.app/posts`,
40+
{
41+
researcherID, // now passed in the body, not in the URL
42+
...formData
43+
}
44+
)
4245

4346
setSuccess('Post added successfully!');
4447
setFormData({

src/components/Apply.jsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { useState } from 'react';
2+
import { useParams } from 'react-router-dom';
3+
import axios from 'axios';
4+
5+
const Apply = ({ assistantId }) => {
6+
const { id: postId } = useParams(); // grabs postId from URL
7+
const [message, setMessage] = useState('');
8+
const [status, setStatus] = useState(null);
9+
10+
const handleSubmit = async (e) => {
11+
e.preventDefault();
12+
13+
try {
14+
const res = await axios.post('https://research-finder-server.vercel.app/applications', {
15+
assistantId,
16+
postId,
17+
message
18+
});
19+
20+
setStatus('Application submitted successfully!');
21+
} catch (err) {
22+
console.error('Application error:', err.response?.data || err.message);
23+
setStatus('Failed to submit application.');
24+
}
25+
};
26+
27+
return (
28+
<div style={{ padding: '2rem' }}>
29+
<h2>Apply to Research Opportunity</h2>
30+
<form onSubmit={handleSubmit}>
31+
<label>
32+
Why are you interested?
33+
<textarea
34+
rows="5"
35+
value={message}
36+
onChange={(e) => setMessage(e.target.value)}
37+
required
38+
style={{ width: '100%', marginTop: '0.5rem' }}
39+
/>
40+
</label>
41+
<br />
42+
<button type="submit" style={{ marginTop: '1rem' }}>
43+
Submit Application
44+
</button>
45+
</form>
46+
47+
{status && <p>{status}</p>}
48+
</div>
49+
);
50+
};
51+
52+
export default Apply;

src/components/FeedDisplay.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import React from 'react';
22
import './FeedDisplay.css';
3+
import { Link } from 'react-router-dom'; // <-- Make sure this is imported
34

45
const FeedDisplay = ({ data }) => {
5-
console.log('FeedDisplay received data:', data); // Debugging
6+
if (!data) return <p>No data available.</p>;
67

7-
if (!data) {
8-
return <p>No data available.</p>;
9-
}
10-
11-
const { title, body, compensation, organization, researcherName, workType } = data;
8+
const { id, title, body, compensation, organization, researcherName, workType } = data;
129

1310
return (
1411
<div className="feed-display-card">
@@ -18,6 +15,10 @@ const FeedDisplay = ({ data }) => {
1815
<p><strong>Organization:</strong> {organization || 'Unknown'}</p>
1916
<p><strong>Researcher:</strong> {researcherName || 'Unknown'}</p>
2017
<p><strong>Work Type:</strong> {workType || 'Not specified'}</p>
18+
19+
<Link to={`/apply/${id}`}>
20+
<button className="apply-button">Apply</button>
21+
</Link>
2122
</div>
2223
);
2324
};

0 commit comments

Comments
 (0)