mirror of
https://github.com/Lissy93/web-check.git
synced 2025-08-15 23:28:01 +02:00
fix: handle undefined robots data and improve object destructuring in RobotsTxt component
This commit is contained in:
@ -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} />
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user