PunishmentItem.vue 2.9 KB

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