Instantly share code, notes, and snippets.
Created
May 15, 2019 11:47
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save thomasJang/cd3b4339461a469f5e4cdd76d66fadd3 to your computer and use it in GitHub Desktop.
alram-confirmButtons.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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