Skip to content

Commit

Permalink
Merge pull request #384 from anbrue/feature/prettier-issues
Browse files Browse the repository at this point in the history
formatted for the happiness of prettier
  • Loading branch information
robearlam authored Mar 1, 2024
2 parents 1b8c900 + d3ba55f commit 85305be
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from 'react';
import { Field, Link as JssLink, LinkField, Text as JssText } from '@sitecore-jss/sitecore-jss-nextjs';
import {
Field,
Link as JssLink,
LinkField,
Text as JssText,
} from '@sitecore-jss/sitecore-jss-nextjs';

interface Fields {
Title: Field<string>;
Expand Down Expand Up @@ -27,9 +32,17 @@ export const Default = (props: ActionBannerProps): JSX.Element => {
return (
<div className={`component action-banner ${props.params.styles}`} id={id ? id : undefined}>
<div className="component-content">
<div className="col-1"><h2><JssText field={props.fields.Title} /></h2></div>
<div className="col-2"><JssText field={props.fields.Text} /></div>
<div className="col-1"><JssLink field={props.fields.CallToAction} /></div>
<div className="col-1">
<h2>
<JssText field={props.fields.Title} />
</h2>
</div>
<div className="col-2">
<JssText field={props.fields.Text} />
</div>
<div className="col-1">
<JssLink field={props.fields.CallToAction} />
</div>
</div>
</div>
);
Expand Down
72 changes: 34 additions & 38 deletions src/Project/Sugcon2024/Sugcon/src/components/Events/Agenda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,48 @@ import { Field } from '@sitecore-jss/sitecore-jss-nextjs';
import useSWR from 'swr';

interface Fields {
SessionizeUrl: Field<string>;
SessionizeUrl: Field<string>;
}

type AgendaProps = {
params: { [key: string]: string };
fields: Fields;
params: { [key: string]: string };
fields: Fields;
};

const AgendaDefaultComponent = (props: AgendaProps): JSX.Element => (
<div className={`component promo ${props.params.styles}`}>
<div className="component-content">
<span className="is-empty-hint">Agenda</span>
</div>
<div className={`component promo ${props.params.styles}`}>
<div className="component-content">
<span className="is-empty-hint">Agenda</span>
</div>
</div>
);

export const Default = (props: AgendaProps): JSX.Element => {
const id = props.params.RenderingIdentifier;

if (!props?.fields?.SessionizeUrl?.value) {
return <AgendaDefaultComponent {...props} />;
}

//Question: linter is saying the hook shouldn't be called conditionally, but that's correct in this case?
//eslint-disable-next-line
const { data, error } = useSWR(props.fields.SessionizeUrl.value, () => fetch(props.fields.SessionizeUrl.value).then((response) => response.text()));

//TODO: design error
if (error) {
return (
<div>Failed to load...</div>
);
}

//TODO: design loading
if (!data) {
return (
<div>Loading</div>
);
}

return (
<div className={`component agenda ${props.params.styles}`} id={id ? id : undefined}>
<div className="component-content">
<div dangerouslySetInnerHTML={{ __html: data as string }} />
</div>
</div>
);
const id = props.params.RenderingIdentifier;

if (!props?.fields?.SessionizeUrl?.value) {
return <AgendaDefaultComponent {...props} />;
}

//Question: linter is saying the hook shouldn't be called conditionally, but that's correct in this case?
//eslint-disable-next-line
const { data, error } = useSWR(props.fields.SessionizeUrl.value, () => fetch(props.fields.SessionizeUrl.value).then((response) => response.text()));

//TODO: design error
if (error) {
return <div>Failed to load...</div>;
}

//TODO: design loading
if (!data) {
return <div>Loading</div>;
}

return (
<div className={`component agenda ${props.params.styles}`} id={id ? id : undefined}>
<div className="component-content">
<div dangerouslySetInnerHTML={{ __html: data as string }} />
</div>
</div>
);
};

0 comments on commit 85305be

Please sign in to comment.