log page views
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { HomeLayoutPageHeader } from '@/app/home/(user)/_components/home-page-header';
|
||||
import { loadCategory } from '@/app/home/(user)/_lib/server/load-category';
|
||||
|
||||
import { pathsConfig } from '@kit/shared/config';
|
||||
import { AppBreadcrumbs } from '@kit/ui/makerkit/app-breadcrumbs';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import BookingContainer from '~/home/(user)/_components/booking/booking-container';
|
||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
|
||||
import BookingContainer from '~/home/(user)/_components/booking/booking-container';
|
||||
import { PageViewAction, createPageViewLog } from '~/lib/services/audit/pageView.service';
|
||||
import { loadCurrentUserAccount } from '~/home/(user)/_lib/server/load-user-account';
|
||||
|
||||
export const generateMetadata = async () => {
|
||||
const i18n = await createI18nServerInstance();
|
||||
@@ -25,11 +29,24 @@ async function BookingHandlePage({
|
||||
}) {
|
||||
const { handle } = await params;
|
||||
const { category } = await loadCategory({ handle });
|
||||
const { account } = await loadCurrentUserAccount();
|
||||
|
||||
if (!category) {
|
||||
return <div>Category not found</div>;
|
||||
}
|
||||
|
||||
if (!account) {
|
||||
return redirect(pathsConfig.auth.signIn);
|
||||
}
|
||||
|
||||
await createPageViewLog({
|
||||
accountId: account.id,
|
||||
action: PageViewAction.VIEW_TTO_SERVICE_BOOKING,
|
||||
extraData: {
|
||||
handle,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppBreadcrumbs
|
||||
|
||||
@@ -6,6 +6,7 @@ export enum PageViewAction {
|
||||
REGISTRATION_SUCCESS = 'REGISTRATION_SUCCESS',
|
||||
VIEW_ORDER_ANALYSIS = 'VIEW_ORDER_ANALYSIS',
|
||||
VIEW_TEAM_ACCOUNT_DASHBOARD = 'VIEW_TEAM_ACCOUNT_DASHBOARD',
|
||||
VIEW_TTO_SERVICE_BOOKING = 'VIEW_TTO_SERVICE_BOOKING',
|
||||
}
|
||||
|
||||
export const createPageViewLog = async ({
|
||||
@@ -37,6 +38,7 @@ export const createPageViewLog = async ({
|
||||
account_id: accountId,
|
||||
action,
|
||||
changed_by: user.id,
|
||||
extra_data: extraData
|
||||
})
|
||||
.throwOnError();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user