added delete popup on the coupon list
This commit is contained in:
parent
6bdf3b22a0
commit
e22a5681dd
1 changed files with 22 additions and 5 deletions
|
|
@ -4,6 +4,7 @@ import gql from 'graphql-tag'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
|
import { DeleteDialog } from 'src/components/DeleteDialog'
|
||||||
import { Link, Button, IconButton } from 'src/components/buttons'
|
import { Link, Button, IconButton } from 'src/components/buttons'
|
||||||
import TitleSection from 'src/components/layout/TitleSection'
|
import TitleSection from 'src/components/layout/TitleSection'
|
||||||
import DataTable from 'src/components/tables/DataTable'
|
import DataTable from 'src/components/tables/DataTable'
|
||||||
|
|
@ -49,6 +50,14 @@ const CREATE_CODE = gql`
|
||||||
const PromoCodes = () => {
|
const PromoCodes = () => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
|
const [deleteDialog, setDeleteDialog] = useState(false)
|
||||||
|
const [toBeDeleted, setToBeDeleted] = useState()
|
||||||
|
|
||||||
|
const onConfirmed = () => {
|
||||||
|
deleteCode(toBeDeleted)
|
||||||
|
setDeleteDialog(false)
|
||||||
|
}
|
||||||
|
|
||||||
const [showModal, setShowModal] = useState(false)
|
const [showModal, setShowModal] = useState(false)
|
||||||
const [errorMsg, setErrorMsg] = useState(null)
|
const [errorMsg, setErrorMsg] = useState(null)
|
||||||
const toggleModal = () => setShowModal(!showModal)
|
const toggleModal = () => setShowModal(!showModal)
|
||||||
|
|
@ -111,7 +120,8 @@ const PromoCodes = () => {
|
||||||
view: t => (
|
view: t => (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
deleteCode({ variables: { codeId: t.id } })
|
setDeleteDialog(true)
|
||||||
|
setToBeDeleted({ variables: { codeId: t.id } })
|
||||||
}}>
|
}}>
|
||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|
@ -135,10 +145,17 @@ const PromoCodes = () => {
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
{!loading && !R.isEmpty(codeResponse.promoCodes) && (
|
{!loading && !R.isEmpty(codeResponse.promoCodes) && (
|
||||||
|
<>
|
||||||
<DataTable
|
<DataTable
|
||||||
elements={elements}
|
elements={elements}
|
||||||
data={R.path(['promoCodes'])(codeResponse)}
|
data={R.path(['promoCodes'])(codeResponse)}
|
||||||
/>
|
/>
|
||||||
|
<DeleteDialog
|
||||||
|
open={deleteDialog}
|
||||||
|
setDeleteDialog={setDeleteDialog}
|
||||||
|
onConfirmed={onConfirmed}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{!loading && R.isEmpty(codeResponse.promoCodes) && (
|
{!loading && R.isEmpty(codeResponse.promoCodes) && (
|
||||||
<Box display="flex" alignItems="left" flexDirection="column">
|
<Box display="flex" alignItems="left" flexDirection="column">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue