Initial commit: SmoothSchedule multi-tenant scheduling platform
This commit includes: - Django backend with multi-tenancy (django-tenants) - React + TypeScript frontend with Vite - Platform administration API with role-based access control - Authentication system with token-based auth - Quick login dev tools for testing different user roles - CORS and CSRF configuration for local development - Docker development environment setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
83
legacy_reference/frontend/src/hooks/useCustomDomains.ts
Normal file
83
legacy_reference/frontend/src/hooks/useCustomDomains.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* React Query hooks for custom domain management
|
||||
*/
|
||||
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
getCustomDomains,
|
||||
addCustomDomain,
|
||||
deleteCustomDomain,
|
||||
verifyCustomDomain,
|
||||
setPrimaryDomain,
|
||||
} from '../api/customDomains';
|
||||
import { CustomDomain } from '../types';
|
||||
|
||||
/**
|
||||
* Hook to fetch all custom domains for the current business
|
||||
*/
|
||||
export const useCustomDomains = () => {
|
||||
return useQuery<CustomDomain[], Error>({
|
||||
queryKey: ['customDomains'],
|
||||
queryFn: getCustomDomains,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook to add a new custom domain
|
||||
*/
|
||||
export const useAddCustomDomain = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<CustomDomain, Error, string>({
|
||||
mutationFn: addCustomDomain,
|
||||
onSuccess: () => {
|
||||
// Invalidate and refetch custom domains
|
||||
queryClient.invalidateQueries({ queryKey: ['customDomains'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook to delete a custom domain
|
||||
*/
|
||||
export const useDeleteCustomDomain = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<void, Error, number>({
|
||||
mutationFn: deleteCustomDomain,
|
||||
onSuccess: () => {
|
||||
// Invalidate and refetch custom domains
|
||||
queryClient.invalidateQueries({ queryKey: ['customDomains'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook to verify a custom domain
|
||||
*/
|
||||
export const useVerifyCustomDomain = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{ verified: boolean; message: string }, Error, number>({
|
||||
mutationFn: verifyCustomDomain,
|
||||
onSuccess: () => {
|
||||
// Invalidate and refetch custom domains
|
||||
queryClient.invalidateQueries({ queryKey: ['customDomains'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook to set a custom domain as primary
|
||||
*/
|
||||
export const useSetPrimaryDomain = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<CustomDomain, Error, number>({
|
||||
mutationFn: setPrimaryDomain,
|
||||
onSuccess: () => {
|
||||
// Invalidate and refetch custom domains
|
||||
queryClient.invalidateQueries({ queryKey: ['customDomains'] });
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user