PunishmentItem.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. import UserIdToUsername from "@/components/UserIdToUsername.vue";
  75. export default {
  76. components: { UserIdToUsername },
  77. props: {
  78. punishment: { type: Object, default: () => {} }
  79. },
  80. data() {
  81. return {
  82. active: false
  83. };
  84. },
  85. watch: {
  86. punishment(punishment) {
  87. this.active =
  88. punishment.active &&
  89. new Date(this.punishment.expiresAt).getTime() > Date.now();
  90. }
  91. },
  92. methods: {
  93. formatDistance,
  94. format,
  95. parseISO,
  96. ...mapActions("modalVisibility", ["closeModal"])
  97. }
  98. };
  99. </script>
  100. <style lang="less" scoped>
  101. .night-mode {
  102. .punishment-item {
  103. background-color: var(--dark-grey-2) !important;
  104. border: 0 !important;
  105. }
  106. }
  107. .punishment-item {
  108. padding: 15px;
  109. justify-content: flex-start;
  110. .item-icon {
  111. min-width: 85px;
  112. max-width: 85px;
  113. height: 85px;
  114. margin-left: 20px;
  115. margin-right: 35px;
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. justify-content: space-evenly;
  120. border: 1px solid var(--light-grey-3);
  121. border-radius: @border-radius;
  122. .checkbox-control .slider {
  123. cursor: default;
  124. }
  125. }
  126. .item-title {
  127. font-size: 19px;
  128. margin: 0;
  129. }
  130. .item-title-2 {
  131. font-size: 17px;
  132. margin: 0;
  133. }
  134. ul {
  135. list-style: inside;
  136. margin-top: 10px;
  137. .item-description {
  138. font-size: 14px;
  139. margin: 0;
  140. }
  141. }
  142. }
  143. </style>