efril #13
@ -0,0 +1,7 @@
|
|||||||
|
import GamesList from '@/views/apps/marketing/games/list'
|
||||||
|
|
||||||
|
const GamePage = () => {
|
||||||
|
return <GamesList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GamePage
|
||||||
@ -161,6 +161,9 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
|||||||
{dictionary['navigation'].wheel_spin}
|
{dictionary['navigation'].wheel_spin}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
|
<SubMenu label={dictionary['navigation'].games}>
|
||||||
|
<MenuItem href={`/${locale}/apps/marketing/games/list`}>{dictionary['navigation'].list}</MenuItem>
|
||||||
|
</SubMenu>
|
||||||
<MenuItem href={`/${locale}/apps/marketing/campaign`}>{dictionary['navigation'].campaign}</MenuItem>
|
<MenuItem href={`/${locale}/apps/marketing/campaign`}>{dictionary['navigation'].campaign}</MenuItem>
|
||||||
<MenuItem href={`/${locale}/apps/marketing/customer-analytics`}>
|
<MenuItem href={`/${locale}/apps/marketing/customer-analytics`}>
|
||||||
{dictionary['navigation'].customer_analytics}
|
{dictionary['navigation'].customer_analytics}
|
||||||
|
|||||||
@ -135,6 +135,7 @@
|
|||||||
"campaign": "Campaign",
|
"campaign": "Campaign",
|
||||||
"customer_analytics": "Customer Analytics",
|
"customer_analytics": "Customer Analytics",
|
||||||
"voucher": "Voucher",
|
"voucher": "Voucher",
|
||||||
"tiers_text": "Tiers"
|
"tiers_text": "Tiers",
|
||||||
|
"games": "Games"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,6 +135,7 @@
|
|||||||
"campaign": "Kampanye",
|
"campaign": "Kampanye",
|
||||||
"customer_analytics": "Analisis Pelanggan",
|
"customer_analytics": "Analisis Pelanggan",
|
||||||
"voucher": "Vocher",
|
"voucher": "Vocher",
|
||||||
"tiers_text": "Tiers"
|
"tiers_text": "Tiers",
|
||||||
|
"games": "Permaninan"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/types/services/game.ts
Normal file
17
src/types/services/game.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
export interface Game {
|
||||||
|
id: string // uuid
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
is_active: boolean
|
||||||
|
metadata: Record<string, any>
|
||||||
|
created_at: string // ISO datetime
|
||||||
|
updated_at: string // ISO datetime
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Games {
|
||||||
|
data: Game[]
|
||||||
|
total_count: number
|
||||||
|
page: number
|
||||||
|
limit: number
|
||||||
|
total_pages: number
|
||||||
|
}
|
||||||
407
src/views/apps/marketing/games/list/AddEditGamesDrawer.tsx
Normal file
407
src/views/apps/marketing/games/list/AddEditGamesDrawer.tsx
Normal file
@ -0,0 +1,407 @@
|
|||||||
|
// React Imports
|
||||||
|
import { useState, useEffect } from 'react'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import Drawer from '@mui/material/Drawer'
|
||||||
|
import IconButton from '@mui/material/IconButton'
|
||||||
|
import MenuItem from '@mui/material/MenuItem'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
import Divider from '@mui/material/Divider'
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
import Box from '@mui/material/Box'
|
||||||
|
import Switch from '@mui/material/Switch'
|
||||||
|
import FormControlLabel from '@mui/material/FormControlLabel'
|
||||||
|
import Chip from '@mui/material/Chip'
|
||||||
|
import InputAdornment from '@mui/material/InputAdornment'
|
||||||
|
import Avatar from '@mui/material/Avatar'
|
||||||
|
import Card from '@mui/material/Card'
|
||||||
|
import CardContent from '@mui/material/CardContent'
|
||||||
|
import FormHelperText from '@mui/material/FormHelperText'
|
||||||
|
|
||||||
|
// Third-party Imports
|
||||||
|
import { useForm, Controller } from 'react-hook-form'
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import CustomTextField from '@core/components/mui/TextField'
|
||||||
|
|
||||||
|
// Types
|
||||||
|
export interface Game {
|
||||||
|
id: string // uuid
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
is_active: boolean
|
||||||
|
metadata: Record<string, any>
|
||||||
|
created_at: string // ISO datetime
|
||||||
|
updated_at: string // ISO datetime
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GameRequest {
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
is_active: boolean
|
||||||
|
metadata: {
|
||||||
|
imageUrl?: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
open: boolean
|
||||||
|
handleClose: () => void
|
||||||
|
data?: Game // Game data for edit (if exists)
|
||||||
|
}
|
||||||
|
|
||||||
|
type FormValidateType = {
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
is_active: boolean
|
||||||
|
imageUrl: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial form data
|
||||||
|
const initialData: FormValidateType = {
|
||||||
|
name: '',
|
||||||
|
type: 'quiz',
|
||||||
|
is_active: true,
|
||||||
|
imageUrl: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mock mutation hooks (replace with actual hooks)
|
||||||
|
const useGameMutation = () => {
|
||||||
|
const createGame = {
|
||||||
|
mutate: (data: GameRequest, options?: { onSuccess?: () => void }) => {
|
||||||
|
console.log('Creating game:', data)
|
||||||
|
setTimeout(() => options?.onSuccess?.(), 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateGame = {
|
||||||
|
mutate: (data: { id: string; payload: GameRequest }, options?: { onSuccess?: () => void }) => {
|
||||||
|
console.log('Updating game:', data)
|
||||||
|
setTimeout(() => options?.onSuccess?.(), 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { createGame, updateGame }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game types
|
||||||
|
const GAME_TYPES = [
|
||||||
|
{ value: 'quiz', label: 'Quiz' },
|
||||||
|
{ value: 'puzzle', label: 'Puzzle' },
|
||||||
|
{ value: 'memory', label: 'Memory Game' },
|
||||||
|
{ value: 'trivia', label: 'Trivia' },
|
||||||
|
{ value: 'word', label: 'Word Game' },
|
||||||
|
{ value: 'math', label: 'Math Game' },
|
||||||
|
{ value: 'arcade', label: 'Arcade' },
|
||||||
|
{ value: 'strategy', label: 'Strategy' }
|
||||||
|
]
|
||||||
|
|
||||||
|
// Game categories
|
||||||
|
const GAME_CATEGORIES = [
|
||||||
|
{ value: 'trivia', label: 'Trivia' },
|
||||||
|
{ value: 'educational', label: 'Educational' },
|
||||||
|
{ value: 'entertainment', label: 'Entertainment' },
|
||||||
|
{ value: 'brain_training', label: 'Brain Training' },
|
||||||
|
{ value: 'casual', label: 'Casual' },
|
||||||
|
{ value: 'competitive', label: 'Competitive' }
|
||||||
|
]
|
||||||
|
|
||||||
|
// Difficulty levels
|
||||||
|
const DIFFICULTY_LEVELS = [
|
||||||
|
{ value: 'easy', label: 'Easy' },
|
||||||
|
{ value: 'medium', label: 'Medium' },
|
||||||
|
{ value: 'hard', label: 'Hard' },
|
||||||
|
{ value: 'expert', label: 'Expert' }
|
||||||
|
]
|
||||||
|
|
||||||
|
const AddEditGamesDrawer = (props: Props) => {
|
||||||
|
// Props
|
||||||
|
const { open, handleClose, data } = props
|
||||||
|
|
||||||
|
// States
|
||||||
|
const [showMore, setShowMore] = useState(false)
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||||
|
const [imagePreview, setImagePreview] = useState<string | null>(null)
|
||||||
|
|
||||||
|
const { createGame, updateGame } = useGameMutation()
|
||||||
|
|
||||||
|
// Determine if this is edit mode
|
||||||
|
const isEditMode = Boolean(data?.id)
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
const {
|
||||||
|
control,
|
||||||
|
reset: resetForm,
|
||||||
|
handleSubmit,
|
||||||
|
watch,
|
||||||
|
setValue,
|
||||||
|
formState: { errors }
|
||||||
|
} = useForm<FormValidateType>({
|
||||||
|
defaultValues: initialData
|
||||||
|
})
|
||||||
|
|
||||||
|
const watchedImageUrl = watch('imageUrl')
|
||||||
|
|
||||||
|
// Effect to populate form when editing
|
||||||
|
useEffect(() => {
|
||||||
|
if (isEditMode && data) {
|
||||||
|
// Extract imageUrl from metadata
|
||||||
|
const imageUrl = data.metadata?.imageUrl || ''
|
||||||
|
|
||||||
|
// Populate form with existing data
|
||||||
|
const formData: FormValidateType = {
|
||||||
|
name: data.name || '',
|
||||||
|
type: data.type || 'quiz',
|
||||||
|
is_active: data.is_active ?? true,
|
||||||
|
imageUrl: imageUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
resetForm(formData)
|
||||||
|
setImagePreview(imageUrl || null)
|
||||||
|
} else {
|
||||||
|
// Reset to initial data for add mode
|
||||||
|
resetForm(initialData)
|
||||||
|
setImagePreview(null)
|
||||||
|
}
|
||||||
|
}, [data, isEditMode, resetForm])
|
||||||
|
|
||||||
|
// Handle image URL change
|
||||||
|
useEffect(() => {
|
||||||
|
if (watchedImageUrl) {
|
||||||
|
setImagePreview(watchedImageUrl)
|
||||||
|
} else {
|
||||||
|
setImagePreview(null)
|
||||||
|
}
|
||||||
|
}, [watchedImageUrl])
|
||||||
|
|
||||||
|
// Handle unlimited stock toggle
|
||||||
|
useEffect(() => {
|
||||||
|
if (watchedImageUrl) {
|
||||||
|
setImagePreview(watchedImageUrl)
|
||||||
|
} else {
|
||||||
|
setImagePreview(null)
|
||||||
|
}
|
||||||
|
}, [watchedImageUrl])
|
||||||
|
|
||||||
|
const handleFormSubmit = async (formData: FormValidateType) => {
|
||||||
|
try {
|
||||||
|
setIsSubmitting(true)
|
||||||
|
|
||||||
|
// Create GameRequest object
|
||||||
|
const gameRequest: GameRequest = {
|
||||||
|
name: formData.name,
|
||||||
|
type: formData.type,
|
||||||
|
is_active: formData.is_active,
|
||||||
|
metadata: {
|
||||||
|
imageUrl: formData.imageUrl || undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isEditMode && data?.id) {
|
||||||
|
// Update existing game
|
||||||
|
updateGame.mutate(
|
||||||
|
{ id: data.id, payload: gameRequest },
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
handleReset()
|
||||||
|
handleClose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// Create new game
|
||||||
|
createGame.mutate(gameRequest, {
|
||||||
|
onSuccess: () => {
|
||||||
|
handleReset()
|
||||||
|
handleClose()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error submitting game:', error)
|
||||||
|
// Handle error (show toast, etc.)
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
handleClose()
|
||||||
|
resetForm(initialData)
|
||||||
|
setImagePreview(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
open={open}
|
||||||
|
anchor='right'
|
||||||
|
variant='temporary'
|
||||||
|
onClose={handleReset}
|
||||||
|
ModalProps={{ keepMounted: true }}
|
||||||
|
sx={{
|
||||||
|
'& .MuiDrawer-paper': {
|
||||||
|
width: { xs: 300, sm: 400 },
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
height: '100%'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Sticky Header */}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'sticky',
|
||||||
|
top: 0,
|
||||||
|
zIndex: 10,
|
||||||
|
backgroundColor: 'background.paper',
|
||||||
|
borderBottom: 1,
|
||||||
|
borderColor: 'divider'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className='flex items-center justify-between plb-5 pli-6'>
|
||||||
|
<Typography variant='h5'>{isEditMode ? 'Edit Game' : 'Tambah Game Baru'}</Typography>
|
||||||
|
<IconButton size='small' onClick={handleReset}>
|
||||||
|
<i className='tabler-x text-2xl text-textPrimary' />
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Scrollable Content */}
|
||||||
|
<Box sx={{ flex: 1, overflowY: 'auto' }}>
|
||||||
|
<form id='game-form' onSubmit={handleSubmit(handleFormSubmit)}>
|
||||||
|
<div className='flex flex-col gap-6 p-6'>
|
||||||
|
{/* Image Preview */}
|
||||||
|
{imagePreview && (
|
||||||
|
<Card variant='outlined' sx={{ mb: 2 }}>
|
||||||
|
<CardContent sx={{ p: 2 }}>
|
||||||
|
<Typography variant='subtitle2' className='mb-2'>
|
||||||
|
Preview Gambar
|
||||||
|
</Typography>
|
||||||
|
<Avatar
|
||||||
|
src={imagePreview}
|
||||||
|
sx={{
|
||||||
|
width: 80,
|
||||||
|
height: 80,
|
||||||
|
mx: 'auto',
|
||||||
|
mb: 1
|
||||||
|
}}
|
||||||
|
variant='rounded'
|
||||||
|
>
|
||||||
|
<i className='tabler-device-gamepad-2 text-2xl' />
|
||||||
|
</Avatar>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Nama Game */}
|
||||||
|
<div>
|
||||||
|
<Typography variant='body2' className='mb-2'>
|
||||||
|
Nama Game <span className='text-red-500'>*</span>
|
||||||
|
</Typography>
|
||||||
|
<Controller
|
||||||
|
name='name'
|
||||||
|
control={control}
|
||||||
|
rules={{ required: 'Nama game wajib diisi' }}
|
||||||
|
render={({ field }) => (
|
||||||
|
<CustomTextField
|
||||||
|
{...field}
|
||||||
|
fullWidth
|
||||||
|
placeholder='Masukkan nama game'
|
||||||
|
error={!!errors.name}
|
||||||
|
helperText={errors.name?.message}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tipe Game */}
|
||||||
|
<div>
|
||||||
|
<Typography variant='body2' className='mb-2'>
|
||||||
|
Tipe Game <span className='text-red-500'>*</span>
|
||||||
|
</Typography>
|
||||||
|
<Controller
|
||||||
|
name='type'
|
||||||
|
control={control}
|
||||||
|
rules={{ required: 'Tipe game wajib dipilih' }}
|
||||||
|
render={({ field }) => (
|
||||||
|
<CustomTextField {...field} select fullWidth error={!!errors.type} helperText={errors.type?.message}>
|
||||||
|
{GAME_TYPES.map(type => (
|
||||||
|
<MenuItem key={type.value} value={type.value}>
|
||||||
|
{type.label}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</CustomTextField>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Image URL */}
|
||||||
|
<div>
|
||||||
|
<Typography variant='body2' className='mb-2'>
|
||||||
|
URL Gambar
|
||||||
|
</Typography>
|
||||||
|
<Controller
|
||||||
|
name='imageUrl'
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<CustomTextField
|
||||||
|
{...field}
|
||||||
|
fullWidth
|
||||||
|
placeholder='https://example.com/image.jpg'
|
||||||
|
type='url'
|
||||||
|
InputProps={{
|
||||||
|
startAdornment: (
|
||||||
|
<InputAdornment position='start'>
|
||||||
|
<i className='tabler-photo' />
|
||||||
|
</InputAdornment>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Status Aktif */}
|
||||||
|
<div>
|
||||||
|
<Controller
|
||||||
|
name='is_active'
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormControlLabel
|
||||||
|
control={<Switch checked={field.value} onChange={field.onChange} color='primary' />}
|
||||||
|
label='Game Aktif'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Sticky Footer */}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'sticky',
|
||||||
|
bottom: 0,
|
||||||
|
zIndex: 10,
|
||||||
|
backgroundColor: 'background.paper',
|
||||||
|
borderTop: 1,
|
||||||
|
borderColor: 'divider',
|
||||||
|
p: 3
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className='flex items-center gap-4'>
|
||||||
|
<Button variant='contained' type='submit' form='game-form' disabled={isSubmitting}>
|
||||||
|
{isSubmitting ? (isEditMode ? 'Mengupdate...' : 'Menyimpan...') : isEditMode ? 'Update' : 'Simpan'}
|
||||||
|
</Button>
|
||||||
|
<Button variant='outlined' color='error' onClick={handleReset} disabled={isSubmitting}>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</Drawer>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AddEditGamesDrawer
|
||||||
640
src/views/apps/marketing/games/list/GameListTable.tsx
Normal file
640
src/views/apps/marketing/games/list/GameListTable.tsx
Normal file
@ -0,0 +1,640 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
// React Imports
|
||||||
|
import { useEffect, useState, useMemo, useCallback } from 'react'
|
||||||
|
|
||||||
|
// Next Imports
|
||||||
|
import Link from 'next/link'
|
||||||
|
import { useParams } from 'next/navigation'
|
||||||
|
|
||||||
|
// MUI Imports
|
||||||
|
import Card from '@mui/material/Card'
|
||||||
|
import CardHeader from '@mui/material/CardHeader'
|
||||||
|
import Button from '@mui/material/Button'
|
||||||
|
import Typography from '@mui/material/Typography'
|
||||||
|
import Chip from '@mui/material/Chip'
|
||||||
|
import Checkbox from '@mui/material/Checkbox'
|
||||||
|
import IconButton from '@mui/material/IconButton'
|
||||||
|
import { styled } from '@mui/material/styles'
|
||||||
|
import TablePagination from '@mui/material/TablePagination'
|
||||||
|
import type { TextFieldProps } from '@mui/material/TextField'
|
||||||
|
import MenuItem from '@mui/material/MenuItem'
|
||||||
|
|
||||||
|
// Third-party Imports
|
||||||
|
import classnames from 'classnames'
|
||||||
|
import { rankItem } from '@tanstack/match-sorter-utils'
|
||||||
|
import {
|
||||||
|
createColumnHelper,
|
||||||
|
flexRender,
|
||||||
|
getCoreRowModel,
|
||||||
|
useReactTable,
|
||||||
|
getFilteredRowModel,
|
||||||
|
getFacetedRowModel,
|
||||||
|
getFacetedUniqueValues,
|
||||||
|
getFacetedMinMaxValues,
|
||||||
|
getPaginationRowModel,
|
||||||
|
getSortedRowModel
|
||||||
|
} from '@tanstack/react-table'
|
||||||
|
import type { ColumnDef, FilterFn } from '@tanstack/react-table'
|
||||||
|
import type { RankingInfo } from '@tanstack/match-sorter-utils'
|
||||||
|
|
||||||
|
// Type Imports
|
||||||
|
import type { ThemeColor } from '@core/types'
|
||||||
|
import type { Locale } from '@configs/i18n'
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import OptionMenu from '@core/components/option-menu'
|
||||||
|
import TablePaginationComponent from '@components/TablePaginationComponent'
|
||||||
|
import CustomTextField from '@core/components/mui/TextField'
|
||||||
|
import CustomAvatar from '@core/components/mui/Avatar'
|
||||||
|
|
||||||
|
// Util Imports
|
||||||
|
import { getInitials } from '@/utils/getInitials'
|
||||||
|
import { getLocalizedUrl } from '@/utils/i18n'
|
||||||
|
import { formatCurrency } from '@/utils/transform'
|
||||||
|
|
||||||
|
// Style Imports
|
||||||
|
import tableStyles from '@core/styles/table.module.css'
|
||||||
|
import Loading from '@/components/layout/shared/Loading'
|
||||||
|
import AddEditGamesDrawer from './AddEditGamesDrawer'
|
||||||
|
|
||||||
|
// Game Interface
|
||||||
|
export interface Game {
|
||||||
|
id: string // uuid
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
is_active: boolean
|
||||||
|
metadata: Record<string, any>
|
||||||
|
created_at: string // ISO datetime
|
||||||
|
updated_at: string // ISO datetime
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@tanstack/table-core' {
|
||||||
|
interface FilterFns {
|
||||||
|
fuzzy: FilterFn<unknown>
|
||||||
|
}
|
||||||
|
interface FilterMeta {
|
||||||
|
itemRank: RankingInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type GameWithAction = Game & {
|
||||||
|
action?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Styled Components
|
||||||
|
const Icon = styled('i')({})
|
||||||
|
|
||||||
|
const fuzzyFilter: FilterFn<any> = (row, columnId, value, addMeta) => {
|
||||||
|
// Rank the item
|
||||||
|
const itemRank = rankItem(row.getValue(columnId), value)
|
||||||
|
|
||||||
|
// Store the itemRank info
|
||||||
|
addMeta({
|
||||||
|
itemRank
|
||||||
|
})
|
||||||
|
|
||||||
|
// Return if the item should be filtered in/out
|
||||||
|
return itemRank.passed
|
||||||
|
}
|
||||||
|
|
||||||
|
const DebouncedInput = ({
|
||||||
|
value: initialValue,
|
||||||
|
onChange,
|
||||||
|
debounce = 500,
|
||||||
|
...props
|
||||||
|
}: {
|
||||||
|
value: string | number
|
||||||
|
onChange: (value: string | number) => void
|
||||||
|
debounce?: number
|
||||||
|
} & Omit<TextFieldProps, 'onChange'>) => {
|
||||||
|
// States
|
||||||
|
const [value, setValue] = useState(initialValue)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setValue(initialValue)
|
||||||
|
}, [initialValue])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
onChange(value)
|
||||||
|
}, debounce)
|
||||||
|
|
||||||
|
return () => clearTimeout(timeout)
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [value])
|
||||||
|
|
||||||
|
return <CustomTextField {...props} value={value} onChange={e => setValue(e.target.value)} />
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dummy data for games
|
||||||
|
const DUMMY_GAME_DATA: Game[] = [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
name: 'Quiz Master Challenge',
|
||||||
|
type: 'quiz',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {
|
||||||
|
imageUrl: 'https://example.com/quiz-master.jpg'
|
||||||
|
},
|
||||||
|
created_at: '2024-01-15T08:30:00Z',
|
||||||
|
updated_at: '2024-02-10T10:15:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
name: 'Memory Palace',
|
||||||
|
type: 'memory',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {
|
||||||
|
imageUrl: 'https://example.com/memory-palace.jpg'
|
||||||
|
},
|
||||||
|
created_at: '2024-01-20T09:00:00Z',
|
||||||
|
updated_at: '2024-02-15T11:30:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '3',
|
||||||
|
name: 'Word Wizard',
|
||||||
|
type: 'word',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {},
|
||||||
|
created_at: '2024-01-25T14:20:00Z',
|
||||||
|
updated_at: '2024-02-20T16:45:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '4',
|
||||||
|
name: 'Math Sprint',
|
||||||
|
type: 'math',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {},
|
||||||
|
created_at: '2024-02-01T07:15:00Z',
|
||||||
|
updated_at: '2024-02-25T13:20:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '5',
|
||||||
|
name: 'Puzzle Paradise',
|
||||||
|
type: 'puzzle',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {
|
||||||
|
imageUrl: 'https://example.com/puzzle-paradise.jpg'
|
||||||
|
},
|
||||||
|
created_at: '2024-02-05T11:40:00Z',
|
||||||
|
updated_at: '2024-03-01T09:25:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '6',
|
||||||
|
name: 'Trivia Tournament',
|
||||||
|
type: 'trivia',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {},
|
||||||
|
created_at: '2024-02-10T16:00:00Z',
|
||||||
|
updated_at: '2024-03-05T12:10:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '7',
|
||||||
|
name: 'Speed Arcade',
|
||||||
|
type: 'arcade',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {
|
||||||
|
imageUrl: 'https://example.com/speed-arcade.jpg'
|
||||||
|
},
|
||||||
|
created_at: '2024-02-15T13:30:00Z',
|
||||||
|
updated_at: '2024-03-10T15:45:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '8',
|
||||||
|
name: 'Strategy Kingdom',
|
||||||
|
type: 'strategy',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {},
|
||||||
|
created_at: '2024-03-01T10:20:00Z',
|
||||||
|
updated_at: '2024-03-15T08:55:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '9',
|
||||||
|
name: 'Quick Quiz',
|
||||||
|
type: 'quiz',
|
||||||
|
is_active: false,
|
||||||
|
metadata: {},
|
||||||
|
created_at: '2024-03-05T12:45:00Z',
|
||||||
|
updated_at: '2024-03-20T14:30:00Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '10',
|
||||||
|
name: 'Brain Teaser Deluxe',
|
||||||
|
type: 'puzzle',
|
||||||
|
is_active: true,
|
||||||
|
metadata: {
|
||||||
|
imageUrl: 'https://example.com/brain-teaser.jpg'
|
||||||
|
},
|
||||||
|
created_at: '2024-03-10T09:15:00Z',
|
||||||
|
updated_at: '2024-03-25T11:40:00Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// Mock data hook with dummy data
|
||||||
|
const useGameCatalog = ({ page, limit, search }: { page: number; limit: number; search: string }) => {
|
||||||
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
|
||||||
|
// Simulate loading
|
||||||
|
useEffect(() => {
|
||||||
|
setIsLoading(true)
|
||||||
|
const timer = setTimeout(() => setIsLoading(false), 500)
|
||||||
|
return () => clearTimeout(timer)
|
||||||
|
}, [page, limit, search])
|
||||||
|
|
||||||
|
// Filter data based on search
|
||||||
|
const filteredData = useMemo(() => {
|
||||||
|
if (!search) return DUMMY_GAME_DATA
|
||||||
|
|
||||||
|
return DUMMY_GAME_DATA.filter(
|
||||||
|
game =>
|
||||||
|
game.name.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
game.type.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
game.metadata?.description?.toLowerCase().includes(search.toLowerCase())
|
||||||
|
)
|
||||||
|
}, [search])
|
||||||
|
|
||||||
|
// Paginate data
|
||||||
|
const paginatedData = useMemo(() => {
|
||||||
|
const startIndex = (page - 1) * limit
|
||||||
|
const endIndex = startIndex + limit
|
||||||
|
return filteredData.slice(startIndex, endIndex)
|
||||||
|
}, [filteredData, page, limit])
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
games: paginatedData,
|
||||||
|
total_count: filteredData.length
|
||||||
|
},
|
||||||
|
isLoading,
|
||||||
|
error: null,
|
||||||
|
isFetching: isLoading
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper functions
|
||||||
|
const getGameTypeLabel = (type: string) => {
|
||||||
|
const typeMap: Record<string, string> = {
|
||||||
|
quiz: 'Quiz',
|
||||||
|
puzzle: 'Puzzle',
|
||||||
|
memory: 'Memory',
|
||||||
|
trivia: 'Trivia',
|
||||||
|
word: 'Word Game',
|
||||||
|
math: 'Math Game',
|
||||||
|
arcade: 'Arcade',
|
||||||
|
strategy: 'Strategy'
|
||||||
|
}
|
||||||
|
return typeMap[type] || type
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDifficultyColor = (difficulty: string): ThemeColor => {
|
||||||
|
switch (difficulty) {
|
||||||
|
case 'easy':
|
||||||
|
return 'success'
|
||||||
|
case 'medium':
|
||||||
|
return 'warning'
|
||||||
|
case 'hard':
|
||||||
|
return 'error'
|
||||||
|
case 'expert':
|
||||||
|
return 'primary'
|
||||||
|
default:
|
||||||
|
return 'secondary'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDifficultyLabel = (difficulty: string) => {
|
||||||
|
const difficultyMap: Record<string, string> = {
|
||||||
|
easy: 'Mudah',
|
||||||
|
medium: 'Sedang',
|
||||||
|
hard: 'Sulit',
|
||||||
|
expert: 'Ahli'
|
||||||
|
}
|
||||||
|
return difficultyMap[difficulty] || difficulty
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatDuration = (seconds: number) => {
|
||||||
|
if (seconds < 60) return `${seconds}s`
|
||||||
|
const minutes = Math.floor(seconds / 60)
|
||||||
|
const remainingSeconds = seconds % 60
|
||||||
|
return remainingSeconds > 0 ? `${minutes}m ${remainingSeconds}s` : `${minutes}m`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Column Definitions
|
||||||
|
const columnHelper = createColumnHelper<GameWithAction>()
|
||||||
|
|
||||||
|
const GameListTable = () => {
|
||||||
|
// States
|
||||||
|
const [addGameOpen, setAddGameOpen] = useState(false)
|
||||||
|
const [editGameData, setEditGameData] = useState<Game | undefined>(undefined)
|
||||||
|
const [rowSelection, setRowSelection] = useState({})
|
||||||
|
const [globalFilter, setGlobalFilter] = useState('')
|
||||||
|
const [currentPage, setCurrentPage] = useState(1)
|
||||||
|
const [pageSize, setPageSize] = useState(10)
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
|
||||||
|
const { data, isLoading, error, isFetching } = useGameCatalog({
|
||||||
|
page: currentPage,
|
||||||
|
limit: pageSize,
|
||||||
|
search
|
||||||
|
})
|
||||||
|
|
||||||
|
const games = data?.games ?? []
|
||||||
|
const totalCount = data?.total_count ?? 0
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
const { lang: locale } = useParams()
|
||||||
|
|
||||||
|
const handlePageChange = useCallback((event: unknown, newPage: number) => {
|
||||||
|
setCurrentPage(newPage)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handlePageSizeChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const newPageSize = parseInt(event.target.value, 10)
|
||||||
|
setPageSize(newPageSize)
|
||||||
|
setCurrentPage(1) // Reset to first page
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleEditGame = (game: Game) => {
|
||||||
|
setEditGameData(game)
|
||||||
|
setAddGameOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDeleteGame = (gameId: string) => {
|
||||||
|
if (confirm('Apakah Anda yakin ingin menghapus game ini?')) {
|
||||||
|
console.log('Deleting game:', gameId)
|
||||||
|
// Add your delete logic here
|
||||||
|
// deleteGame.mutate(gameId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleToggleActive = (gameId: string, currentStatus: boolean) => {
|
||||||
|
console.log('Toggling active status for game:', gameId, !currentStatus)
|
||||||
|
// Add your toggle logic here
|
||||||
|
// toggleGameStatus.mutate({ id: gameId, is_active: !currentStatus })
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCloseGameDrawer = () => {
|
||||||
|
setAddGameOpen(false)
|
||||||
|
setEditGameData(undefined)
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns = useMemo<ColumnDef<GameWithAction, any>[]>(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
id: 'select',
|
||||||
|
header: ({ table }) => (
|
||||||
|
<Checkbox
|
||||||
|
{...{
|
||||||
|
checked: table.getIsAllRowsSelected(),
|
||||||
|
indeterminate: table.getIsSomeRowsSelected(),
|
||||||
|
onChange: table.getToggleAllRowsSelectedHandler()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Checkbox
|
||||||
|
{...{
|
||||||
|
checked: row.getIsSelected(),
|
||||||
|
disabled: !row.getCanSelect(),
|
||||||
|
indeterminate: row.getIsSomeSelected(),
|
||||||
|
onChange: row.getToggleSelectedHandler()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
columnHelper.accessor('name', {
|
||||||
|
header: 'Nama Game',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className='flex items-center gap-4'>
|
||||||
|
<CustomAvatar src={row.original.metadata?.imageUrl} size={40}>
|
||||||
|
{getInitials(row.original.name)}
|
||||||
|
</CustomAvatar>
|
||||||
|
<div className='flex flex-col'>
|
||||||
|
<Link href={getLocalizedUrl(`/apps/games/${row.original.id}/detail`, locale as Locale)}>
|
||||||
|
<Typography className='font-medium cursor-pointer hover:underline text-primary'>
|
||||||
|
{row.original.name}
|
||||||
|
</Typography>
|
||||||
|
</Link>
|
||||||
|
<Typography variant='caption' color='textSecondary'>
|
||||||
|
{getGameTypeLabel(row.original.type)}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('type', {
|
||||||
|
header: 'Tipe Game',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Chip label={getGameTypeLabel(row.original.type)} color='primary' variant='tonal' size='small' />
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('is_active', {
|
||||||
|
header: 'Status',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Chip
|
||||||
|
label={row.original.is_active ? 'Aktif' : 'Nonaktif'}
|
||||||
|
color={row.original.is_active ? 'success' : 'error'}
|
||||||
|
variant='tonal'
|
||||||
|
size='small'
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('created_at', {
|
||||||
|
header: 'Tanggal Dibuat',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Typography color='text.primary'>
|
||||||
|
{new Date(row.original.created_at).toLocaleDateString('id-ID', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric'
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
id: 'actions',
|
||||||
|
header: 'Aksi',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className='flex items-center'>
|
||||||
|
<OptionMenu
|
||||||
|
iconButtonProps={{ size: 'medium' }}
|
||||||
|
iconClassName='text-textSecondary text-[22px]'
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
text: row.original.is_active ? 'Nonaktifkan' : 'Aktifkan',
|
||||||
|
icon: row.original.is_active ? 'tabler-eye-off text-[22px]' : 'tabler-eye text-[22px]',
|
||||||
|
menuItemProps: {
|
||||||
|
className: 'flex items-center gap-2 text-textSecondary',
|
||||||
|
onClick: () => handleToggleActive(row.original.id, row.original.is_active)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Edit',
|
||||||
|
icon: 'tabler-edit text-[22px]',
|
||||||
|
menuItemProps: {
|
||||||
|
className: 'flex items-center gap-2 text-textSecondary',
|
||||||
|
onClick: () => handleEditGame(row.original)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Hapus',
|
||||||
|
icon: 'tabler-trash text-[22px]',
|
||||||
|
menuItemProps: {
|
||||||
|
className: 'flex items-center gap-2 text-textSecondary',
|
||||||
|
onClick: () => handleDeleteGame(row.original.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
enableSorting: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[locale, handleEditGame, handleDeleteGame, handleToggleActive]
|
||||||
|
)
|
||||||
|
|
||||||
|
const table = useReactTable({
|
||||||
|
data: games as Game[],
|
||||||
|
columns,
|
||||||
|
filterFns: {
|
||||||
|
fuzzy: fuzzyFilter
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
rowSelection,
|
||||||
|
globalFilter,
|
||||||
|
pagination: {
|
||||||
|
pageIndex: currentPage,
|
||||||
|
pageSize
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enableRowSelection: true,
|
||||||
|
onRowSelectionChange: setRowSelection,
|
||||||
|
getCoreRowModel: getCoreRowModel(),
|
||||||
|
manualPagination: true,
|
||||||
|
pageCount: Math.ceil(totalCount / pageSize)
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card>
|
||||||
|
<div className='flex justify-between flex-col items-start md:flex-row md:items-center p-6 border-bs gap-4'>
|
||||||
|
<CustomTextField
|
||||||
|
select
|
||||||
|
value={table.getState().pagination.pageSize}
|
||||||
|
onChange={e => table.setPageSize(Number(e.target.value))}
|
||||||
|
className='max-sm:is-full sm:is-[70px]'
|
||||||
|
>
|
||||||
|
<MenuItem value='10'>10</MenuItem>
|
||||||
|
<MenuItem value='25'>25</MenuItem>
|
||||||
|
<MenuItem value='50'>50</MenuItem>
|
||||||
|
</CustomTextField>
|
||||||
|
<div className='flex flex-col sm:flex-row max-sm:is-full items-start sm:items-center gap-4'>
|
||||||
|
<DebouncedInput
|
||||||
|
value={search ?? ''}
|
||||||
|
onChange={value => setSearch(value as string)}
|
||||||
|
placeholder='Cari Game'
|
||||||
|
className='max-sm:is-full'
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
color='secondary'
|
||||||
|
variant='tonal'
|
||||||
|
startIcon={<i className='tabler-upload' />}
|
||||||
|
className='max-sm:is-full'
|
||||||
|
>
|
||||||
|
Ekspor
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant='contained'
|
||||||
|
startIcon={<i className='tabler-plus' />}
|
||||||
|
onClick={() => setAddGameOpen(!addGameOpen)}
|
||||||
|
className='max-sm:is-full'
|
||||||
|
>
|
||||||
|
Tambah Game
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='overflow-x-auto'>
|
||||||
|
{isLoading ? (
|
||||||
|
<Loading />
|
||||||
|
) : (
|
||||||
|
<table className={tableStyles.table}>
|
||||||
|
<thead>
|
||||||
|
{table.getHeaderGroups().map(headerGroup => (
|
||||||
|
<tr key={headerGroup.id}>
|
||||||
|
{headerGroup.headers.map(header => (
|
||||||
|
<th key={header.id}>
|
||||||
|
{header.isPlaceholder ? null : (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={classnames({
|
||||||
|
'flex items-center': header.column.getIsSorted(),
|
||||||
|
'cursor-pointer select-none': header.column.getCanSort()
|
||||||
|
})}
|
||||||
|
onClick={header.column.getToggleSortingHandler()}
|
||||||
|
>
|
||||||
|
{flexRender(header.column.columnDef.header, header.getContext())}
|
||||||
|
{{
|
||||||
|
asc: <i className='tabler-chevron-up text-xl' />,
|
||||||
|
desc: <i className='tabler-chevron-down text-xl' />
|
||||||
|
}[header.column.getIsSorted() as 'asc' | 'desc'] ?? null}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</thead>
|
||||||
|
{table.getFilteredRowModel().rows.length === 0 ? (
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td colSpan={table.getVisibleFlatColumns().length} className='text-center'>
|
||||||
|
Tidak ada data tersedia
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
) : (
|
||||||
|
<tbody>
|
||||||
|
{table
|
||||||
|
.getRowModel()
|
||||||
|
.rows.slice(0, table.getState().pagination.pageSize)
|
||||||
|
.map(row => {
|
||||||
|
return (
|
||||||
|
<tr key={row.id} className={classnames({ selected: row.getIsSelected() })}>
|
||||||
|
{row.getVisibleCells().map(cell => (
|
||||||
|
<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</tbody>
|
||||||
|
)}
|
||||||
|
</table>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<TablePagination
|
||||||
|
component={() => (
|
||||||
|
<TablePaginationComponent
|
||||||
|
pageIndex={currentPage}
|
||||||
|
pageSize={pageSize}
|
||||||
|
totalCount={totalCount}
|
||||||
|
onPageChange={handlePageChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
count={totalCount}
|
||||||
|
rowsPerPage={pageSize}
|
||||||
|
page={currentPage}
|
||||||
|
onPageChange={handlePageChange}
|
||||||
|
onRowsPerPageChange={handlePageSizeChange}
|
||||||
|
rowsPerPageOptions={[10, 25, 50]}
|
||||||
|
disabled={isLoading}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
<AddEditGamesDrawer open={addGameOpen} handleClose={handleCloseGameDrawer} data={editGameData} />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GameListTable
|
||||||
17
src/views/apps/marketing/games/list/index.tsx
Normal file
17
src/views/apps/marketing/games/list/index.tsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// MUI Imports
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
import GameListTable from './GameListTable'
|
||||||
|
|
||||||
|
// Type Imports
|
||||||
|
|
||||||
|
const GamesList = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<GameListTable />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GamesList
|
||||||
Loading…
x
Reference in New Issue
Block a user