Skip to content

Commit

Permalink
Merge pull request #86 from 2004yash/main
Browse files Browse the repository at this point in the history
Bug fixes of leads page
  • Loading branch information
SkySingh04 authored Sep 24, 2024
2 parents 8bf7376 + 82ea365 commit d852d8e
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions components/leadspage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const Leads: React.FC = () => {
setCurrentLeads(currentLeads);
setAlumniLeads(alumniLeads);
await fetchLeads();
setLoading(false);
setLoading(false);
} catch (error) {
console.error("Error fetching leads:", error);
setLoading(false);
Expand Down Expand Up @@ -281,20 +281,28 @@ const LeadForm: React.FC<LeadFormProps> = ({ closeForm, selectedLead, onLeadUpda
selectedLead || { id: '', name: '', position: '', organization: '', additionalInfo: '', imageUrl: '' }
);

const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => {
const { name, value } = e.target;
setLead((prevLead) => ({ ...prevLead, [name]: value }));
};

const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.files && e.target.files[0]) {
// Check if e.target and e.target.files exist and have a file
if (e.target && e.target.files && e.target.files.length > 0) {
// Get the first file from the FileList
const file = e.target.files[0];

// Create an object URL for the selected file and update state
setLead((prevLead) => ({
...prevLead,
imageUrl: URL.createObjectURL(e.target.files[0]),
imageUrl: URL.createObjectURL(file),
}));
} else {
console.error("No file selected or input event is not valid.");
}
};


const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
await onLeadUpdate(); // Call onLeadUpdate to refresh the leads
Expand Down Expand Up @@ -355,29 +363,27 @@ const LeadForm: React.FC<LeadFormProps> = ({ closeForm, selectedLead, onLeadUpda
/>
</div>
<div style={{ marginBottom: '1rem' }}>
<label htmlFor="position" style={{
display: 'block',
fontSize: '1rem',
// marginBottom: '0.5rem',
color: '#333',
}}>Position:</label>
<input
type="text"
<label htmlFor="position">Position:</label>
<select
id="position"
name="position"
value={lead.position}
onChange={handleChange}
required
style={{
width: '100%',
// padding: '0.5rem',
borderRadius: '5px',
border: '1px solid #ccc',
fontSize: '1rem',
outline: 'none',
boxSizing: 'border-box',
}}
/>
>
<option value="">Select Position</option> {/* Placeholder option */}
<option value="Alumni">Alumni</option>
<option value="Current">Current</option>
</select>

</div>
<div style={{ marginBottom: '1rem' }}>
<label htmlFor="organization" style={{
Expand Down

0 comments on commit d852d8e

Please sign in to comment.