Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { EntityWithDetails, getEntityBySlug } from "~/utils/db/entities/entities.db.server";
|
||||
import { promiseHash } from "~/utils/promises/promiseHash";
|
||||
import { getTenantIdOrNull } from "~/utils/services/.server/urlService";
|
||||
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
|
||||
import { Params } from "react-router";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
|
||||
type RowsLoaderData = {
|
||||
t: TFunction;
|
||||
userId: string;
|
||||
tenantId: string | null;
|
||||
entity: EntityWithDetails;
|
||||
};
|
||||
async function getLoader({ request, params }: { request: Request; params: Params }): Promise<RowsLoaderData> {
|
||||
await requireAuth({ request, params });
|
||||
const tenantId = await getTenantIdOrNull({ request, params });
|
||||
const unparsedData = await promiseHash({
|
||||
i18n: getTranslations(request),
|
||||
userInfo: getUserInfo(request),
|
||||
tenantId: getTenantIdOrNull({ request, params }),
|
||||
entity: getEntityBySlug({ tenantId, slug: params.entity!, activeOnly: true }),
|
||||
});
|
||||
|
||||
const data: RowsLoaderData = {
|
||||
t: unparsedData.i18n.t,
|
||||
userId: unparsedData.userInfo.userId,
|
||||
tenantId: unparsedData.tenantId,
|
||||
entity: unparsedData.entity,
|
||||
};
|
||||
return data;
|
||||
}
|
||||
|
||||
type RowsActionData = RowsLoaderData & {
|
||||
form: FormData;
|
||||
};
|
||||
async function getAction({ request, params }: { request: Request; params: Params }): Promise<RowsActionData> {
|
||||
const loader = await getLoader({ request, params });
|
||||
await validateCSRFToken(request);
|
||||
const form = await request.formData();
|
||||
|
||||
return {
|
||||
...loader,
|
||||
form,
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
getLoader,
|
||||
getAction,
|
||||
};
|
||||
Reference in new issue
Block a user