fix: text copy fields

This commit is contained in:
Julian Krauser 2025-01-09 12:48:09 +01:00
parent c83b4670cc
commit 9215ac6fd8
5 changed files with 8 additions and 49 deletions

View file

@ -80,15 +80,13 @@ export default defineComponent({
this.createInvite(createInvite) this.createInvite(createInvite)
.then((result) => { .then((result) => {
this.status = { status: "success" }; this.status = { status: "success" };
setTimeout(() => {
this.closeModal();
}, 2000);
}) })
.catch((err) => { .catch((err) => {
this.status = { status: "failed", reason: err.response.data }; this.status = { status: "failed", reason: err.response.data };
}) })
.finally(() => {
setTimeout(() => {
this.closeModal();
}, 2000);
});
}, },
}, },
}); });

View file

@ -10,16 +10,7 @@
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<img :src="image" alt="totp" class="w-56 h-56 self-center" /> <img :src="image" alt="totp" class="w-56 h-56 self-center" />
<div class="flex relative"> <TextCopy :copyText="otp" />
<input type="text" :value="otp" />
<ClipboardIcon
class="w-5 h-5 p-2 box-content absolute right-1 top-1/2 -translate-y-1/2 bg-white cursor-pointer"
@click="copyToClipboard"
/>
<div v-if="copySuccess" class="absolute w-5 h-5 right-3 top-[10px]">
<SuccessCheckmark />
</div>
</div>
</div> </div>
<form class="flex flex-col gap-2" @submit.prevent="verify"> <form class="flex flex-col gap-2" @submit.prevent="verify">
<div class="-space-y-px"> <div class="-space-y-px">
@ -44,13 +35,13 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineComponent, markRaw, defineAsyncComponent } from "vue"; import { defineComponent } from "vue";
import { mapActions, mapState } from "pinia"; import { mapActions, mapState } from "pinia";
import MainTemplate from "@/templates/Main.vue"; import MainTemplate from "@/templates/Main.vue";
import Spinner from "@/components/Spinner.vue"; import Spinner from "@/components/Spinner.vue";
import SuccessCheckmark from "@/components/SuccessCheckmark.vue"; import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
import FailureXMark from "@/components/FailureXMark.vue"; import FailureXMark from "@/components/FailureXMark.vue";
import { ClipboardIcon } from "@heroicons/vue/24/outline"; import TextCopy from "@/components/TextCopy.vue";
</script> </script>
<script lang="ts"> <script lang="ts">
@ -62,8 +53,6 @@ export default defineComponent({
otp: undefined as undefined | string, otp: undefined as undefined | string,
verifyStatus: undefined as undefined | "loading" | "success" | "failed", verifyStatus: undefined as undefined | "loading" | "success" | "failed",
verifyError: "" as string, verifyError: "" as string,
copySuccess: false,
timeoutCopy: undefined as any,
}; };
}, },
mounted() { mounted() {
@ -100,13 +89,6 @@ export default defineComponent({
}, 2000); }, 2000);
}); });
}, },
copyToClipboard() {
navigator.clipboard.writeText(this.otp ?? "");
this.copySuccess = true;
this.timeoutCopy = setTimeout(() => {
this.copySuccess = false;
}, 2000);
},
}, },
}); });
</script> </script>

View file

@ -47,8 +47,6 @@ import { defineComponent } from "vue";
import Spinner from "@/components/Spinner.vue"; import Spinner from "@/components/Spinner.vue";
import SuccessCheckmark from "@/components/SuccessCheckmark.vue"; import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
import FailureXMark from "@/components/FailureXMark.vue"; import FailureXMark from "@/components/FailureXMark.vue";
import { RouterLink } from "vue-router";
import { ClipboardIcon } from "@heroicons/vue/24/outline";
import FormBottomBar from "@/components/FormBottomBar.vue"; import FormBottomBar from "@/components/FormBottomBar.vue";
import TextCopy from "@/components/TextCopy.vue"; import TextCopy from "@/components/TextCopy.vue";
</script> </script>

View file

@ -47,7 +47,6 @@ import Spinner from "@/components/Spinner.vue";
import SuccessCheckmark from "@/components/SuccessCheckmark.vue"; import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
import FailureXMark from "@/components/FailureXMark.vue"; import FailureXMark from "@/components/FailureXMark.vue";
import { RouterLink } from "vue-router"; import { RouterLink } from "vue-router";
import { ClipboardIcon } from "@heroicons/vue/24/outline";
import FormBottomBar from "@/components/FormBottomBar.vue"; import FormBottomBar from "@/components/FormBottomBar.vue";
import TextCopy from "@/components/TextCopy.vue"; import TextCopy from "@/components/TextCopy.vue";
</script> </script>

View file

@ -17,16 +17,7 @@
<form v-else class="flex flex-col gap-2" @submit.prevent="setup"> <form v-else class="flex flex-col gap-2" @submit.prevent="setup">
<img :src="image" alt="totp" class="w-56 h-56 self-center" /> <img :src="image" alt="totp" class="w-56 h-56 self-center" />
<div class="flex relative"> <TextCopy :copyText="otp" />
<input type="text" :value="otp" />
<ClipboardIcon
class="w-5 h-5 p-2 box-content absolute right-1 top-1/2 -translate-y-1/2 bg-white cursor-pointer"
@click="copyToClipboard"
/>
<div v-if="copySuccess" class="absolute w-5 h-5 right-3 top-[10px]">
<SuccessCheckmark />
</div>
</div>
<div class="-space-y-px"> <div class="-space-y-px">
<div> <div>
@ -57,8 +48,8 @@ import Spinner from "@/components/Spinner.vue";
import SuccessCheckmark from "@/components/SuccessCheckmark.vue"; import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
import FailureXMark from "@/components/FailureXMark.vue"; import FailureXMark from "@/components/FailureXMark.vue";
import { RouterLink } from "vue-router"; import { RouterLink } from "vue-router";
import { ClipboardIcon } from "@heroicons/vue/24/outline";
import FormBottomBar from "@/components/FormBottomBar.vue"; import FormBottomBar from "@/components/FormBottomBar.vue";
import TextCopy from "@/components/TextCopy.vue";
</script> </script>
<script lang="ts"> <script lang="ts">
@ -74,8 +65,6 @@ export default defineComponent({
otp: undefined as undefined | string, otp: undefined as undefined | string,
setupStatus: undefined as undefined | "loading" | "success" | "failed", setupStatus: undefined as undefined | "loading" | "success" | "failed",
setupError: "" as string, setupError: "" as string,
copySuccess: false,
timputCopy: undefined as any,
}; };
}, },
mounted() { mounted() {
@ -121,13 +110,6 @@ export default defineComponent({
this.setupError = err.response.data; this.setupError = err.response.data;
}); });
}, },
copyToClipboard() {
navigator.clipboard.writeText(this.otp ?? "");
this.copySuccess = true;
this.timputCopy = setTimeout(() => {
this.copySuccess = false;
}, 2000);
},
}, },
}); });
</script> </script>