Skip to content

Commit a0ef240

Browse files
committed
refactor: RecentSandboxes to use Typescript
1 parent f9906fc commit a0ef240

File tree

2 files changed

+17
-10
lines changed
  • packages/app/src/app/pages/Dashboard/Content

2 files changed

+17
-10
lines changed

packages/app/src/app/pages/Dashboard/Content/Sandboxes/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ import { Filters } from './Filters';
66
import { DashboardActions } from './Actions';
77
import { ITemplate } from './types';
88

9-
interface Props {
9+
interface IContentProps {
1010
sandboxes: any[];
11-
Header: React.ComponentType;
12-
SubHeader: React.ComponentType;
13-
ExtraElement: React.ComponentType;
11+
Header: React.ComponentType | string;
12+
SubHeader?: React.ComponentType;
13+
ExtraElement: React.ComponentType<IExtraElementProps>;
1414

15-
possibleTemplates: ITemplate[];
15+
possibleTemplates?: ITemplate[];
1616
isLoading?: boolean;
1717
hideOrder?: boolean;
1818
hideFilters?: boolean;
19-
page?: number;
19+
page?: number | string;
2020
actions?: any[];
2121
}
2222

23+
interface IExtraElementProps {
24+
style: React.CSSProperties;
25+
}
26+
2327
// eslint-disable-next-line react/prefer-stateless-function
24-
export class Content extends React.Component<Props> {
28+
export class Content extends React.Component<IContentProps> {
2529
render() {
2630
const {
2731
sandboxes,

packages/app/src/app/pages/Dashboard/Content/routes/RecentSandboxes/index.js renamed to packages/app/src/app/pages/Dashboard/Content/routes/RecentSandboxes/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import Helmet from 'react-helmet';
2+
import { Helmet } from 'react-helmet';
33
import { useQuery } from '@apollo/react-hooks';
44

55
import { useOvermind } from 'app/overmind';
@@ -16,6 +16,11 @@ export const RecentSandboxes = () => {
1616
orderDirection: state.dashboard.orderBy.order.toUpperCase(),
1717
},
1818
});
19+
20+
if (error) {
21+
return <div>Error!</div>;
22+
}
23+
1924
const sandboxes = loading ? [] : (data && data.me && data.me.sandboxes) || [];
2025

2126
let mostUsedTemplate = null;
@@ -28,13 +33,11 @@ export const RecentSandboxes = () => {
2833
// We want to hide all templates
2934
// TODO: make this a query variable for graphql and move the logic to the server
3035
const noTemplateSandboxes = sandboxes.filter(s => !s.customTemplate);
31-
3236
return (
3337
<>
3438
<Helmet>
3539
<title>Recent Sandboxes - CodeSandbox</title>
3640
</Helmet>
37-
{error && <div>Error!</div>}
3841
<Sandboxes
3942
isLoading={loading}
4043
Header="Recent Sandboxes"

0 commit comments

Comments
 (0)