mirror of
https://github.com/balzack/databag.git
synced 2025-02-15 21:19:16 +00:00
styling membership modal
This commit is contained in:
parent
a53a3d4847
commit
03bcaa03b0
@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect, useRef } from 'react'
|
import React, { useState, useEffect, useRef } from 'react'
|
||||||
import { Avatar } from 'avatar/Avatar';
|
import { Avatar } from 'avatar/Avatar';
|
||||||
import { MemberItemWrapper } from './MemberItem.styled';
|
import { MemberItemWrapper, CheckIcon, UncheckIcon } from './MemberItem.styled';
|
||||||
import { useMemberItem } from './useMemberItem.hook';
|
import { useMemberItem } from './useMemberItem.hook';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
|
|
||||||
@ -13,9 +13,11 @@ export function MemberItem({ readonly, item }) {
|
|||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
if (item.member) {
|
if (item.member) {
|
||||||
return <Button type="primary" size="small" danger onClick={() => actions.clearMembership()}>Remove</Button>
|
return <Button type="link" icon={<CheckIcon />} loading={state.busy}
|
||||||
|
onClick={() => actions.clearMembership()} />
|
||||||
}
|
}
|
||||||
return <Button type="primary" size="small" onClick={() => actions.setMembership()}>Add</Button>
|
return <Button type="link" icon={<UncheckIcon />} loading={state.busy}
|
||||||
|
onClick={() => actions.setMembership()} />
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { CheckSquareOutlined, BorderOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
export const MemberItemWrapper = styled.div`
|
export const MemberItemWrapper = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -37,3 +38,10 @@ export const MemberItemWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const CheckIcon = styled(CheckSquareOutlined)`
|
||||||
|
font-size: 20px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const UncheckIcon = styled(BorderOutlined)`
|
||||||
|
font-size: 20px;
|
||||||
|
`;
|
||||||
|
@ -7,7 +7,8 @@ export function useMemberItem({ item }) {
|
|||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
name: null,
|
name: null,
|
||||||
handle: null
|
handle: null,
|
||||||
|
busy: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const card = useContext(CardContext);
|
const card = useContext(CardContext);
|
||||||
@ -27,10 +28,28 @@ export function useMemberItem({ item }) {
|
|||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
setMembership: async () => {
|
setMembership: async () => {
|
||||||
|
if (!state.busy) {
|
||||||
|
updateState({ busy: true });
|
||||||
|
try {
|
||||||
conversation.actions.setChannelCard(item.card.id);
|
conversation.actions.setChannelCard(item.card.id);
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
window.alert(err);
|
||||||
|
}
|
||||||
|
updateState({ busy: false });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
clearMembership: async () => {
|
clearMembership: async () => {
|
||||||
|
if (!state.busy) {
|
||||||
|
updateState({ busy: true });
|
||||||
|
try {
|
||||||
conversation.actions.clearChannelCard(item.card.id);
|
conversation.actions.clearChannelCard(item.card.id);
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
window.alert(err);
|
||||||
|
}
|
||||||
|
updateState({ busy: false });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user