mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
added nfc endpoint handler
This commit is contained in:
parent
e71f5baadf
commit
47bd95245d
@ -48,5 +48,10 @@ export default [
|
|||||||
path: "/landing/*",
|
path: "/landing/*",
|
||||||
useLayout: "blank",
|
useLayout: "blank",
|
||||||
public: true
|
public: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/nfc/*",
|
||||||
|
useLayout: "blank",
|
||||||
|
public: true
|
||||||
}
|
}
|
||||||
]
|
]
|
44
packages/app/src/pages/nfc/[tag_id].jsx
Normal file
44
packages/app/src/pages/nfc/[tag_id].jsx
Normal 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>
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user