The frontend component of PuffPastry, meant to interface with the backend, which in turn interfaces with the smart contract.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

VotingControls.vue 2.2 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div class="flex flex-row justify-around">
  3. <div>
  4. <Confirm
  5. :width="24" :height="24" :box="96"
  6. class="inline-block fill-gray-50 hover:fill-green-500 cursor-pointer mx-2"
  7. :class="{'fill-green-500': vote === 'Positive'}"
  8. @click="recordAccept"
  9. />
  10. <span class="text-white align-bottom font-poppins hidden sm:inline-block">Approve</span>
  11. </div>
  12. <div>
  13. <Cancel
  14. :width="24" :height="24" :box="96"
  15. class="inline-block fill-gray-50 hover:fill-red-500 cursor-pointer mx-2"
  16. :class="{'fill-red-500': vote === 'Negative'}"
  17. @click="recordDecline"
  18. />
  19. <span class="text-white align-bottom font-poppins hidden sm:inline-block">Reject</span>
  20. </div>
  21. <div>
  22. <Abstain
  23. :width="24" :height="24" :box="96"
  24. class="inline-block fill-gray-50 hover:fill-amber-500 cursor-pointer mx-2"
  25. @click="recordAbstain"
  26. />
  27. <span class="text-white align-bottom font-poppins hidden sm:inline-block">Abstain</span>
  28. </div>
  29. </div>
  30. </template>
  31. <script setup lang="ts">
  32. import {VoteIssueRequest, VoteIssueResponse} from "../types/issue.ts";
  33. import Cancel from "./icons/Cancel.vue";
  34. import Confirm from "./icons/Confirm.vue";
  35. import freighter from "@stellar/freighter-api";
  36. import Abstain from "./icons/Abstain.vue";
  37. const props = defineProps<{ selectedId: string, vote?: 'Positive' | 'Negative' }>();
  38. const recordAccept = async () => {
  39. if (!props.selectedId) return;
  40. const addr = await freighter.getAddress();
  41. // TODO: replace this call
  42. await post<VoteIssueRequest, VoteIssueResponse>('/issues/vote',
  43. { issue_id: props.selectedId.toString(), wallet: addr.address, vote: "Positive" })
  44. }
  45. const recordDecline = async () => {
  46. if (!props.selectedId) return;
  47. const addr = await freighter.getAddress();
  48. // TODO: replace this call
  49. await post<VoteIssueRequest, VoteIssueResponse>('/issues/vote',
  50. { issue_id: props.selectedId, wallet: addr.address, vote: "Negative" })
  51. }
  52. const recordAbstain = async () => {
  53. if (!props.selectedId) return;
  54. const addr = await freighter.getAddress();
  55. }
  56. </script>
  57. <style lang="postcss">
  58. .font-poppins {
  59. font-family: 'Poppins', sans-serif;
  60. }
  61. </style>