-
Notifications
You must be signed in to change notification settings - Fork 196
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
164 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createOidcSSOConn, createSamlSSOConn } from '@/lib/stytch/api'; | ||
import { useCallback, useState } from 'react'; | ||
|
||
export const useCreateOidcSso = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState<string | null>(null); | ||
const [data, setData] = useState(null); | ||
|
||
const mutate = useCallback(async (display_name: string) => { | ||
setIsLoading(true); | ||
setError(null); | ||
try { | ||
const response = await createOidcSSOConn(display_name) | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const data = await response.json(); | ||
setData(data); | ||
} catch (error) { | ||
setError(error instanceof Error ? error.message : String(error)); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}, []); | ||
|
||
return { mutate, isLoading, error, data }; | ||
}; |
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,29 @@ | ||
import { createSamlSSOConn } from '@/lib/stytch/api'; | ||
import { useCallback, useState } from 'react'; | ||
|
||
export const useCreateSamlSso = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState<string | null>(null); | ||
const [data, setData] = useState(null); | ||
|
||
const mutate = useCallback(async (display_name: string) => { | ||
setIsLoading(true); | ||
setError(null); | ||
try { | ||
const response = await createSamlSSOConn(display_name) | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const data = await response.json(); | ||
setData(data); | ||
} catch (error) { | ||
setError(error instanceof Error ? error.message : String(error)); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}, []); | ||
|
||
return { mutate, isLoading, error, data }; | ||
}; |
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,29 @@ | ||
import { deleteMember, invite } from '@/lib/stytch/api'; | ||
import { useCallback, useState } from 'react'; | ||
|
||
export const useDeleteMember = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState<string | null>(null); | ||
const [data, setData] = useState(null); | ||
|
||
const mutate = useCallback(async (member_id: string) => { | ||
setIsLoading(true); | ||
setError(null); | ||
try { | ||
const response = await deleteMember(member_id) | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const data = await response.json(); | ||
setData(data); | ||
} catch (error) { | ||
setError(error instanceof Error ? error.message : String(error)); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}, []); | ||
|
||
return { mutate, isLoading, error, data }; | ||
}; |
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,29 @@ | ||
import { invite } from '@/lib/stytch/api'; | ||
import { useCallback, useState } from 'react'; | ||
|
||
export const useInvite = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [error, setError] = useState<string | null>(null); | ||
const [data, setData] = useState(null); | ||
|
||
const mutate = useCallback(async (email: string) => { | ||
setIsLoading(true); | ||
setError(null); | ||
try { | ||
const response = await invite(email) | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const data = await response.json(); | ||
setData(data); | ||
} catch (error) { | ||
setError(error instanceof Error ? error.message : String(error)); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}, []); | ||
|
||
return { mutate, isLoading, error, data }; | ||
}; |
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