import React, {useState} from 'react';
import ContactForm from './ContactForm.jsx'
import styles from './styles'
import * as api from '../../api'
export default function ({contact,onSave,chats}){
const [edit, setEdit] = useState(false)
const [pay, setPay] = useState(false)
const [amount, setAmount] = useState(0)
const [paying, setPaying] = useState(false)
if (edit) {
return (
{
onSave(id, values)
setEdit(false)
}} onCancel={()=>setEdit(false)} />
)
}
function payButton() {
if(pay){
confirmPay()
} else {
setPay(true)
setAmount(0)
}
}
async function confirmPay() {
const amt = parseInt(amount)
console.log(chats)
console.log(contact)
const chatz = chats && chats.filter(c=> c.contact_ids.includes(parseInt(contact.id)))
console.log(chatz)
let chat
let n = 9999999
chatz && chatz.forEach(c=>{
if(c.contact_ids.length
{!contact.is_owner &&
{pay &&
setPay(false)}>x
}
{pay &&
setAmount(e.target.value)}
/>}
}
}