Skip to content
Snippets Groups Projects
Commit d193bca0 authored by Yoan Vallet's avatar Yoan Vallet
Browse files

feat: add updateAccount service

parent abde7f40
No related branches found
No related tags found
3 merge requests!28Merge fix from dev,!27Dev,!25Features/us150 review of konnectors
......@@ -8,6 +8,7 @@ import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton'
import StyledButton from 'components/CommonKit/Button/StyledButton'
import TrailingIcon from 'assets/icons/ico/trailing-icon.svg'
import { ConnectionService } from 'services/connectionService'
import updateAccount from 'services/accountService'
import { Account, Trigger } from 'doctypes'
interface KonnectorLoginFormProps {
......@@ -65,7 +66,14 @@ const KonnectorLoginForm: React.FC<KonnectorLoginFormProps> = ({
const update = async () => {
// TODO - update account
onSuccess(account, trigger)
console.log('Update')
const auth = {
login: login,
password: password,
}
account.auth = auth
const updatedAccount = updateAccount(client, account)
onSuccess(updatedAccount, trigger)
}
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
......
......@@ -94,9 +94,9 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({
setLaunch(true)
}
const handleKonnectorLaunch = () => {
const handleKonnectorLaunch = async () => {
if (trigger) {
updateState(trigger)
await updateState(trigger)
}
setLaunch(false)
}
......
export const ACCOUNTS_DOCTYPE = 'io.cozy.accounts'
type AuthLoginData = {
credentials_encrypted: string
credentials_encrypted?: string
login: string
password?: string
}
type OAuthData = {
......
......@@ -98,6 +98,17 @@ export class AccountService {
}
}
static updateAccount = async (client: Client, account: Account) => {
try {
const updatedAccount: Account = await accountsMutations(
client
).updateAccount(account)
return updatedAccount
} catch (error) {
throw error
}
}
static getAccountByType = async (client: Client, type: string) => {
try {
const query = client
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment