fix: wrong newbie role
This commit is contained in:
parent
522b2150f2
commit
b6e1f45336
|
|
@ -7,33 +7,41 @@ export function useUserRole(subdomain?: string) {
|
|||
const site = useGetSite(subdomain)
|
||||
|
||||
const userSite = useAccountSites()
|
||||
const [ssrReady, address] = useAccountState(({ ssrReady, computed }) => [
|
||||
const [ssrReady, account] = useAccountState(({ ssrReady, computed }) => [
|
||||
ssrReady,
|
||||
computed.account?.address,
|
||||
computed.account,
|
||||
])
|
||||
|
||||
const isOperator = useIsOperators({
|
||||
characterId: +(site.data?.metadata?.proof || 0),
|
||||
operator: address,
|
||||
operator: account?.address,
|
||||
})
|
||||
|
||||
let role = null
|
||||
if (subdomain) {
|
||||
if (address) {
|
||||
if (userSite.data?.find((site) => site.username === subdomain)) {
|
||||
role = "owner"
|
||||
} else if (isOperator.data) {
|
||||
role = "operator"
|
||||
}
|
||||
|
||||
return {
|
||||
isSuccess: site.isSuccess && userSite.isSuccess && isOperator.isSuccess,
|
||||
data: role,
|
||||
}
|
||||
} else {
|
||||
if (account?.type === "email") {
|
||||
return {
|
||||
isSuccess: ssrReady,
|
||||
data: null,
|
||||
data: account.character?.handle === subdomain ? "owner" : null,
|
||||
}
|
||||
} else {
|
||||
if (account?.address) {
|
||||
if (userSite.data?.find((site) => site.username === subdomain)) {
|
||||
role = "owner"
|
||||
} else if (isOperator.data) {
|
||||
role = "operator"
|
||||
}
|
||||
|
||||
return {
|
||||
isSuccess:
|
||||
site.isSuccess && userSite.isSuccess && isOperator.isSuccess,
|
||||
data: role,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
isSuccess: ssrReady,
|
||||
data: null,
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue