| 1 | import { |
| 2 | ExclamationCircleIcon, |
| 3 | ExclamationTriangleIcon, |
| 4 | } from "@heroicons/react/24/outline"; |
| 5 | import { useAppSelector } from "../../../../../redux/hooks"; |
| 6 | |
| 7 | export function ErrorSection() { |
| 8 | const configError = useAppSelector((state) => state.config.configError); |
| 9 | |
| 10 | const sortedErrors = configError |
| 11 | ? [...configError].sort((a, b) => (b.fatal ? 1 : 0) - (a.fatal ? 1 : 0)) |
| 12 | : []; |
| 13 | |
| 14 | return ( |
| 15 | <div className="flex flex-col gap-5 p-2"> |
| 16 | <ul className="m-0 list-none space-y-4 p-0"> |
| 17 | {sortedErrors.map((error, index) => ( |
| 18 | <li |
| 19 | key={index} |
| 20 | className={`flex items-start rounded-md p-2 text-sm shadow-md ${ |
| 21 | error.fatal |
| 22 | ? "bg-red-100 text-red-800" |
| 23 | : "bg-yellow-100 text-yellow-800" |
| 24 | }`} |
| 25 | > |
| 26 | {error.fatal ? ( |
| 27 | <ExclamationCircleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" /> |
| 28 | ) : ( |
| 29 | <ExclamationTriangleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" /> |
| 30 | )} |
| 31 | <p |
| 32 | className="m-0 whitespace-pre-wrap text-wrap" |
| 33 | style={{ wordBreak: "break-word" }} |
| 34 | > |
| 35 | {error.message} |
| 36 | </p> |
| 37 | </li> |
| 38 | ))} |
| 39 | </ul> |
| 40 | </div> |
| 41 | ); |
| 42 | } |