@@ -10,6 +10,7 @@ import { UserService } from "@/services/UserService";
10
10
import { CompanyService } from "@/services/CompanyService" ;
11
11
import { convertToAppRole , isCompany } from "@/utils/utils" ;
12
12
import Link from "next/link" ;
13
+ import { ScanQrCode } from "lucide-react" ;
13
14
14
15
export default async function QR ( ) {
15
16
const session = await getServerSession ( authOptions ) ;
@@ -25,8 +26,8 @@ export default async function QR() {
25
26
let company : Company | null = null ;
26
27
if ( isCompany ( user . role ) ) {
27
28
// assumes that cannon api only provides the company associated with the current edition
28
- if ( user . company ) {
29
- company = await CompanyService . getCompany ( user . company . id ) ;
29
+ if ( user . company ?. length ) {
30
+ company = await CompanyService . getCompany ( user . company [ 0 ] . company ) ;
30
31
} else {
31
32
await demoteMe ( session ! . cannonToken ) ;
32
33
}
@@ -49,13 +50,15 @@ export default async function QR() {
49
50
50
51
return (
51
52
< div className = "container m-auto h-full" >
52
- < div className = "flex flex-col justify-center items-center text-center p-4 gap-y-4" >
53
+ < div className = "h-full flex flex-col justify-center items-center text-center p-4 gap-y-4" >
53
54
< div className = "flex flex-col justify-center items-center" >
54
- < Image className = "w-48" src = { hackyPeeking } alt = "Hacky Peaking" />
55
+ { ! isCompany ( user . role ) && (
56
+ < Image className = "w-48" src = { hackyPeeking } alt = "Hacky Peaking" />
57
+ ) }
55
58
< QRCode
56
59
className = "w-72 h-auto p-4 border-[14px] bg-white rounded-lg"
57
60
style = { { borderColor } }
58
- value = { `sinfo:// ${ btoa ( JSON . stringify ( { kind : "user" , user : { id : user . id , name : user . name , img : user . img , role : user . role } } ) ) } ` }
61
+ value = { userQRCode }
59
62
/>
60
63
</ div >
61
64
< div >
@@ -64,17 +67,25 @@ export default async function QR() {
64
67
{ convertToAppRole ( user . role ) }
65
68
</ p >
66
69
</ div >
67
- { user . company && (
68
- < Link href = { `/companies/${ user . company . id } ` } >
70
+ { company && (
71
+ < Link href = { `/companies/${ company . id } ` } >
69
72
< Image
70
73
className = "object-contain"
71
74
width = { 100 }
72
75
height = { 100 }
73
- src = { user . company . img }
74
- alt = { `${ user . company . name } logo` }
76
+ src = { company . img }
77
+ alt = { `${ company . name } logo` }
75
78
/>
76
79
</ Link >
77
80
) }
81
+ < Link
82
+ href = "/qr/scan"
83
+ className = "button button-primary text-lg w-full"
84
+ style = { { backgroundColor : borderColor } }
85
+ >
86
+ < ScanQrCode size = { 24 } />
87
+ Scan
88
+ </ Link >
78
89
</ div >
79
90
</ div >
80
91
) ;
0 commit comments