diff --git a/example/package-lock.json b/example/package-lock.json index f9f38a3c..9f8a660e 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -40,6 +40,7 @@ } }, "..": { + "name": "@mytiki/tiki-receipt-capacitor", "version": "0.3.0", "license": "MIT", "dependencies": { diff --git a/src/components/sheet/sheet-add-retailer.vue b/src/components/sheet/sheet-add-retailer.vue index cc57d754..37430bba 100644 --- a/src/components/sheet/sheet-add-retailer.vue +++ b/src/components/sheet/sheet-add-retailer.vue @@ -9,25 +9,33 @@ import AccountForm from "../account/account-form.vue"; import HeaderBack from "@/components/header/header-back.vue"; import TextButton from "@/components/button/button-text.vue"; import { type Account, AMAZON } from "@mytiki/capture-receipt-capacitor"; -import { ref } from "vue"; +import type { TikiService } from "@/service"; +import { ref, inject, computed } from "vue"; +import { ButtonTextState } from "@/components/button/button-text-state"; + +const emit = defineEmits(["close", "back"]); +const tiki: TikiService | undefined = inject("Tiki"); -defineEmits(["close", "back"]); const form = ref({ username: "", password: "", type: AMAZON }); const error = ref(); -const submit = async () => { - if ( +const canSubmit = computed( + () => form.value.username != undefined && form.value.password != undefined && form.value.username?.length > 0 && - form.value.password?.length > 0 - ) { - try { - error.value = ""; - form.value = { username: "", password: "", type: AMAZON }; - } catch (err: any) { - error.value = err.toString(); - } + form.value.password?.length > 0, +); + +const submit = async () => { + try { + await tiki!.capture.login(form.value); + tiki!.capture.scan().catch((error) => console.error(error.toString())); + error.value = ""; + form.value = { username: "", password: "", type: AMAZON }; + emit("back"); + } catch (err: any) { + error.value = err.toString(); } }; @@ -44,5 +52,9 @@ const submit = async () => { :error="error" :account-type="form.type" /> - +