PunishmentItem.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="universal-item punishment-item">
  3. <div class="item-icon">
  4. <p class="is-expanded checkbox-control">
  5. <label class="switch">
  6. <input type="checkbox" v-model="active" disabled />
  7. <span class="slider round"></span>
  8. </label>
  9. </p>
  10. <p>
  11. <strong>{{ active ? "Active" : "Inactive" }}</strong>
  12. </p>
  13. </div>
  14. <div class="item-title-description">
  15. <h2 v-if="punishment.type === 'banUserId'" class="item-title">
  16. <strong>Punishment</strong> for user
  17. <user-link
  18. :user-id="punishment.value"
  19. :alt="punishment.value"
  20. />
  21. </h2>
  22. <h2 class="item-title" v-else>
  23. <strong>Punishment</strong> for IP
  24. {{ punishment.value }}
  25. </h2>
  26. <h3 class="item-title-2">Reason: {{ punishment.reason }}</h3>
  27. <ul>
  28. <li class="item-description" :title="punishment.expiresAt">
  29. Expires
  30. {{
  31. formatDistance(
  32. parseISO(punishment.expiresAt),
  33. new Date(),
  34. { addSuffix: true }
  35. )
  36. }}
  37. ({{
  38. format(
  39. parseISO(punishment.expiresAt),
  40. "MMMM do yyyy, h:mm:ss a"
  41. )
  42. }})
  43. </li>
  44. <li class="item-description">
  45. Punished by
  46. <user-link
  47. :user-id="punishment.punishedBy"
  48. :alt="punishment.punishedBy"
  49. />
  50. <span :title="punishment.punishedAt">
  51. &nbsp;{{
  52. formatDistance(
  53. parseISO(punishment.punishedAt),
  54. new Date(),
  55. { addSuffix: true }
  56. )
  57. }}
  58. ({{
  59. format(
  60. parseISO(punishment.punishedAt),
  61. "MMMM do yyyy, h:mm:ss a"
  62. )
  63. }})
  64. </span>
  65. </li>
  66. </ul>
  67. </div>
  68. </div>
  69. </template>
  70. <script>
  71. import { mapActions } from "vuex";
  72. import { format, formatDistance, parseISO } from "date-fns";
  73. export default {
  74. props: {
  75. punishment: { type: Object, default: () => {} }
  76. },
  77. data() {
  78. return {
  79. active: false
  80. };
  81. },
  82. watch: {
  83. punishment(punishment) {
  84. this.active =
  85. punishment.active &&
  86. new Date(this.punishment.expiresAt).getTime() > Date.now();
  87. }
  88. },
  89. methods: {
  90. formatDistance,
  91. format,
  92. parseISO,
  93. ...mapActions("modalVisibility", ["closeModal"])
  94. }
  95. };
  96. </script>
  97. <style lang="less" scoped>
  98. .night-mode {
  99. .punishment-item {
  100. background-color: var(--dark-grey-2) !important;
  101. border: 0 !important;
  102. }
  103. }
  104. .punishment-item {
  105. padding: 15px;
  106. justify-content: flex-start;
  107. .item-icon {
  108. min-width: 85px;
  109. max-width: 85px;
  110. height: 85px;
  111. margin-left: 20px;
  112. margin-right: 35px;
  113. display: flex;
  114. flex-direction: column;
  115. align-items: center;
  116. justify-content: space-evenly;
  117. border: 1px solid var(--light-grey-3);
  118. border-radius: @border-radius;
  119. .checkbox-control .slider {
  120. cursor: default;
  121. }
  122. }
  123. .item-title {
  124. font-size: 19px;
  125. margin: 0;
  126. }
  127. .item-title-2 {
  128. font-size: 17px;
  129. margin: 0;
  130. }
  131. ul {
  132. list-style: inside;
  133. margin-top: 10px;
  134. .item-description {
  135. font-size: 14px;
  136. margin: 0;
  137. }
  138. }
  139. }
  140. </style>