PunishmentItem.vue 2.7 KB

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