Skip to content

Commit 07e3e2a

Browse files
committed
add loading states to modal
1 parent df6b4c6 commit 07e3e2a

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

src/components/relay-dashboard/paid-subscribers/SubscriberDetailModal/SubscriberDetailModal.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { Modal, message } from 'antd';
2+
import { Modal, message, Spin, Typography } from 'antd';
33
import {
44
KeyOutlined,
55
CalendarOutlined,
@@ -10,15 +10,43 @@ import {
1010
} from '@ant-design/icons';
1111
import { SubscriberProfile } from '@app/hooks/usePaidSubscribers';
1212
import * as S from './SubscriberDetailModal.styles';
13+
1314
interface SubscriberDetailModalProps {
1415
subscriber: SubscriberProfile | null;
16+
loading?: boolean;
17+
fetchFailed?: boolean;
1518
isVisible: boolean;
1619
onClose: () => void;
1720
}
1821

19-
export const SubscriberDetailModal: React.FC<SubscriberDetailModalProps> = ({ subscriber, isVisible, onClose }) => {
22+
export const SubscriberDetailModal: React.FC<SubscriberDetailModalProps> = ({ subscriber, isVisible, onClose, loading = false, fetchFailed = false }) => {
2023
const [copied, setCopied] = useState(false);
24+
// Loading state
25+
if (!subscriber && loading && !fetchFailed) {
26+
return (
27+
<Modal open={isVisible} footer={null} onCancel={onClose} centered>
28+
<Spin tip="Loading..." />
29+
</Modal>
30+
);
31+
}
2132

33+
// Error state
34+
if (!subscriber && !loading && fetchFailed) {
35+
return (
36+
<Modal open={isVisible} footer={null} onCancel={onClose} centered>
37+
<Typography.Text type="danger">Failed to fetch subscriber profile. Please try again.</Typography.Text>
38+
</Modal>
39+
);
40+
}
41+
42+
// Not found state
43+
if (!subscriber && !loading && !fetchFailed) {
44+
return (
45+
<Modal open={isVisible} footer={null} onCancel={onClose} centered>
46+
<Typography.Text type="secondary">Couldn't find this subscriber profile.</Typography.Text>
47+
</Modal>
48+
);
49+
}
2250
if (!subscriber) {
2351
return null;
2452
}

0 commit comments

Comments
 (0)