misc_pterodactyl-panel/resources/scripts/components/FlashMessageRender.tsx

29 lines
881 B
TypeScript
Raw Normal View History

import { useStoreState } from 'easy-peasy';
2022-11-25 20:25:03 +00:00
import { Fragment } from 'react';
import MessageBox from '@/components/MessageBox';
type Props = Readonly<{
byKey?: string;
2020-07-04 21:21:28 +00:00
className?: string;
}>;
function FlashMessageRender({ byKey, className }: Props) {
2022-11-25 20:25:03 +00:00
const flashes = useStoreState(state => state.flashes.items.filter(flash => (byKey ? flash.key === byKey : true)));
return flashes.length ? (
<div className={className}>
{flashes.map((flash, index) => (
2022-11-25 20:25:03 +00:00
<Fragment key={flash.id || flash.type + flash.message}>
{index > 0 && <div className="mt-2" />}
<MessageBox type={flash.type} title={flash.title}>
{flash.message}
</MessageBox>
2022-11-25 20:25:03 +00:00
</Fragment>
))}
</div>
) : null;
}
2020-07-04 21:21:28 +00:00
export default FlashMessageRender;