diff --git a/src/client/api/model/website.ts b/src/client/api/model/website.ts index a498e48..fa11afa 100644 --- a/src/client/api/model/website.ts +++ b/src/client/api/model/website.ts @@ -7,18 +7,6 @@ import { AppRouterOutput } from '../trpc'; export type WebsiteInfo = NonNullable; -export async function getWorkspaceWebsites( - workspaceId: string -): Promise { - const { data } = await request.get('/api/workspace/websites', { - params: { - workspaceId, - }, - }); - - return data.websites; -} - export async function deleteWorkspaceWebsite( workspaceId: string, websiteId: string @@ -28,33 +16,10 @@ export async function deleteWorkspaceWebsite( queryClient.resetQueries(['websites', workspaceId]); } -export function useWorspaceWebsites(workspaceId: string) { - const { data: websites = [], isLoading } = useQuery( - ['websites', workspaceId], - () => { - return getWorkspaceWebsites(workspaceId); - } - ); - - return { websites, isLoading }; -} - export function refreshWorkspaceWebsites(workspaceId: string) { queryClient.refetchQueries(['websites', workspaceId]); } -export async function addWorkspaceWebsite( - workspaceId: string, - name: string, - domain: string -) { - await request.post('/api/workspace/website', { - workspaceId, - name, - domain, - }); -} - export async function getWorkspaceWebsitePageview( workspaceId: string, websiteId: string, diff --git a/src/server/router/workspace.ts b/src/server/router/workspace.ts index 10373c9..47d4a72 100644 --- a/src/server/router/workspace.ts +++ b/src/server/router/workspace.ts @@ -17,48 +17,6 @@ import { ROLES } from '../../shared'; export const workspaceRouter = Router(); -workspaceRouter.get( - '/websites', - validate( - query('workspaceId').isString().withMessage('workspaceId should be string') - ), - auth(), - workspacePermission(), - async (req, res) => { - const workspaceId = req.query.workspaceId as string; - - const websites = await getWorkspaceWebsites(workspaceId); - - res.json({ websites }); - } -); - -workspaceRouter.post( - '/website', - validate( - body('workspaceId').isString(), - body('name') - .isString() - .withMessage('name should be string') - .isLength({ max: 100 }) - .withMessage('length should be under 100'), - body('domain') - .isURL() - .withMessage('domain should be URL') - .isLength({ max: 500 }) - .withMessage('length should be under 500') - ), - auth(), - workspacePermission(), - async (req, res) => { - const { workspaceId, name, domain } = req.body; - - const website = await addWorkspaceWebsite(workspaceId, name, domain); - - res.json({ website }); - } -); - workspaceRouter.delete( '/:workspaceId/website/:websiteId', validate(param('workspaceId').isString(), param('websiteId').isString()),