 3341074bb2
			
		
	
	
		3341074bb2
		
			
		
	
	
	
	
		
			
			* username update from getting-started when received as query param * Added test for onboarding username update * Now saving username saved in localStorage * remove username field * Removed wordlist * Implement checkoutUsername as api endpoint * Remove unused lib utils not empty Co-authored-by: zomars <zomars@me.com>
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			599 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			599 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import slugify from "@calcom/lib/slugify";
 | |
| 
 | |
| export type ResponseUsernameApi = {
 | |
|   available: boolean;
 | |
|   premium: boolean;
 | |
|   message?: string;
 | |
|   suggestion?: string;
 | |
| };
 | |
| 
 | |
| export async function checkPremiumUsername(_username: string): Promise<ResponseUsernameApi> {
 | |
|   const username = slugify(_username);
 | |
|   const response = await fetch("https://cal.com/api/username", {
 | |
|     credentials: "include",
 | |
|     headers: {
 | |
|       "Content-Type": "application/json",
 | |
|     },
 | |
|     body: JSON.stringify({ username }),
 | |
|     method: "POST",
 | |
|     mode: "cors",
 | |
|   });
 | |
| 
 | |
|   const json = await response.json();
 | |
|   return json;
 | |
| }
 |