Skip to content

Instantly share code, notes, and snippets.

@thomasJang
Created May 15, 2019 11:47
Show Gist options
  • Save thomasJang/cd3b4339461a469f5e4cdd76d66fadd3 to your computer and use it in GitHub Desktop.
Save thomasJang/cd3b4339461a469f5e4cdd76d66fadd3 to your computer and use it in GitHub Desktop.
alram-confirmButtons.js
const confirmButtons = {
[NotificationType.ORG_MEMBER_INVITED]: (
<div data-button-gorup>
<Button
size="small"
type="primary"
onClick={() => {
handleInvitation('acceptInvitation', msg);
}}
>
{t.pages.common.notification.inviteAccept}
</Button>
<Button
size="small"
onClick={() => {
handleInvitation('denyInvitation', msg);
}}
>
{t.pages.common.notification.inviteDeny}
</Button>
</div>
),
[NotificationType.ORG_MEMBER_JOIN_REQUEST]: (
<div data-button-gorup>
<Button
size="small"
type="primary"
onClick={() => {
handleInvitation('acceptInvitation', msg);
}}
>
{t.pages.common.notification.inviteAccept}
</Button>
<Button
size="small"
onClick={() => {
handleInvitation('denyInvitation', msg);
}}
>
{t.pages.common.notification.inviteDeny}
</Button>
</div>
),
[NotificationType.ORG_MEMBER_AUTH_REQUESTED]: (
<div data-button-gorup>
<Button
size="small"
type="primary"
onClick={() => {
handleChangeAuthority('accept', msg);
}}
>
{t.pages.common.notification.inviteAccept}
</Button>
<Button
size="small"
onClick={() => {
handleChangeAuthority('deny', msg);
}}
>
{t.pages.common.notification.inviteDeny}
</Button>
</div>
),
[NotificationType.CONNECTION_INFO_SHARED]: (
<div data-button-gorup>
<Button
size="small"
type="primary"
onClick={() => {
// TODO 해당 커넥션으로 이동
handleMoveToConnectionView(msg);
}}
>
{t.pages.common.notification.connection}
</Button>
</div>
),
};
const hasButton = !!confirmButtons[msg.notiType];
const MyButton = () => {
{
/* case
button이 있고, responseResult존재하지 않으면 -> confirmButton
button이 있고, responseResult결과가 있으면 -> notiType에 따라서 있으면 null
button이 있고, responseResult결과가 있으면 -> notiType에 따라서 없으면 완료된 케이스
button이 없으면, null
*/
}
if (!hasButton) {
return null;
}
if (!msg.responseResult) {
return confirmButtons[msg.notiType];
}
console.log(msg);
if (msg.actionYn === 'Y') {
return null;
}
if (
msg.notiType === NotificationType.ORG_MEMBER_JOIN_REQUEST ||
msg.notiType === NotificationType.ORG_MEMBER_AUTH_REQUESTED
) {
return null;
} else if (msg.responseResult === 'DENY') {
return null;
} else if (isError === true) {
console.log(isError);
return null;
} else {
return (
<>
<div data-button-gorup>
<Button
size="small"
type="primary"
onClick={() => {
handleMoveToTeams(msg);
}}
>
{t.pages.common.notification.moveToTeam}
</Button>
</div>
</>
);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment