@@ -3,19 +3,18 @@ import { Button } from "payload/components/elements";
3
3
import { AdminView } from "payload/config" ;
4
4
import ViewTemplate from "./ViewTemplate" ;
5
5
import { Column } from "payload/dist/admin/components/elements/Table/types" ;
6
- import { Promotion } from "../../@types/Promotion" ;
7
- import { IPromotion } from "../../@types/IPromotion" ;
6
+ import { PromoInfo } from "types" ;
8
7
import PromotionsApi from "../../apis/promotions.api" ;
9
8
import { RenderCellFactory } from "../utils/RenderCellFactory" ;
10
9
import SortedColumn from "../utils/SortedColumn" ;
11
10
import { Table } from "payload/dist/admin/components/elements/Table" ;
12
11
13
12
const MerchPromotion : AdminView = ( { user, canAccessAdmin } ) => {
14
13
// Get data from API
15
- const [ data , setData ] = useState < IPromotion [ ] > ( null ) ;
14
+ const [ data , setData ] = useState < PromoInfo [ ] > ( null ) ;
16
15
useEffect ( ( ) => {
17
16
PromotionsApi . getPromotions ( )
18
- . then ( ( res : IPromotion [ ] ) => setData ( res ) )
17
+ . then ( ( res : PromoInfo [ ] ) => setData ( res ) )
19
18
. catch ( ( error ) => console . log ( error ) ) ;
20
19
} , [ ] ) ;
21
20
@@ -34,7 +33,9 @@ const MerchPromotion: AdminView = ({ user, canAccessAdmin }) => {
34
33
}
35
34
36
35
const tableCols = new Array < Column > ( ) ;
37
- for ( const key of Object . keys ( new Promotion ( ) ) ) {
36
+ const samplePromo = data [ 0 ] ;
37
+ const keys = Object . keys ( samplePromo ) ;
38
+ for ( const key of keys ) {
38
39
const renderCellComponent = RenderCellFactory . get ( data [ 0 ] , key ) ;
39
40
const renderCell : React . FC < { children ?: React . ReactNode } > =
40
41
renderCellComponent instanceof Promise
@@ -118,9 +119,7 @@ const MerchPromotion: AdminView = ({ user, canAccessAdmin }) => {
118
119
</ Button >
119
120
< div
120
121
style = { {
121
- position : "absolute" ,
122
- top : 0 ,
123
- right : 0 ,
122
+ position : "relative" ,
124
123
} }
125
124
>
126
125
< Button onClick = { handleCreatePromotion } buttonStyle = "primary" >
0 commit comments