mirror of
https://github.com/balzack/databag.git
synced 2025-02-19 06:29:23 +00:00
rendering contact error status
This commit is contained in:
parent
e6de43a977
commit
3fc130b5c8
@ -18,6 +18,7 @@ const Colors = {
|
|||||||
requested: '#4488ff',
|
requested: '#4488ff',
|
||||||
pending: '#22aaaa',
|
pending: '#22aaaa',
|
||||||
confirmed: '#aaaaaa',
|
confirmed: '#aaaaaa',
|
||||||
|
error: '#ff4444',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Colors;
|
export default Colors;
|
||||||
|
@ -206,7 +206,6 @@ export function useCardContext() {
|
|||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
window.alert("failed to connect to contact");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,9 +359,9 @@ export function useCardContext() {
|
|||||||
let token = card.data.cardProfile.guid + "." + card.data.cardDetail.token;
|
let token = card.data.cardProfile.guid + "." + card.data.cardDetail.token;
|
||||||
return getContactChannelTopicAssetUrl(node, token, channelId, topicId, assetId);
|
return getContactChannelTopicAssetUrl(node, token, channelId, topicId, assetId);
|
||||||
},
|
},
|
||||||
resync: (cardId) => {
|
resync: async (cardId) => {
|
||||||
resync.current.push(cardId);
|
resync.current.push(cardId);
|
||||||
setCards(null);
|
await setCards(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import { CardItemWrapper, StatusConnected, StatusConnecting, StatusRequested, StatusPending, StatusConfirmed} from './CardItem.styled';
|
import { CardItemWrapper, StatusError,
|
||||||
|
StatusConnected, StatusConnecting,
|
||||||
|
StatusRequested, StatusPending,
|
||||||
|
StatusConfirmed} from './CardItem.styled';
|
||||||
import { useCardItem } from './useCardItem.hook';
|
import { useCardItem } from './useCardItem.hook';
|
||||||
import { Logo } from 'logo/Logo';
|
import { Logo } from 'logo/Logo';
|
||||||
import { Tooltip } from 'antd';
|
import { Tooltip } from 'antd';
|
||||||
|
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
export function CardItem({ item }) {
|
export function CardItem({ item }) {
|
||||||
|
|
||||||
@ -24,6 +28,13 @@ export function CardItem({ item }) {
|
|||||||
<div class="handle">{ handle() }</div>
|
<div class="handle">{ handle() }</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="markup">
|
<div class="markup">
|
||||||
|
{ !state.resync && item.error && (
|
||||||
|
<Tooltip placement="left" title="sync error">
|
||||||
|
<StatusError onClick={actions.resync}>
|
||||||
|
<ExclamationCircleOutlined />
|
||||||
|
</StatusError>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{ detail?.status === 'connected' && (
|
{ detail?.status === 'connected' && (
|
||||||
<Tooltip placement="left" title="connected contact">
|
<Tooltip placement="left" title="connected contact">
|
||||||
<StatusConnected />
|
<StatusConnected />
|
||||||
|
@ -42,9 +42,19 @@ export const CardItemWrapper = styled.div`
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const StatusError = styled.div`
|
||||||
|
color: ${Colors.error};
|
||||||
|
font-size: 14px;
|
||||||
|
padding-right: 8px;
|
||||||
|
`
|
||||||
|
|
||||||
export const StatusConnected = styled.div`
|
export const StatusConnected = styled.div`
|
||||||
background-color: ${Colors.connected};
|
background-color: ${Colors.connected};
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
@ -5,6 +5,7 @@ export function useCardItem(item) {
|
|||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
logo: null,
|
logo: null,
|
||||||
|
resync: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const card = useContext(CardContext);
|
const card = useContext(CardContext);
|
||||||
@ -18,6 +19,13 @@ export function useCardItem(item) {
|
|||||||
}, [card]);
|
}, [card]);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
resync: async () => {
|
||||||
|
if (!state.resync) {
|
||||||
|
updateState({ resync: true });
|
||||||
|
await card.actions.resync(item.id);
|
||||||
|
updateState({ resync: false });
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return { state, actions };
|
return { state, actions };
|
||||||
|
Loading…
Reference in New Issue
Block a user