Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbradford committed Aug 31, 2023
1 parent 62050c1 commit b48dc74
Show file tree
Hide file tree
Showing 6 changed files with 371 additions and 349 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"rules": {
// I suggest you add those two rules:
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-explicit-any": "warn",
// semicolons are required
"semi": ["error", "always"]
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/home/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ export default function AppShell(props: AppShellProps) {
user={props.user}
errorMessage={`No form found for ${formId}`}
/>
)
);
}
setActiveForm(selectedForm)
setMode(formDetailAppMode)
setActiveForm(selectedForm);
setMode(formDetailAppMode);
}}
/>
);
Expand Down
13 changes: 9 additions & 4 deletions src/components/home/modes/DashboardMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ type DashboardModeProps = {
};

const openInNewTab = (url: string) => {
const newWindow = window.open(url, '_blank', 'noopener,noreferrer')
if (newWindow) newWindow.opener = null
}
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
if (newWindow) newWindow.opener = null;
};

export default function DashboardMode(props: DashboardModeProps) {
if (props.forms.length === 0) {
Expand Down Expand Up @@ -73,7 +73,12 @@ export default function DashboardMode(props: DashboardModeProps) {
View responses
</button>
{f.is_open ? (
<button onClick={() => openInNewTab(`https://talkform.ai/forms/fill/${f.id}`)} className="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
<button
onClick={() =>
openInNewTab(`https://talkform.ai/forms/fill/${f.id}`)
}
className="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
>
<LinkIcon className="h-5 w-5" aria-hidden="true" />
</button>
) : null}
Expand Down
8 changes: 6 additions & 2 deletions src/components/home/modes/FormDetailMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default function FormDetailMode(props: FormDetailModeProps) {
const badgeColor = props.form.is_open
? 'bg-green-100 text-green-800'
: 'bg-red-100 text-red-800';
const camelCaseTitle = props.form.name.charAt(0).toUpperCase() + props.form.name.slice(1, props.form.name.length);
const camelCaseTitle =
props.form.name.charAt(0).toUpperCase() +
props.form.name.slice(1, props.form.name.length);
return (
<>
<div className="flex min-w-0 gap-x-4">
Expand All @@ -32,7 +34,9 @@ export default function FormDetailMode(props: FormDetailModeProps) {
</div>
</div>
<ResponsesTable
data={props.responses.map((response) => response.results as Array<Record<string, any>>)}
data={props.responses.map(
(response) => response.results as Array<Record<string, any>>
)}
/>
</>
);
Expand Down
78 changes: 41 additions & 37 deletions src/components/home/modes/ResponsesTable.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@

interface Props {
data: Array<Record<string, any>>;
data: Array<Record<string, any>>;
}

const ResponsesTable: React.FC<Props> = ({ data }) => {
if (!data || data.length === 0) return <div>No data available.</div>;

// Assuming all lists have a similar structure, so we'll use the first list's first item for headers
const sampleItem = data[0];
if (!sampleItem) return <div>{`${data.length} responses collected but all are empty`}</div>;

const headers = Object.keys(sampleItem);

return (
<div className="overflow-x-auto">
{data.map((list, listIndex) => (
<div key={listIndex} className="mb-8">
<table className="min-w-full bg-white table-auto">
<thead className="bg-gray-800 text-white">
<tr>
{headers.map(header => (
<th key={header} className="px-4 py-2">{header}</th>
if (!data || data.length === 0) return <div>No data available.</div>;

// Assuming all lists have a similar structure, so we'll use the first list's first item for headers
const sampleItem = data[0];
if (!sampleItem)
return <div>{`${data.length} responses collected but all are empty`}</div>;

const headers = Object.keys(sampleItem);

return (
<div className="overflow-x-auto">
{data.map((list, listIndex) => (
<div key={listIndex} className="mb-8">
<table className="min-w-full bg-white table-auto">
<thead className="bg-gray-800 text-white">
<tr>
{headers.map((header) => (
<th key={header} className="px-4 py-2">
{header}
</th>
))}
</tr>
</thead>
<tbody className="text-gray-700">
{data.map((row, rowIndex) => (
<tr key={rowIndex}>
{headers.map((header) => (
<td key={header} className="border px-4 py-2">
{row[header] || 'N/A'}
</td>
))}
</tr>
</thead>
<tbody className="text-gray-700">
{data.map((row, rowIndex) => (
<tr key={rowIndex}>
{headers.map(header => (
<td key={header} className="border px-4 py-2">{row[header] || 'N/A'}</td>
))}
</tr>
))}
</tbody>
</table>
</div>
))}
</div>
);
))}
</tbody>
</table>
</div>
))}
</div>
);
};
export default ResponsesTable;

export default ResponsesTable;
Loading

0 comments on commit b48dc74

Please sign in to comment.