Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sweepstake
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arjun Jhukal
sweepstake
Commits
4bb1f0b3
Commit
4bb1f0b3
authored
Oct 27, 2025
by
Arjun Jhukal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
download transaction and player is working for all the pages on admin dashboard
parent
a36b8a6b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
144 additions
and
18 deletions
+144
-18
index.tsx
...mponents/pages/dashboard/adminDashboard/players/index.tsx
+33
-1
TransactionTable.tsx
...dashboard/adminDashboard/transaction/TransactionTable.tsx
+48
-2
downloadApi.ts
src/services/downloadApi.ts
+63
-15
No files found.
src/components/pages/dashboard/adminDashboard/players/index.tsx
View file @
4bb1f0b3
...
...
@@ -7,6 +7,7 @@ import TableHeader from '@/components/molecules/TableHeader'
import
CustomTable
from
'@/components/organism/Table'
;
import
{
useAppDispatch
}
from
'@/hooks/hook'
;
import
{
PATH
}
from
'@/routes/PATH'
;
import
{
useDownloadUserMutation
}
from
'@/services/downloadApi'
;
import
{
useDeletePlayerByIdMutation
,
useGetAllPlayerQuery
,
useSuspendPlayerByIdMutation
}
from
'@/services/playerApi'
;
import
{
showToast
,
ToastVariant
}
from
'@/slice/toastSlice'
;
import
{
PlayerItem
,
PlayerProps
}
from
'@/types/player'
;
...
...
@@ -36,6 +37,7 @@ export default function PlayerListing() {
const
[
deletePlayer
,
{
isLoading
:
deletingPlayer
}]
=
useDeletePlayerByIdMutation
();
const
[
suspendPlayer
,
{
isLoading
:
suspendingPlayer
}]
=
useSuspendPlayerByIdMutation
();
const
[
downloadUser
,
{
isLoading
:
downloading
}]
=
useDownloadUserMutation
();
const
handlePlayerSuspend
=
async
(
id
:
string
)
=>
{
try
{
...
...
@@ -225,7 +227,37 @@ export default function PlayerListing() {
<
TableHeader
search=
{
search
}
setSearch=
{
setSearch
}
onDownloadCSV=
{
()
=>
{
}
}
onDownloadCSV=
{
async
()
=>
{
try
{
const
res
=
await
downloadUser
({
search
,
}).
unwrap
();
const
blob
=
new
Blob
([
res
],
{
type
:
"text/csv"
});
const
url
=
window
.
URL
.
createObjectURL
(
blob
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
`transactions_${new Date().toISOString()}.csv`
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
a
.
remove
();
dispatch
(
showToast
({
variant
:
ToastVariant
.
SUCCESS
,
message
:
"CSV Downloaded successfully."
,
})
);
}
catch
(
e
:
any
)
{
dispatch
(
showToast
({
variant
:
ToastVariant
.
ERROR
,
message
:
e
.
message
||
"Unable to download CSV."
,
})
);
}
}
}
downloading=
{
downloading
}
/>
<
div
className=
"px-4"
>
<
TabController
...
...
src/components/pages/dashboard/adminDashboard/transaction/TransactionTable.tsx
View file @
4bb1f0b3
...
...
@@ -159,12 +159,12 @@ export default function TransactionTable({ user_id, game_id, search, setSearch }
return
(
<
div
className=
"border-gray border-solid border-[1px] rounded-[8px] lg:rounded-[16px]"
>
<
TableHeader
{
/*
<TableHeader
search={search}
setSearch={setSearch && setSearch}
onDownloadCSV={async () => {
try {
const
response
=
await
downloadTransaction
({
user
:
user_id
,
game
:
game_id
?.
toString
()
}).
unwrap
();
const response = await downloadTransaction({ user: user_id, game: game_id?.toString()
,search:search
}).unwrap();
dispatch(
showToast({
variant: ToastVariant.SUCCESS,
...
...
@@ -185,8 +185,54 @@ export default function TransactionTable({ user_id, game_id, search, setSearch }
filters={[
{ value: status || "", setValue: (value) => setStatus(value as TransactionStatusProps), options: StatusOptions, placeholder: "Filter by status" }
]}
/> */
}
<
TableHeader
search=
{
search
}
setSearch=
{
setSearch
&&
setSearch
}
onDownloadCSV=
{
async
()
=>
{
try
{
const
res
=
await
downloadTransaction
({
user
:
user_id
?.
toString
(),
game
:
game_id
?.
toString
(),
search
,
}).
unwrap
();
const
blob
=
new
Blob
([
res
],
{
type
:
"text/csv"
});
const
url
=
window
.
URL
.
createObjectURL
(
blob
);
const
a
=
document
.
createElement
(
"a"
);
a
.
href
=
url
;
a
.
download
=
`transactions_${new Date().toISOString()}.csv`
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
a
.
remove
();
dispatch
(
showToast
({
variant
:
ToastVariant
.
SUCCESS
,
message
:
"CSV Downloaded successfully."
,
})
);
}
catch
(
e
:
any
)
{
dispatch
(
showToast
({
variant
:
ToastVariant
.
ERROR
,
message
:
e
.
message
||
"Unable to download CSV."
,
})
);
}
}
}
downloading=
{
downloading
}
filters=
{
[
{
value
:
status
||
""
,
setValue
:
(
value
)
=>
setStatus
(
value
as
TransactionStatusProps
),
options
:
StatusOptions
,
placeholder
:
"Filter by status"
,
},
]
}
/>
<>
<
CustomTable
key=
{
`${page}-${pageSize}-${search}-${game_id}-${user_id}`
}
...
...
src/services/downloadApi.ts
View file @
4bb1f0b3
import
{
createApi
}
from
"@reduxjs/toolkit/query/react"
;
import
{
baseQuery
}
from
"./baseQuery"
;
// import { createApi } from "@reduxjs/toolkit/query/react";
// import { baseQuery } from "./baseQuery";
// import { GlobalResponse } from "@/types/config";
// export const downloadApi = createApi({
// reducerPath: "downloadApi",
// baseQuery: baseQuery,
// tagTypes: ["Download"],
// endpoints: (builder) => ({
// downloadTransaction: builder.mutation<GlobalResponse, { user?: string; game?: string; search?: string }>({
// query: ({ user, game, search }) => {
// const params = new URLSearchParams();
// if (user) params.append('user', user.toString());
// if (game) params.append('game', game.toString());
// if (search) params.append('search', search.toString());
// const queryString = params.toString();
// return {
// url: `/api/admin/download/transactions${queryString ? `?${queryString}` : ''}`,
// method: "GET",
// }
// }
// })
// })
// })
// export const { useDownloadTransactionMutation } = downloadApi;
// src/services/downloadApi.ts
import
{
createApi
,
fetchBaseQuery
}
from
"@reduxjs/toolkit/query/react"
;
import
{
baseQuery
}
from
"./baseQuery"
;
// your custom base query
import
{
GlobalResponse
}
from
"@/types/config"
;
export
const
downloadApi
=
createApi
({
...
...
@@ -7,19 +34,41 @@ export const downloadApi = createApi({
baseQuery
:
baseQuery
,
tagTypes
:
[
"Download"
],
endpoints
:
(
builder
)
=>
({
downloadTransaction
:
builder
.
mutation
<
GlobalResponse
,
{
user
?:
string
;
game
?:
string
}
>
({
query
:
({
user
,
game
})
=>
{
downloadTransaction
:
builder
.
mutation
<
Blob
,
{
user
?:
string
;
game
?:
string
;
search
?:
string
}
>
({
async
queryFn
(
args
,
_queryApi
,
_extraOptions
,
fetchWithBQ
)
{
const
params
=
new
URLSearchParams
();
if
(
user
)
params
.
append
(
'user'
,
user
.
toString
());
if
(
game
)
params
.
append
(
'game'
,
game
.
toString
());
if
(
args
.
user
)
params
.
append
(
"user"
,
args
.
user
.
toString
());
if
(
args
.
game
)
params
.
append
(
"game"
,
args
.
game
.
toString
());
if
(
args
.
search
)
params
.
append
(
"search"
,
args
.
search
.
toString
());
const
queryString
=
params
.
toString
();
return
{
url
:
`/api/admin/download/transactions
${
queryString
?
`?
${
queryString
}
`
:
''
}
`
,
const
response
=
await
fetchWithBQ
({
url
:
`/api/admin/download/transactions
${
queryString
?
`?
${
queryString
}
`
:
""
}
`
,
method
:
"GET"
,
}
}
})
})
})
responseHandler
:
async
(
response
)
=>
response
.
blob
(),
// ⬅️ handle blob here
});
if
(
response
.
error
)
return
{
error
:
response
.
error
};
return
{
data
:
response
.
data
as
Blob
};
},
}),
downloadUser
:
builder
.
mutation
<
Blob
,
{
search
?:
string
}
>
({
async
queryFn
(
args
,
_queryApi
,
_extraOptions
,
fetchWithBQ
)
{
const
params
=
new
URLSearchParams
();
if
(
args
.
search
)
params
.
append
(
"search"
,
args
.
search
.
toString
());
const
queryString
=
params
.
toString
();
const
response
=
await
fetchWithBQ
({
url
:
`/api/admin/download/transactions
${
queryString
?
`?
${
queryString
}
`
:
""
}
`
,
method
:
"GET"
,
responseHandler
:
async
(
response
)
=>
response
.
blob
(),
// ⬅️ handle blob here
});
if
(
response
.
error
)
return
{
error
:
response
.
error
};
return
{
data
:
response
.
data
as
Blob
};
},
}),
}),
});
export
const
{
useDownloadTransactionMutation
}
=
downloadApi
;
\ No newline at end of file
export
const
{
useDownloadTransactionMutation
,
useDownloadUserMutation
}
=
downloadApi
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment