Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #269 from tiki/feat/publish-service
Browse files Browse the repository at this point in the history
Feat/publish service
  • Loading branch information
mike-audi authored Oct 2, 2023
2 parents af73502 + ad33488 commit deb8881
Show file tree
Hide file tree
Showing 22 changed files with 284 additions and 221 deletions.
106 changes: 53 additions & 53 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@capacitor/core": "^5.4.1",
"@capacitor/ios": "^5.4.1",
"@mytiki/capture-receipt-capacitor": "^0.6.0",
"@mytiki/tiki-receipt-capacitor": "file:../",
"@mytiki/receipt-capacitor": "file:../",
"@mytiki/tiki-sdk-capacitor": "^0.3.1",
"@capacitor/preferences": "^5.0.6",
"uuid": "^9.0.0",
Expand Down
60 changes: 53 additions & 7 deletions example/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,44 @@
-->

<script setup lang="ts">
import { Preferences } from "@capacitor/preferences";
import { inject, ref } from "vue";
import { TikiReceipt } from "@mytiki/tiki-receipt-capacitor";
import type { TikiService } from "@mytiki/tiki-receipt-capacitor";
import { TikiReceipt } from "@mytiki/receipt-capacitor";
import type { TikiService } from "@mytiki/receipt-capacitor";
import { v4 as uuidv4 } from "uuid";

const userKey = "tiki-receipt-capacitor-example.id";
const tiki: TikiService | undefined = inject("Tiki");
const id: string = uuidv4();
tiki?.initialize().then(() => console.log("ok. lets go"));
//.then(() => tiki?.logout());

const loadUser = async (): Promise<string> => {
const { value } = await Preferences.get({ key: userKey });
if (!value) {
const id = uuidv4();
await Preferences.set({ key: userKey, value: id });
return id;
} else {
return value;
}
};

const id = ref<string>("");
loadUser().then((user) => {
id.value = user;
tiki
?.initialize(id.value)
.then(() => console.log("Initialization complete."));
});
const present = ref(false);

const cycle = async () => {
await tiki!.logout().then(async () => {
await Preferences.remove({ key: userKey });
id.value = await loadUser();
tiki
?.initialize(id.value)
.then(() => console.log("Initialization complete."));
});
};
</script>

<template>
Expand All @@ -30,10 +58,13 @@ const present = ref(false);
<main>
<div class="greetings">
<h1>Oh, Hi!</h1>
<p><b>ID: </b>{{ id }}</p>
<h3>Just click &ldquo;start&rdquo; to well...</h3>
</div>
<button class="start" @click="present = !present">start</button>
<div class="cycle">
<p><b>ID: </b>{{ id }}</p>
<button class="newUser" @click="cycle">new user</button>
</div>
<tiki-receipt v-model:present="present" />
</main>
</template>
Expand All @@ -49,8 +80,11 @@ header {
}

.start {
width: fit-content;
margin: 2em auto;
}

button {
width: fit-content;
display: block;
padding: 0.5em 2em;
border: #00b272 solid 1px;
Expand Down Expand Up @@ -83,4 +117,16 @@ header {
.greetings p {
text-align: center;
}

.cycle {
position: absolute;
bottom: 10%;
left: 50%;
transform: translateX(-50%);
text-align: center;
}

.newUser {
margin: auto;
}
</style>
2 changes: 1 addition & 1 deletion example/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* MIT license. See LICENSE file in root directory.
*/

@import "@mytiki/tiki-receipt-capacitor/dist/tiki-receipt-capacitor.css";
@import "@mytiki/receipt-capacitor/dist/receipt-capacitor.css";

#app {
margin: 0 auto;
Expand Down
2 changes: 1 addition & 1 deletion example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./assets/main.css";

import { createApp } from "vue";
import App from "@/app.vue";
import Tiki from "@mytiki/tiki-receipt-capacitor";
import Tiki from "@mytiki/receipt-capacitor";
import Vue3TouchEvents from "vue3-touch-events";

createApp(App)
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@mytiki/tiki-receipt-capacitor",
"name": "@mytiki/receipt-capacitor",
"version": "0.3.0",
"description": "The TIKI Receipt library adds to your Vue.js + Capacitor mobile app a Data Reward program for your users to share their receipts in-exchange for loyalty points.",
"author": "Tiki inc.",
Expand All @@ -14,15 +14,15 @@
"files": [
"dist"
],
"module": "./dist/tiki-receipt-capacitor.es.js",
"main": "./dist/tiki-receipt-capacitor.umd.js",
"module": "./dist/receipt-capacitor.es.js",
"main": "./dist/receipt-capacitor.umd.js",
"typings": "./dist/types/main.d.ts",
"exports": {
".": {
"types": "./dist/types/main.d.ts",
"import": "./dist/tiki-receipt-capacitor.es.js"
"import": "./dist/receipt-capacitor.es.js"
},
"./dist/tiki-receipt-capacitor.css": "./dist/tiki-receipt-capacitor.css"
"./dist/receipt-capacitor.css": "./dist/receipt-capacitor.css"
},
"scripts": {
"build": "rimraf dist && vue-tsc --declaration --emitDeclarationOnly; vite build",
Expand Down
1 change: 1 addition & 0 deletions src/components/sheet/sheet-add-gmail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const canSubmit = computed(
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: GMAIL };
emit("back");
Expand Down
Loading

0 comments on commit deb8881

Please sign in to comment.