Skip to content

Commit 8a0f4c0

Browse files
committed
Fix template icons crashing sandbox modal
1 parent 86ebf61 commit 8a0f4c0

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

packages/app/src/app/pages/Dashboard/Content/CreateNewSandbox/NewSandboxModal/NewSandboxModal.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ interface INewSandboxModalProps {
2424
signals: any;
2525
}
2626

27+
interface ITab {
28+
name: string;
29+
tabIndex: number;
30+
}
31+
2732
export const NewSandboxModal = inject('store', 'signals')(
2833
hooksObserver(
2934
({
@@ -34,7 +39,7 @@ export const NewSandboxModal = inject('store', 'signals')(
3439
}: INewSandboxModalProps) => {
3540
const [selectedTab, setSelectedTab] = useState(0);
3641

37-
const tabs = [
42+
const tabs: ITab[] = [
3843
'Overview',
3944
user && 'My Templates',
4045
'Client Templates',
@@ -47,9 +52,8 @@ export const NewSandboxModal = inject('store', 'signals')(
4752
}))
4853
.filter(({ name }) => Boolean(name));
4954

50-
const selectTab = (tabIndex: number) => {
51-
const tab = tabs[tabIndex];
52-
setSelectedTab(tabIndex);
55+
const selectTab = (tab: ITab) => {
56+
setSelectedTab(tab.tabIndex);
5357

5458
track('New Sandbox Modal - Open Tab', { tabName: tab.name });
5559
};
@@ -62,13 +66,13 @@ export const NewSandboxModal = inject('store', 'signals')(
6266
return (
6367
<Container closing={closing} forking={forking}>
6468
<TabContainer forking={forking} closing={closing}>
65-
{tabs.map(({ name, tabIndex }) => (
69+
{tabs.map(tab => (
6670
<Button
6771
key={name}
6872
onClick={() => {
69-
selectTab(tabIndex);
73+
selectTab(tab);
7074
}}
71-
selected={selectedTab === tabIndex}
75+
selected={selectedTab === tab.tabIndex}
7276
>
7377
{name}
7478
</Button>

packages/common/src/components/Template/UserTemplate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import Icons from '@codesandbox/template-icons';
2+
import * as Icons from '@codesandbox/template-icons';
33
import color from 'color';
44
import { Template } from '../../types/index';
55
import getIcon from '../../templates/icons';

0 commit comments

Comments
 (0)