Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated button styling #68

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions client/src/pages/EditProfilePage/EditProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { useEffect, useState, ChangeEvent, FormEvent } from "react";
import React, {
useEffect,
useState,
useRef,
ChangeEvent,
FormEvent,
} from "react";
import { useAppSelector, useAppDispatch } from "../../app/hooks";
import {
fetchUserProfile,
Expand All @@ -10,6 +16,7 @@ const EditProfilePage = () => {
const dispatch = useAppDispatch();
const { profile, status } = useAppSelector((state) => state.userProfile);
const userID = useAppSelector((state) => state.user.userData?._id);
const fileInputRef = useRef<HTMLInputElement>(null);

const [formData, setFormData] = useState({
fullName: "",
Expand Down Expand Up @@ -68,6 +75,10 @@ const EditProfilePage = () => {
dispatch(uploadProfilePicture({ formData, userID }));
};

const handleFileInputClick = () => {
fileInputRef.current?.click();
};

if (status === "loading" || !userID) {
return <div>Loading...</div>;
}
Expand Down Expand Up @@ -120,17 +131,29 @@ const EditProfilePage = () => {
/>
</label>
<button
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
className="bg-gray-700 hover:bg-gray-800 text-white font-bold py-2 px-4 rounded"
type="submit"
>
Save Changes
</button>
</form>
<div className="mt-6">
<h3 className="text-2xl font-bold mb-4">Upload Profile Picture</h3>
<input type="file" onChange={handleFileChange} />
<input
ref={fileInputRef}
type="file"
onChange={handleFileChange}
style={{ display: "none" }}
/>
{file && <p className="text-lg mt-2">{file.name}</p>}
<button
className="bg-gray-700 hover:bg-gray-800 text-white font-bold py-2 px-4 rounded mt-4 mr-2"
onClick={handleFileInputClick}
>
Choose File
</button>
<button
className="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded mt-4"
className="bg-gray-700 hover:bg-gray-800 text-white font-bold py-2 px-4 rounded mt-4 ml-2"
onClick={handleImageUpload}
>
Upload Image
Expand Down
Loading