Skip to content

Commit

Permalink
Merge pull request #255 from traPtitech/feat/sort-members
Browse files Browse the repository at this point in the history
プロジェクトメンバーを加入日昇順にソート
  • Loading branch information
ogu-kazemiya authored Dec 5, 2024
2 parents e0d920c + c25f81c commit fd184dc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/Project/MemberList.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts" setup>
import { computed } from 'vue'
import MemberListItem from './MemberListItem.vue'
import { ProjectMember } from '/@/lib/apis'
import SectionTitle from '/@/components/Layout/SectionTitle.vue'
Expand All @@ -7,15 +8,28 @@ interface Props {
members: ProjectMember[]
}
defineProps<Props>()
const props = defineProps<Props>()
const sortedMembers = computed(() => {
if (!props.members) return []
const li = props.members
li.sort((a, b) => {
if (a.duration.since.year !== b.duration.since.year) {
return a.duration.since.year - b.duration.since.year
} else {
return a.duration.since.semester - b.duration.since.semester
}
})
return li
})
</script>

<template>
<section :class="$style.section">
<section-title>プロジェクトメンバー</section-title>
<ul :class="$style.container">
<member-list-item
v-for="member in members"
v-for="member in sortedMembers"
:key="member.id"
:member="member"
/>
Expand Down

0 comments on commit fd184dc

Please sign in to comment.