diff --git a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx
index 735490db2..5f972229d 100644
--- a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx
+++ b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx
@@ -21,7 +21,9 @@ import styles from "./overviewTable.module.css"
import {
ComparisonLevel,
+ overviewTableActionsEnum,
OverviewTableProps,
+ OverviewTableReducerAction,
} from "@/types/components/loyalty/blocks"
import { User } from "@/types/user"
@@ -54,15 +56,7 @@ const titleTranslations = {
],
}
-enum actions {
- SET_SELECTED_LEVEL_A_MOBILE = "SET_SELECTED_LEVEL_A_MOBILE",
- SET_SELECTED_LEVEL_B_MOBILE = "SET_SELECTED_LEVEL_B_MOBILE",
- SET_SELECTED_LEVEL_A_DESKTOP = "SET_SELECTED_LEVEL_A_DESKTOP",
- SET_SELECTED_LEVEL_B_DESKTOP = "SET_SELECTED_LEVEL_B_DESKTOP",
- SET_SELECTED_LEVEL_C_DESKTOP = "SET_SELECTED_LEVEL_C_DESKTOP",
-}
-
-function getLevelByTier(tier: number) {
+function getLevelByTier(tier: membershipLevels) {
return levelsData.levels.find(
(level) => level.tier === tier
) as ComparisonLevel
@@ -109,29 +103,29 @@ function getInitialState(user?: User) {
}
}
-function reducer(state: any, action: any) {
+function reducer(state: any, action: OverviewTableReducerAction) {
switch (action.type) {
- case actions.SET_SELECTED_LEVEL_A_MOBILE:
+ case overviewTableActionsEnum.SET_SELECTED_LEVEL_A_MOBILE:
return {
...state,
selectedLevelAMobile: action.payload,
}
- case actions.SET_SELECTED_LEVEL_B_MOBILE:
+ case overviewTableActionsEnum.SET_SELECTED_LEVEL_B_MOBILE:
return {
...state,
selectedLevelBMobile: action.payload,
}
- case actions.SET_SELECTED_LEVEL_A_DESKTOP:
+ case overviewTableActionsEnum.SET_SELECTED_LEVEL_A_DESKTOP:
return {
...state,
selectedLevelADesktop: action.payload,
}
- case actions.SET_SELECTED_LEVEL_B_DESKTOP:
+ case overviewTableActionsEnum.SET_SELECTED_LEVEL_B_DESKTOP:
return {
...state,
selectedLevelBDesktop: action.payload,
}
- case actions.SET_SELECTED_LEVEL_C_DESKTOP:
+ case overviewTableActionsEnum.SET_SELECTED_LEVEL_C_DESKTOP:
return {
...state,
selectedLevelCDesktop: action.payload,
@@ -146,10 +140,13 @@ export default function OverviewTable({ user }: OverviewTableProps) {
const [selectionState, dispatch] = useReducer(reducer, user, getInitialState)
- function handleSelectChange(actionType: string) {
+ function handleSelectChange(actionType: overviewTableActionsEnum) {
return (key: Key) => {
if (typeof key === "number") {
- dispatch({ payload: getLevelByTier(key), type: actionType })
+ dispatch({
+ payload: getLevelByTier(key),
+ type: actionType,
+ })
}
}
}
@@ -179,7 +176,9 @@ export default function OverviewTable({ user }: OverviewTableProps) {
label={intl.formatMessage({ id: "Level" })}
items={levelOptions}
value={selectionState.selectedLevelAMobile.tier}
- onSelect={handleSelectChange(actions.SET_SELECTED_LEVEL_A_MOBILE)}
+ onSelect={handleSelectChange(
+ overviewTableActionsEnum.SET_SELECTED_LEVEL_A_MOBILE
+ )}
/>
{displayHeader ? (
diff --git a/components/Loyalty/Blocks/index.tsx b/components/Loyalty/Blocks/index.tsx
index ea1a53870..a47970ad8 100644
--- a/components/Loyalty/Blocks/index.tsx
+++ b/components/Loyalty/Blocks/index.tsx
@@ -1,5 +1,3 @@
-import { serverClient } from "@/lib/trpc/server"
-
import JsonToHtml from "@/components/JsonToHtml"
import DynamicContentBlock from "@/components/Loyalty/Blocks/DynamicContent"
import Shortcuts from "@/components/MyPages/Blocks/Shortcuts"
@@ -10,8 +8,6 @@ import type { BlocksProps } from "@/types/components/loyalty/blocks"
import { LoyaltyBlocksTypenameEnum } from "@/types/components/loyalty/enums"
export async function Blocks({ blocks }: BlocksProps) {
- const user = await serverClient().user.get()
- console.log({ user })
return blocks.map((block) => {
switch (block.__typename) {
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent:
@@ -24,12 +20,7 @@ export async function Blocks({ blocks }: BlocksProps) {
)
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksDynamicContent:
- return (
-
- )
+ return
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
return (