ViewPunishment.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div>
  3. <modal title="View Punishment">
  4. <div slot="body">
  5. <article class="message">
  6. <div class="message-body">
  7. <strong>Type:</strong>
  8. {{ punishment.type }}
  9. <br />
  10. <strong>Value:</strong>
  11. {{ punishment.value }}
  12. <br />
  13. <strong>Reason:</strong>
  14. {{ punishment.reason }}
  15. <br />
  16. <strong>Active:</strong>
  17. {{ punishment.active }}
  18. <br />
  19. <strong>Expires at:</strong>
  20. {{
  21. format(
  22. parseISO(punishment.expiresAt),
  23. "MMMM do yyyy, h:mm:ss a"
  24. )
  25. }}
  26. ({{
  27. formatDistance(
  28. parseISO(punishment.expiresAt),
  29. new Date(),
  30. { addSuffix: true }
  31. )
  32. }})
  33. <br />
  34. <strong>Punished at:</strong>
  35. {{
  36. format(
  37. parseISO(punishment.punishedAt),
  38. "MMMM do yyyy, h:mm:ss a"
  39. )
  40. }}
  41. ({{
  42. formatDistance(
  43. parseISO(punishment.punishedAt),
  44. new Date(),
  45. { addSuffix: true }
  46. )
  47. }})
  48. <br />
  49. <strong>Punished by:</strong>
  50. <user-id-to-username
  51. :userId="punishment.punishedBy"
  52. :alt="punishment.punishedBy"
  53. />
  54. <br />
  55. </div>
  56. </article>
  57. </div>
  58. <div slot="footer">
  59. <button
  60. class="button is-danger"
  61. @click="
  62. closeModal({
  63. sector: 'admin',
  64. modal: 'viewPunishment'
  65. })
  66. "
  67. >
  68. <span>&nbsp;Close</span>
  69. </button>
  70. </div>
  71. </modal>
  72. </div>
  73. </template>
  74. <script>
  75. import { mapState, mapActions } from "vuex";
  76. import { format, formatDistance, parseISO } from "date-fns"; // eslint-disable-line no-unused-vars
  77. import io from "../../io";
  78. import Modal from "./Modal.vue";
  79. import UserIdToUsername from "../UserIdToUsername.vue";
  80. export default {
  81. components: { Modal, UserIdToUsername },
  82. data() {
  83. return {
  84. ban: {}
  85. };
  86. },
  87. computed: {
  88. ...mapState("admin/punishments", {
  89. punishment: state => state.punishment
  90. })
  91. },
  92. mounted() {
  93. io.getSocket(socket => {
  94. this.socket = socket;
  95. return socket;
  96. });
  97. },
  98. methods: {
  99. ...mapActions("modals", ["closeModal"]),
  100. format,
  101. formatDistance,
  102. parseISO
  103. }
  104. };
  105. </script>