update admin panel

This commit is contained in:
Emily
2025-02-12 16:49:19 +01:00
parent f5882bff9f
commit af6dff57ed
9 changed files with 524 additions and 32 deletions

View File

@@ -4,13 +4,16 @@ import type { TAdminProject } from '~/server/api/admin/projects';
import { PREMIUM_PLAN, getPlanFromId } from '@data/PREMIUM'
import { useSelectMenuStyle } from '~/composables/ui/useSelectMenuStyle';
const page = ref<number>(0);
const limit = ref<number>(20);
const page = ref<number>(1);
const ordersList = [
{ label: 'created_at -->', id: '{ "created_at": 1 }' },
{ label: 'created_at <--', id: '{ "created_at": -1 }' },
{ label: 'active -->', id: '{ "last_log_at": 1 }' },
{ label: 'active <--', id: '{ "last_log_at": -1 }' },
{ label: 'visits -->', id: '{ "visits": 1 }' },
{ label: 'visits <--', id: '{ "visits": -1 }' },
@@ -39,9 +42,34 @@ const ordersList = [
const order = ref<string>('{ "created_at": -1 }');
const limitList = [
{ label: '10', id: 10 },
{ label: '20', id: 20 },
{ label: '50', id: 50 },
{ label: '100', id: 100 },
]
const { data: projects, pending: pendingProjects } = await useFetch<TAdminProject[]>(
() => `/api/admin/projects?page=${page.value}&limit=${limit.value}&sortQuery=${order.value}`,
const limit = ref<number>(20);
const filterList = [
{ label: 'ALL', id: '{}' },
{ label: 'PREMIUM', id: '{ "premium_type": { "$gt": 0, "$lt": 1000 } }' },
{ label: 'APPSUMO', id: '{ "premium_type": { "$gt": 6000, "$lt": 7000 } }' },
{ label: 'PREMIUM+APPSUMO', id: '{ "premium_type": { "$gt": 0, "$lt": 7000 } }' },
{ label: 'FREE', id: '{ "premium_type": 0' },
]
onMounted(() => {
for (const key in PREMIUM_PLAN) {
filterList.push({ label: key, id: `{"premium_type": ${(PREMIUM_PLAN as any)[key].ID}}` });
}
})
const filter = ref<string>('{}');
const { data: projectsInfo, pending: pendingProjects } = await useFetch<{ count: number, projects: TAdminProject[] }>(
() => `/api/admin/projects?page=${page.value - 1}&limit=${limit.value}&sortQuery=${order.value}&filterQuery=${filter.value}`,
signHeaders()
);
@@ -64,30 +92,28 @@ const { uiMenu } = useSelectMenuStyle();
</USelectMenu>
</div>
<!-- TODO: Move to metrics tab -->
<!-- TODO: Add project details button -->
<!-- TODO: Add project utilities -->
<div class="flex gap-2 items-center">
<div> Projects: </div>
<div> 123 </div>
<div> Premium: </div>
<div> 123 </div>
<div> Active: </div>
<div> 123 </div>
<div> Dead: </div>
<div> 123 </div>
<div>Limit:</div>
<USelectMenu :uiMenu="uiMenu" class="w-[12rem]" placeholder="Limit" :options="limitList"
value-attribute="id" option-attribute="label" v-model="limit">
</USelectMenu>
</div>
<div class="flex gap-2 items-center">
<div> Users: </div>
<div> 123 </div>
<div>Filter:</div>
<USelectMenu :uiMenu="uiMenu" class="w-[12rem]" placeholder="Filter" :options="filterList"
value-attribute="id" option-attribute="label" v-model="filter">
</USelectMenu>
</div>
<div class="flex gap-2 items-center">
<div> Total Visits: </div>
<div> 123 </div>
<div> Total Events: </div>
<div> 123 </div>
<div>Page {{ page }} </div>
<div> {{ Math.min(limit, projectsInfo?.count || 0) }} of {{ projectsInfo?.count || 0
}}</div>
</div>
<div>
<UPagination v-model="page" :page-count="limit" :total="projectsInfo?.count || 0" />
</div>
</div>
@@ -98,7 +124,7 @@ const { uiMenu } = useSelectMenuStyle();
class="cursor-default flex justify-center flex-wrap gap-6 mb-[4rem] mt-4 overflow-auto h-full pt-6 pb-[8rem]">
<AdminOverviewProjectCard v-if="!pendingProjects" :key="project._id.toString()" :project="project"
class="w-[26rem]" v-for="project of projects" />
class="w-[26rem]" v-for="project of projectsInfo?.projects" />
<div v-if="pendingProjects"> Loading...</div>