2
0

PunishmentItem.vue 2.8 KB

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