-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configurable permissions/roles on guilds
- Loading branch information
1 parent
dd3a967
commit 6068afb
Showing
17 changed files
with
252 additions
and
117 deletions.
There are no files selected for viewing
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
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,28 @@ | ||
import {createContext, PropsWithChildren, useContext, useMemo} from 'react'; | ||
|
||
type GuildPage = { | ||
guildId: string; | ||
isAdmin: boolean; | ||
} | ||
|
||
const GuildPageContext = createContext<GuildPage | undefined>(undefined); | ||
|
||
export function GuildPageProvider(props: PropsWithChildren<GuildPage>): JSX.Element { | ||
const {guildId, isAdmin, children} = props; | ||
|
||
const contextValue = useMemo(() => { | ||
return { | ||
guildId: guildId, | ||
isAdmin: isAdmin, | ||
}; | ||
}, [guildId, isAdmin]); | ||
return <GuildPageContext.Provider value={contextValue}>{children}</GuildPageContext.Provider>; | ||
} | ||
|
||
export function useGuildPage(): GuildPage { | ||
const context = useContext(GuildPageContext); | ||
if (context === undefined) { | ||
throw new Error('useGuild must be used within a GuildProvider'); | ||
} | ||
return context; | ||
} |
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
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
import {Accordion, Box, Stack, Title} from '@mantine/core'; | ||
import {T} from '../../../components/T'; | ||
import {GuildProps} from './Guild'; | ||
import {useGetGuildConfig} from './useGetGuild'; | ||
import {GuildEventTypes} from './GuildEventTypes'; | ||
import {GuildLanguage} from './config/GuildLanguage'; | ||
import {GuildArchive} from './config/GuildArchive'; | ||
import {useGuildPage} from '../../../contexts/guild/GuildPageContext'; | ||
|
||
export function GuildConfig(props: GuildProps): JSX.Element { | ||
const {guildId} = props; | ||
export function GuildConfig(): JSX.Element { | ||
const {guildId} = useGuildPage(); | ||
const guildConfigQuery = useGetGuildConfig(guildId); | ||
const guildConfig = guildConfigQuery.data; | ||
if (guildConfigQuery.isLoading || !guildConfig) return <></>; | ||
|
||
return <> | ||
<Title order={3}>Konfiguration</Title> | ||
<Title order={3}><T k={'configuration'}/></Title> | ||
<Accordion variant={'separated'} mt={8}> | ||
<Accordion.Item value={'integration.discord'}> | ||
<Accordion.Control><T k={'integration.discord'}/></Accordion.Control> | ||
<Accordion.Panel> | ||
<Stack> | ||
<Box> | ||
<Title order={4}><T k={'language'}/></Title> | ||
<GuildLanguage guildId={guildId} {...guildConfig}/> | ||
<GuildLanguage {...guildConfig}/> | ||
</Box> | ||
<Box> | ||
<Title order={4}><T k={'integration.discord'}/></Title> | ||
<GuildArchive guildId={guildId} {...guildConfig}/> | ||
<GuildArchive {...guildConfig}/> | ||
</Box> | ||
</Stack> | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
<Accordion.Item value={'types'}> | ||
<Accordion.Control><T k={'event.eventTypes'}/></Accordion.Control> | ||
<Accordion.Panel> | ||
<GuildEventTypes guildId={guildId}/> | ||
<GuildEventTypes/> | ||
</Accordion.Panel> | ||
</Accordion.Item> | ||
</Accordion> | ||
|
||
|
||
<Title order={3} mt={'lg'}>Spieler</Title> | ||
<Title order={3} mt={'lg'}><T k={'members'}/></Title> | ||
</>; | ||
} |
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 was deleted.
Oops, something went wrong.
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,14 @@ | ||
import {AnchorLink} from '../../../../components/Text/AnchorLink'; | ||
import {Avatar, Group} from '@mantine/core'; | ||
import {TableCellProps} from './GuildUsers'; | ||
|
||
export function GuildUser(props: TableCellProps): JSX.Element { | ||
const {id, avatarUrl, name} = props.row.original.user; | ||
|
||
return <AnchorLink to={`/profile/${id}`}> | ||
<Group spacing={'sm'}> | ||
<Avatar src={avatarUrl} radius={40}/> | ||
{name} | ||
</Group> | ||
</AnchorLink>; | ||
} |
Oops, something went wrong.