-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change useApi hook to include guild id
- Loading branch information
1 parent
8917195
commit 70039d3
Showing
9 changed files
with
41 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import { useApi } from './use-api.tsx'; | ||
import { useGuildApi } from './use-api.tsx'; | ||
import { useEffect, useState } from 'react'; | ||
import { useGuildId } from '../state/use-guild-id.tsx'; | ||
import { APIGuildChannel, ChannelType } from '../../discord-api.ts'; | ||
|
||
export type Channel = APIGuildChannel<ChannelType>; | ||
export const useGetChannels = () => { | ||
const api = useApi(); | ||
const guildId = useGuildId(); | ||
const api = useGuildApi(); | ||
const [channels, setChannels] = useState<Channel[]>(); | ||
useEffect(() => { | ||
if (!guildId) return; | ||
api | ||
.get(`/guild/${guildId}/moderation/channel`) | ||
.get(`/moderation/channel`) | ||
.json<Channel[]>() | ||
.then((channels) => setChannels(channels)); | ||
}, [guildId, api]); | ||
}, [api]); | ||
|
||
return channels; | ||
}; |
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,21 +1,18 @@ | ||
import { useApi } from './use-api.tsx'; | ||
import { useGuildId } from '../state/use-guild-id.tsx'; | ||
import { useApi, useGuildApi } from './use-api.tsx'; | ||
import { useEffect, useState } from 'react'; | ||
import { APIRole } from '../../discord-api.ts'; | ||
|
||
export type Role = APIRole; | ||
|
||
export const useGetRoles = () => { | ||
const api = useApi(); | ||
const guildId = useGuildId(); | ||
const api = useGuildApi(); | ||
const [roles, setRoles] = useState<APIRole[]>(); | ||
useEffect(() => { | ||
if (!guildId) return; | ||
api | ||
.get(`/guild/${guildId}/moderation/role/`) | ||
.get(`/moderation/role/`) | ||
.json<Role[]>() | ||
.then((roles) => setRoles(roles)); | ||
}, [guildId, api]); | ||
}, [api]); | ||
|
||
return roles; | ||
}; |
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,18 +1,15 @@ | ||
import { useApi } from '../../../hooks/api/use-api.tsx'; | ||
import { useGuildApi } from '../../../hooks/api/use-api.tsx'; | ||
import { Settings } from '../domain/settings.tsx'; | ||
import { useEffect, useState } from 'react'; | ||
import { useGuildId } from '../../../hooks/state/use-guild-id.tsx'; | ||
|
||
export const useGetSettings = () => { | ||
const api = useApi(); | ||
const guildId = useGuildId(); | ||
const api = useGuildApi(); | ||
const [settings, setSettings] = useState<Settings>(); | ||
useEffect(() => { | ||
if (!guildId) return; | ||
api | ||
.get(`/guild/${guildId}/settings`) | ||
.get(`/settings`) | ||
.json<Settings>() | ||
.then((settings) => setSettings(settings)); | ||
}, [api, guildId]); | ||
}, [api]); | ||
return settings; | ||
}; |
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,10 +1,7 @@ | ||
import { useApi } from '../../../hooks/api/use-api.tsx'; | ||
import { useGuildId } from '../../../hooks/state/use-guild-id.tsx'; | ||
import { useGuildApi } from '../../../hooks/api/use-api.tsx'; | ||
import { Settings } from '../domain/settings.tsx'; | ||
|
||
export const usePutSettings = () => { | ||
const api = useApi(); | ||
const guildId = useGuildId(); | ||
return (settings: Settings) => | ||
api.put(settings, `/guild/${guildId}/settings`).text(); | ||
const api = useGuildApi(); | ||
return (settings: Settings) => api.put(settings, `/settings`).text(); | ||
}; |