4b16860d07
* fix: Correctly prefill username in case of non-org email invite in an org * Update test --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
23 lines
565 B
TypeScript
23 lines
565 B
TypeScript
type ResponseUsernameApi = {
|
|
available: boolean;
|
|
premium: boolean;
|
|
message?: string;
|
|
suggestion?: string;
|
|
};
|
|
|
|
export async function fetchUsername(username: string, orgSlug: string | null) {
|
|
const response = await fetch("/api/username", {
|
|
credentials: "include",
|
|
method: "POST",
|
|
body: JSON.stringify({
|
|
username: username.trim(),
|
|
orgSlug: orgSlug ?? undefined,
|
|
}),
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
});
|
|
const data = (await response.json()) as ResponseUsernameApi;
|
|
return { response, data };
|
|
}
|