|
1 | 1 | // MessagePopup.js
|
2 | 2 | import React from 'react';
|
3 | 3 | import { FaCheckCircle, FaExclamationCircle } from 'react-icons/fa';
|
| 4 | +import { useTranslation } from 'react-i18next'; |
4 | 5 |
|
5 | 6 | const MessagePopup = ({ type, message, onClose }) => {
|
6 |
| - const { title, description } = message || {}; |
| 7 | + const { title, description } = message || {}; |
| 8 | + const { t } = useTranslation(); |
7 | 9 |
|
8 |
| - const IconComponent = type === 'error' ? FaExclamationCircle : FaCheckCircle; |
| 10 | + const IconComponent = type === 'error' ? FaExclamationCircle : FaCheckCircle; |
9 | 11 |
|
10 |
| - const titleColor = type === 'error' ? 'text-red-500' : 'text-green-600'; |
| 12 | + const titleColor = type === 'error' ? 'text-red-500' : 'text-green-600'; |
11 | 13 |
|
12 |
| - return ( |
13 |
| - <div className="fixed inset-0 flex items-center justify-center z-50"> |
14 |
| - <div className="absolute inset-0 bg-black opacity-50" onClick={() => onClose()}></div> |
| 14 | + return ( |
| 15 | + <div className="fixed inset-0 flex items-center justify-center z-50"> |
| 16 | + <div className="absolute inset-0 bg-black opacity-50" onClick={() => onClose()}></div> |
15 | 17 |
|
16 |
| - <div className="bg-white p-4 rounded-lg shadow-lg w-full lg:w-[33.33%] sm:w-[66.67%] z-10 relative m-4"> |
17 |
| - <div className="flex items-start justify-between border-b rounded-t dark:border-gray-600"> |
| 18 | + <div className="bg-white p-4 rounded-lg shadow-lg w-full lg:w-[33.33%] sm:w-[66.67%] z-10 relative m-4"> |
| 19 | + <div className="flex items-start justify-between border-b rounded-t dark:border-gray-600"> |
18 | 20 |
|
19 |
| - <h2 className={`text-lg font-bold mb-2 flex items-center ${titleColor}`}> |
20 |
| - <IconComponent size={20} className="inline mr-1" /> |
21 |
| - {title} |
22 |
| - </h2> |
23 |
| - <button type="button" className="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ml-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" onClick={() => onClose()}> |
24 |
| - <svg className="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14"> |
25 |
| - <path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" /> |
26 |
| - </svg> |
27 |
| - </button> |
28 |
| - </div> |
29 |
| - <hr className="mb-2 border-t border-custom-blue/80" /> |
30 |
| - <p className="mb-2 mt-4"> |
31 |
| - {description} |
32 |
| - </p> |
33 |
| - <div className="flex justify-end space-x-2 pt-4"> |
34 |
| - <button |
35 |
| - type="button" |
36 |
| - className="px-4 py-2 text-white bg-gray-500 hover:bg-gray-600 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-gray-300 dark:hover:bg-gray-400" |
37 |
| - onClick={onClose} |
38 |
| - > |
39 |
| - Close |
40 |
| - </button> |
41 |
| - </div> |
42 |
| - </div> |
43 |
| - </div> |
44 |
| - ); |
| 21 | + <h2 className={`text-lg font-bold mb-2 flex items-center ${titleColor}`}> |
| 22 | + <IconComponent size={20} className="inline mr-1" /> |
| 23 | + {title} |
| 24 | + </h2> |
| 25 | + <button type="button" className="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ml-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" onClick={() => onClose()}> |
| 26 | + <svg className="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14"> |
| 27 | + <path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" /> |
| 28 | + </svg> |
| 29 | + </button> |
| 30 | + </div> |
| 31 | + <hr className="mb-2 border-t border-custom-blue/80" /> |
| 32 | + <p className="mb-2 mt-4"> |
| 33 | + {description} |
| 34 | + </p> |
| 35 | + <div className="flex justify-end space-x-2 pt-4"> |
| 36 | + <button |
| 37 | + type="button" |
| 38 | + className="px-4 py-2 text-white bg-gray-500 hover:bg-gray-600 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-gray-300 dark:hover:bg-gray-400" |
| 39 | + onClick={onClose} |
| 40 | + > |
| 41 | + {t('messagePopup.close')} |
| 42 | + </button> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + ); |
45 | 47 | };
|
46 | 48 |
|
47 | 49 | export default MessagePopup;
|
0 commit comments