mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
added nfc endpoint handler
This commit is contained in:
parent
972bd9802b
commit
91645d0893
@ -48,5 +48,10 @@ export default [
|
||||
path: "/landing/*",
|
||||
useLayout: "blank",
|
||||
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