DeveloperOptions.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <SmartModal
  3. v-if="show"
  4. dialog
  5. :title="t('app.developer_option')"
  6. @close="hideModal"
  7. >
  8. <template #body>
  9. <p class="px-2 mb-8 text-secondaryLight">
  10. {{ t("app.developer_option_description") }}
  11. </p>
  12. <div class="flex flex-1">
  13. <button class="share-link" @click="copyUserAuthToken">
  14. <SmartIcon class="w-4 h-4 text-xl" :name="copyIcon" />
  15. <span>
  16. {{ t("app.copy_user_id") }}
  17. </span>
  18. </button>
  19. </div>
  20. </template>
  21. </SmartModal>
  22. </template>
  23. <script setup lang="ts">
  24. import { refAutoReset } from "@vueuse/core"
  25. import { copyToClipboard } from "~/helpers/utils/clipboard"
  26. import {
  27. useI18n,
  28. useToast,
  29. useReadonlyStream,
  30. } from "~/helpers/utils/composables"
  31. import { authIdToken$ } from "~/helpers/fb/auth"
  32. const userAuthToken = useReadonlyStream(authIdToken$, null)
  33. const t = useI18n()
  34. const toast = useToast()
  35. defineProps<{
  36. show: Boolean
  37. }>()
  38. const emit = defineEmits<{
  39. (e: "hide-modal"): void
  40. }>()
  41. const copyIcon = refAutoReset<"copy" | "check">("copy", 1000)
  42. // Copy user auth token to clipboard
  43. const copyUserAuthToken = () => {
  44. if (userAuthToken.value) {
  45. copyToClipboard(userAuthToken.value)
  46. copyIcon.value = "check"
  47. toast.success(`${t("state.copied_to_clipboard")}`)
  48. } else {
  49. toast.error(`${t("error.something_went_wrong")}`)
  50. }
  51. }
  52. const hideModal = () => {
  53. emit("hide-modal")
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .share-link {
  58. @apply border border-dividerLight;
  59. @apply rounded;
  60. @apply flex;
  61. @apply p-3;
  62. @apply items-center;
  63. @apply justify-center;
  64. @apply font-semibold;
  65. @apply hover:(bg-primaryLight text-secondaryDark);
  66. @apply focus:outline-none;
  67. @apply focus-visible:border-divider;
  68. svg {
  69. @apply opacity-80;
  70. @apply mr-2;
  71. }
  72. &:hover {
  73. svg {
  74. @apply opacity-100;
  75. }
  76. }
  77. }
  78. </style>