DeveloperOptions.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 { ref } from "@nuxtjs/composition-api"
  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 = ref("copy")
  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. setTimeout(() => (copyIcon.value = "copy"), 1000)
  49. } else {
  50. toast.error(`${t("error.something_went_wrong")}`)
  51. }
  52. }
  53. const hideModal = () => {
  54. emit("hide-modal")
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .share-link {
  59. @apply border border-dividerLight;
  60. @apply rounded;
  61. @apply flex;
  62. @apply p-3;
  63. @apply items-center;
  64. @apply justify-center;
  65. @apply font-semibold;
  66. @apply hover:(bg-primaryLight text-secondaryDark);
  67. @apply focus:outline-none;
  68. @apply focus-visible:border-divider;
  69. svg {
  70. @apply opacity-80;
  71. @apply mr-2;
  72. }
  73. &:hover {
  74. svg {
  75. @apply opacity-100;
  76. }
  77. }
  78. }
  79. </style>