-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
backend/packages/backend/src/features/society/getSocietyMember.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { | ||
getSocietyMember: _getSocietyMember, | ||
} = require("../../services/node.service/getSocietyMember"); | ||
|
||
async function getSocietyMember(ctx) { | ||
const { network, address } = ctx.params; | ||
ctx.body = await _getSocietyMember(network, address); | ||
} | ||
|
||
module.exports = { | ||
getSocietyMember, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Router = require("koa-router"); | ||
const { getSocietyMember } = require("./getSocietyMember"); | ||
|
||
const router = new Router(); | ||
|
||
router.get("/:network/society/members/:address", getSocietyMember); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useIsSocietyMember } from "hooks/useIsSocietyMember"; | ||
import styled from "styled-components"; | ||
|
||
const Hint = styled.div` | ||
margin-top: 4px !important; | ||
color: var(--textFeedbackError); | ||
`; | ||
|
||
export default function SocietyMemberHit() { | ||
const isSocietyMember = useIsSocietyMember(); | ||
if (isSocietyMember) { | ||
return null; | ||
} | ||
|
||
return <Hint>You are not the society member</Hint>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function isOnePersonOnVoteOnly(strategies) { | ||
return strategies.length === 1 && strategies[0].type !== "one-person-on-vote"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useEffect, useState } from "react"; | ||
import { useSelector } from "react-redux"; | ||
import nextApi from "services/nextApi"; | ||
import { | ||
loginAddressSelector, | ||
loginNetworkSelector, | ||
} from "store/reducers/accountSlice"; | ||
|
||
export function useIsSocietyMember() { | ||
const network = useSelector(loginNetworkSelector); | ||
const loginAddress = useSelector(loginAddressSelector); | ||
const [isSocietyMember, setIsSocietyMember] = useState(false); | ||
useEffect(() => { | ||
if (!loginAddress || !network) { | ||
return; | ||
} | ||
nextApi | ||
.fetch(`${network.network}/society/members/${loginAddress}`) | ||
.then(({ result }) => { | ||
setIsSocietyMember(result?.data !== null); | ||
}); | ||
}, [network, loginAddress]); | ||
|
||
return isSocietyMember; | ||
} |