Skip to content

Commit 65f17ab

Browse files
authored
fix: show more human friendly error message (#88)
1 parent e7c8ba5 commit 65f17ab

3 files changed

Lines changed: 84 additions & 8 deletions

File tree

dev/main.tsx

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ const HubWrapper: React.FC = () => {
1414
const appUrl = import.meta.env.VITE_APP_URL ?? 'https://app.stackone.com';
1515
const [theme, setTheme] = useState<'light' | 'dark'>('light');
1616
const [accountId, setAccountId] = useState<string>();
17+
const [originOwnerId, setOriginOwnerId] = useState<string>(
18+
import.meta.env.VITE_ORIGIN_OWNER_ID ?? 'dummy_customer_id',
19+
);
20+
const [originOwnerName, setOriginOwnerName] = useState<string>(
21+
import.meta.env.VITE_ORIGIN_OWNER_NAME ?? 'dummy_customer_name',
22+
);
23+
const [originUsername, setOriginUsername] = useState<string>(
24+
import.meta.env.VITE_ORIGIN_USERNAME ?? 'dummy_username',
25+
);
1726

1827
const fetchToken = useCallback(async () => {
1928
try {
@@ -30,10 +39,9 @@ const HubWrapper: React.FC = () => {
3039
},
3140
body: {
3241
metadata: { source: 'hub' },
33-
origin_owner_id: import.meta.env.VITE_ORIGIN_OWNER_ID ?? 'dummy_customer_id',
34-
origin_owner_name:
35-
import.meta.env.VITE_ORIGIN_OWNER_NAME ?? 'dummy_customer_name',
36-
origin_username: import.meta.env.VITE_ORIGIN_USERNAME ?? 'dummy_username',
42+
origin_owner_id: originOwnerId,
43+
origin_owner_name: originOwnerName,
44+
origin_username: originUsername,
3745
account_id: accountId !== '' && accountId != null ? accountId : undefined,
3846
},
3947
});
@@ -48,7 +56,7 @@ const HubWrapper: React.FC = () => {
4856
} finally {
4957
setLoading(false);
5058
}
51-
}, [accountId]);
59+
}, [accountId, originOwnerId, originOwnerName, originUsername]);
5260

5361
useEffect(() => {
5462
fetchToken();
@@ -70,9 +78,57 @@ const HubWrapper: React.FC = () => {
7078
{theme === 'light' ? '🌞' : '🌚'}
7179
</button>
7280
</div>
73-
<input type="text" value={accountId} onChange={(e) => setAccountId(e.target.value)} />
81+
<input
82+
style={{
83+
marginBottom: '10px',
84+
width: '100%',
85+
border: '1px solid #ccc',
86+
borderRadius: '5px',
87+
padding: '5px',
88+
}}
89+
type="text"
90+
value={accountId}
91+
onChange={(e) => setAccountId(e.target.value)}
92+
/>
93+
<input
94+
style={{
95+
marginBottom: '10px',
96+
width: '100%',
97+
border: '1px solid #ccc',
98+
borderRadius: '5px',
99+
padding: '5px',
100+
}}
101+
type="text"
102+
value={originOwnerId}
103+
onChange={(e) => setOriginOwnerId(e.target.value)}
104+
/>
105+
<input
106+
style={{
107+
marginBottom: '10px',
108+
width: '100%',
109+
border: '1px solid #ccc',
110+
borderRadius: '5px',
111+
padding: '5px',
112+
}}
113+
type="text"
114+
value={originOwnerName}
115+
onChange={(e) => setOriginOwnerName(e.target.value)}
116+
/>
117+
<input
118+
style={{
119+
marginBottom: '10px',
120+
width: '100%',
121+
border: '1px solid #ccc',
122+
borderRadius: '5px',
123+
padding: '5px',
124+
}}
125+
type="text"
126+
value={originUsername}
127+
onChange={(e) => setOriginUsername(e.target.value)}
128+
/>
74129
<h1>StackOneHub Demo</h1>
75130
<StackOneHub
131+
key={token}
76132
mode={mode}
77133
token={token}
78134
baseUrl={apiUrl}

src/modules/integration-picker/components/IntegrationPickerContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const IntegrationPickerContent: React.FC<IntegrationPickerContentProps> =
9393
// Integration selection flow
9494
if (!selectedIntegration) {
9595
if (!hubData?.integrations.length) {
96-
return <ErrorView message="No integrations found." />;
96+
return <ErrorView message="No configured integrations available." />;
9797
}
9898
return (
9999
<IntegrationListView
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1+
import {
2+
Flex,
3+
FlexAlign,
4+
FlexDirection,
5+
FlexGapSize,
6+
FlexJustify,
7+
Typography,
8+
} from '@stackone/malachite';
19
import React from 'react';
210

311
interface ErrorViewProps {
412
message: string;
513
}
614

715
export const ErrorView: React.FC<ErrorViewProps> = ({ message }) => {
8-
return <div>Error: {message}</div>;
16+
return (
17+
<Flex
18+
justify={FlexJustify.Center}
19+
align={FlexAlign.Center}
20+
direction={FlexDirection.Vertical}
21+
gapSize={FlexGapSize.Small}
22+
fullHeight
23+
>
24+
<Typography.Text size="medium" fontWeight="semi-bold">
25+
{message}
26+
</Typography.Text>
27+
</Flex>
28+
);
929
};

0 commit comments

Comments
 (0)