Merged in fix/LOY-180-hide-filter-modal (pull request #1568)
fix(LOY-180): remove use of FilterRewardsModal * fix(LOY-180): remove use of FilterRewardsModal Approved-by: Christian Andolf
This commit is contained in:
@@ -11,18 +11,14 @@ import Pagination from "@/components/MyPages/Pagination"
|
||||
import ExpirationDate from "@/components/Rewards/ExpirationDate"
|
||||
import Grids from "@/components/TempDesignSystem/Grids"
|
||||
import Title from "@/components/TempDesignSystem/Text/Title"
|
||||
import { useFilteredRewards } from "@/hooks/rewards/useFilteredRewards"
|
||||
import useLang from "@/hooks/useLang"
|
||||
import { getEarliestExpirationDate } from "@/utils/rewards"
|
||||
|
||||
import Redeem from "../Redeem"
|
||||
import FilterRewardsModal from "./FilterRewardsModal"
|
||||
|
||||
import styles from "./current.module.css"
|
||||
|
||||
import type { CurrentRewardsClientProps } from "@/types/components/myPages/myPage/accountPage"
|
||||
import type { RewardCategory } from "@/types/components/myPages/rewards"
|
||||
import type { MembershipLevelEnum } from "@/constants/membershipLevels"
|
||||
import type {
|
||||
Reward,
|
||||
RewardWithRedeem,
|
||||
@@ -36,12 +32,6 @@ export default function ClientCurrentRewards({
|
||||
const lang = useLang()
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const [currentPage, setCurrentPage] = useState(1)
|
||||
const [selectedCategories, setSelectedCategories] = useState<
|
||||
RewardCategory[]
|
||||
>([])
|
||||
const [selectedLevels, setSelectedLevels] = useState<MembershipLevelEnum[]>(
|
||||
[]
|
||||
)
|
||||
|
||||
const { data } = trpc.contentstack.rewards.current.useQuery<{
|
||||
rewards: (Reward | RewardWithRedeem)[]
|
||||
@@ -54,36 +44,16 @@ export default function ClientCurrentRewards({
|
||||
}
|
||||
)
|
||||
|
||||
const {
|
||||
filteredRewards,
|
||||
total,
|
||||
availableTierLevels,
|
||||
availableCategories,
|
||||
hasFilterableOptions,
|
||||
} = useFilteredRewards(
|
||||
data?.rewards ?? [],
|
||||
selectedCategories,
|
||||
selectedLevels
|
||||
)
|
||||
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
|
||||
function handleCategoriesChange(categories: RewardCategory[]) {
|
||||
setSelectedCategories(categories)
|
||||
setCurrentPage(1)
|
||||
}
|
||||
|
||||
function handleLevelsChange(levels: MembershipLevelEnum[]) {
|
||||
setSelectedLevels(levels)
|
||||
setCurrentPage(1)
|
||||
}
|
||||
const rewards = data.rewards
|
||||
|
||||
const totalPages = Math.ceil(rewards.length / REWARDS_PER_PAGE)
|
||||
const startIndex = (currentPage - 1) * REWARDS_PER_PAGE
|
||||
const endIndex = startIndex + REWARDS_PER_PAGE
|
||||
const paginatedRewards = filteredRewards.slice(startIndex, endIndex)
|
||||
const totalPages = Math.ceil(total / REWARDS_PER_PAGE)
|
||||
const paginatedRewards = rewards.slice(startIndex, endIndex)
|
||||
|
||||
function handlePageChange(page: number) {
|
||||
requestAnimationFrame(() => {
|
||||
@@ -98,16 +68,6 @@ export default function ClientCurrentRewards({
|
||||
|
||||
return (
|
||||
<div ref={containerRef} className={styles.container}>
|
||||
{showRedeem && hasFilterableOptions ? (
|
||||
<FilterRewardsModal
|
||||
selectedCategories={selectedCategories}
|
||||
selectedLevels={selectedLevels}
|
||||
availableCategories={availableCategories}
|
||||
availableTierLevels={availableTierLevels}
|
||||
onCategoriesChange={handleCategoriesChange}
|
||||
onLevelsChange={handleLevelsChange}
|
||||
/>
|
||||
) : null}
|
||||
<Grids.Stackable>
|
||||
{paginatedRewards.map((reward, idx) => {
|
||||
const earliestExpirationDate =
|
||||
|
||||
Reference in New Issue
Block a user