fix: apollo server image upload
This commit is contained in:
parent
9baa16c824
commit
3e4f4a4962
6 changed files with 103 additions and 10 deletions
|
|
@ -120,14 +120,30 @@ const EDIT_CUSTOMER = gql`
|
|||
mutation editCustomer($customerId: ID!, $customerEdit: CustomerEdit) {
|
||||
editCustomer(customerId: $customerId, customerEdit: $customerEdit) {
|
||||
id
|
||||
frontCamera
|
||||
idCardData
|
||||
idCardPhoto
|
||||
usSsn
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const REPLACE_CUSTOMER_PHOTO = gql`
|
||||
mutation replacePhoto(
|
||||
$customerId: ID!
|
||||
$photoType: String
|
||||
$newPhoto: Upload
|
||||
) {
|
||||
replacePhoto(
|
||||
customerId: $customerId
|
||||
photoType: $photoType
|
||||
newPhoto: $newPhoto
|
||||
) {
|
||||
id
|
||||
newPhoto
|
||||
photoType
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const DELETE_EDITED_CUSTOMER = gql`
|
||||
mutation deleteEditedData($customerId: ID!, $customerEdit: CustomerEdit) {
|
||||
deleteEditedData(customerId: $customerId, customerEdit: $customerEdit) {
|
||||
|
|
@ -156,6 +172,10 @@ const CustomerProfile = memo(() => {
|
|||
}
|
||||
)
|
||||
|
||||
const [replaceCustomerPhoto] = useMutation(REPLACE_CUSTOMER_PHOTO, {
|
||||
onCompleted: () => getCustomer()
|
||||
})
|
||||
|
||||
const [editCustomerData] = useMutation(EDIT_CUSTOMER, {
|
||||
onCompleted: () => getCustomer()
|
||||
})
|
||||
|
|
@ -176,6 +196,15 @@ const CustomerProfile = memo(() => {
|
|||
}
|
||||
})
|
||||
|
||||
const replacePhoto = it =>
|
||||
replaceCustomerPhoto({
|
||||
variables: {
|
||||
customerId,
|
||||
newPhoto: it.newPhoto,
|
||||
photoType: it.photoType
|
||||
}
|
||||
})
|
||||
|
||||
const editCustomer = it =>
|
||||
editCustomerData({
|
||||
variables: {
|
||||
|
|
@ -343,6 +372,7 @@ const CustomerProfile = memo(() => {
|
|||
<CustomerData
|
||||
customer={customerData}
|
||||
updateCustomer={updateCustomer}
|
||||
replacePhoto={replacePhoto}
|
||||
editCustomer={editCustomer}
|
||||
deleteEditedData={deleteEditedData}></CustomerData>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue