style: remove unused code

This commit is contained in:
moonrailgun 2024-01-04 00:34:33 +08:00
parent 81e7f8651a
commit 4f5e79157a
2 changed files with 0 additions and 77 deletions

View File

@ -7,18 +7,6 @@ import { AppRouterOutput } from '../trpc';
export type WebsiteInfo = NonNullable<AppRouterOutput['website']['info']>; export type WebsiteInfo = NonNullable<AppRouterOutput['website']['info']>;
export async function getWorkspaceWebsites(
workspaceId: string
): Promise<WebsiteInfo[]> {
const { data } = await request.get('/api/workspace/websites', {
params: {
workspaceId,
},
});
return data.websites;
}
export async function deleteWorkspaceWebsite( export async function deleteWorkspaceWebsite(
workspaceId: string, workspaceId: string,
websiteId: string websiteId: string
@ -28,33 +16,10 @@ export async function deleteWorkspaceWebsite(
queryClient.resetQueries(['websites', workspaceId]); 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) { export function refreshWorkspaceWebsites(workspaceId: string) {
queryClient.refetchQueries(['websites', workspaceId]); 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( export async function getWorkspaceWebsitePageview(
workspaceId: string, workspaceId: string,
websiteId: string, websiteId: string,

View File

@ -17,48 +17,6 @@ import { ROLES } from '../../shared';
export const workspaceRouter = Router(); 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( workspaceRouter.delete(
'/:workspaceId/website/:websiteId', '/:workspaceId/website/:websiteId',
validate(param('workspaceId').isString(), param('websiteId').isString()), validate(param('workspaceId').isString(), param('websiteId').isString()),