(props)
| 13 | import DetailCardImg from '../assets/images/Modal Image/Details.png' |
| 14 | |
| 15 | const MyProfileCard = (props) => { |
| 16 | const { project, updateProject, showDetailProject, showAlert } = props; |
| 17 | const [showModal, setShowModal] = useState(false); |
| 18 | const context = useContext(projectContext); |
| 19 | const { deleteProject } = context; |
| 20 | |
| 21 | const generateImageUrl = (projectId) => { |
| 22 | return `https://source.unsplash.com/910x900/?coding/?computer/&${projectId}`; |
| 23 | }; |
| 24 | |
| 25 | const handleModalOpen = () => { |
| 26 | setShowModal(true); |
| 27 | }; |
| 28 | |
| 29 | const handleModalClose = () => { |
| 30 | setShowModal(false); |
| 31 | }; |
| 32 | |
| 33 | const handleDelete = () => { |
| 34 | deleteProject(project._id); |
| 35 | showAlert("Deleted Successfully", "success"); |
| 36 | handleModalClose(); |
| 37 | }; |
| 38 | |
| 39 | // Profile Context |
| 40 | let navigate = useNavigate(); |
| 41 | const userProfileContext = useContext(profileContext); |
| 42 | const { userProfile, getUserProfile } = userProfileContext; |
| 43 | useEffect(() => { |
| 44 | if (localStorage.getItem('token')) { |
| 45 | getUserProfile(); |
| 46 | } |
| 47 | else { |
| 48 | navigate('/login') |
| 49 | } |
| 50 | // eslint-disable-next-line |
| 51 | }, []) |
| 52 | |
| 53 | // Function to format date |
| 54 | const formatDate = (dateString) => { |
| 55 | const date = new Date(dateString); |
| 56 | |
| 57 | const year = date.getFullYear().toString().slice(-2); // Get last 2 digits of the year |
| 58 | const month = ('0' + (date.getMonth() + 1)).slice(-2); // Add leading zero for single-digit months |
| 59 | const day = ('0' + date.getDate()).slice(-2); // Add leading zero for single-digit days |
| 60 | const hours = ('0' + date.getHours()).slice(-2); // Add leading zero for single-digit hours |
| 61 | const minutes = ('0' + date.getMinutes()).slice(-2); // Add leading zero for single-digit minutes |
| 62 | |
| 63 | // Format the date and time |
| 64 | return `${day}/${month}/${year} | ${hours}:${minutes}`; |
| 65 | }; |
| 66 | |
| 67 | // Max Length for title and description |
| 68 | const maxTitleLength = 30; |
| 69 | const maxDescriptionLength = 75; |
| 70 | |
| 71 | return ( |
| 72 | <div className="col-md-4 my-3"> |
nothing calls this directly
no test coverage detected