diff --git a/packages/app/src/components/TapShare/Dialog/index.jsx b/packages/app/src/components/TapShare/Dialog/index.jsx new file mode 100644 index 00000000..28a97655 --- /dev/null +++ b/packages/app/src/components/TapShare/Dialog/index.jsx @@ -0,0 +1,92 @@ +import React from "react" +import * as antd from "antd" +import { Icons } from "components/Icons" + +import UserCard from "components/UserCard" +import NFCModel from "comty.js/models/nfc" + +import "./index.less" + +const BehaviorTypeToAction = { + "url": "Open an URL", + "profile": "Open profile", +} + +const handleAction = { + "url": (value) => { + window.location.href = value + }, + "profile": (value) => { + app.navigation.goToAccount(value) + }, + "post": (value) => { + app.message.error("Not supported yet") + } +} + +export default (props) => { + const [L_Tag, R_Tag, E_Tag] = app.cores.api.useRequest(NFCModel.getTagBySerial, props.tag.serialNumber) + + if (L_Tag) { + return + } + + if (!R_Tag || E_Tag) { + return + } + + const onClick = (action) => { + handleAction[action.type](action.value) + + props.close() + } + + const actions = [ + R_Tag.behavior, + { + type: "profile", + value: R_Tag.user.username + } + ] + + return
+
+ +
+ +
+

Choose a action

+ + { + actions.map((action, index) => { + return
+ { + onClick(action) + }} + > + { + BehaviorTypeToAction[action.type] + } + + + + { + action.value + } + +
+ }) + } +
+
+} \ No newline at end of file diff --git a/packages/app/src/components/TapShare/Dialog/index.less b/packages/app/src/components/TapShare/Dialog/index.less new file mode 100644 index 00000000..1566ea1d --- /dev/null +++ b/packages/app/src/components/TapShare/Dialog/index.less @@ -0,0 +1,73 @@ +.nfc_tag_dialog { + display: flex; + flex-direction: column; + + align-items: center; + justify-content: center; + + width: 100%; + height: 100%; + + gap: 30px; + + .nfc_tag_dialog__header { + display: flex; + flex-direction: column; + + align-items: center; + justify-content: center; + + width: 100%; + + .userCard { + background-color: transparent; + border: 0; + outline: 0; + + .avatar { + width: 50vw; + height: 50vw; + } + } + } + + .nfc_tag_dialog__body { + display: flex; + flex-direction: column; + + align-items: center; + justify-content: center; + + width: 100%; + + gap: 10px; + padding: 20px; + + border-radius: 12px; + + background-color: var(--background-color-accent); + + h2 { + align-self: flex-start; + } + + .nfc_tag_dialog__action { + display: flex; + flex-direction: column; + + align-items: center; + justify-content: center; + + width: 100%; + + color: var(--text-color); + + .nfc_tag_dialog__description { + color: var(--text-color); + opacity: 0.7; + font-size: 0.8rem; + padding: 5px; + } + } + } +} \ No newline at end of file