added nfc endpoint handler

This commit is contained in:
SrGooglo 2023-06-19 19:21:40 +00:00
parent e71f5baadf
commit 47bd95245d
2 changed files with 49 additions and 0 deletions

View File

@ -48,5 +48,10 @@ export default [
path: "/landing/*", path: "/landing/*",
useLayout: "blank", useLayout: "blank",
public: true public: true
},
{
path: "/nfc/*",
useLayout: "blank",
public: true
} }
] ]

View File

@ -0,0 +1,44 @@
import React from "react"
import NFCModel from "comty.js/models/nfc"
import { Icons } from "components/Icons"
export default (props) => {
const { tag_id } = props.params
const execution = async () => {
const result = await NFCModel.getTagById(tag_id)
.catch((err) => {
console.log(err)
app.message.error("NFC Tag not found")
return false
})
if (!result) {
return false
}
console.log(result)
switch (result.behavior.type) {
case "url": {
return window.location.href = result.behavior.value
}
case "profile": {
return app.navigation.goToAccount(result.behavior.value)
}
}
}
React.useEffect(() => {
execution()
}, [])
return <div className="nfc_execution">
<Icons.LoadingOutlined
style={{
fontSize: 64
}}
spin
/>
</div>
}