fix: handle undefined robots data and improve object destructuring in RobotsTxt component

This commit is contained in:
tnga
2025-06-16 07:20:26 +01:00
parent 64510f7e7e
commit c0c146b2b9

View File

@ -11,15 +11,17 @@ const cardStyles = `
`; `;
const RobotsTxtCard = ( props: { data: { robots: RowProps[]}, title: string, actionButtons: any}): JSX.Element => { const RobotsTxtCard = ( props: { data: { robots: RowProps[]}, title: string, actionButtons: any}): JSX.Element => {
const robots = props.data; const { data } = props;
const robots = data?.robots || [];
return ( return (
<Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<div className="content"> <div className="content">
{ {
robots.robots.length === 0 && <p>No crawl rules found.</p> robots.length === 0 && <p>No crawl rules found.</p>
} }
{ {
robots.robots.map((row: RowProps, index: number) => { robots.map((row: RowProps, index: number) => {
return ( return (
<Row key={`${row.lbl}-${index}`} lbl={row.lbl} val={row.val} /> <Row key={`${row.lbl}-${index}`} lbl={row.lbl} val={row.val} />
) )