-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from boostcampwm2023/feature/update-member-st…
…atus fix: 처음 접속 시 서버에서 보내준 상태 반영, 여러 탭 사용 시 수동 자리비움 상태 변경 동작 모두 적용
- Loading branch information
Showing
8 changed files
with
95 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const STORAGE_KEY = { | ||
MEMBER: "member", | ||
REDIRECT: "redirect", | ||
UPDATE_STATUS_WITH_INTENTION: "updateStatusWithIntention", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { LandingMemberDTO } from "../types/DTO/landingDTO"; | ||
import sortMemberByStatus from "../utils/sortMemberByStatus"; | ||
|
||
describe("sortMemberByStatus test", () => { | ||
it("on, away, off 순 정렬 테스트", () => { | ||
const memberList: LandingMemberDTO[] = [ | ||
{ id: 1, username: "", imageUrl: "", status: "off" }, | ||
{ id: 2, username: "", imageUrl: "", status: "on" }, | ||
{ id: 3, username: "", imageUrl: "", status: "away" }, | ||
{ id: 4, username: "", imageUrl: "", status: "on" }, | ||
{ id: 5, username: "", imageUrl: "", status: "off" }, | ||
{ id: 6, username: "", imageUrl: "", status: "away" }, | ||
]; | ||
|
||
const sortedMemberIdList = memberList | ||
.sort(sortMemberByStatus) | ||
.map(({ id }) => id); | ||
expect(sortedMemberIdList).toStrictEqual([2, 4, 3, 6, 1, 5]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { LandingMemberDTO, MemberStatus } from "../types/DTO/landingDTO"; | ||
|
||
const getStatusOrder = (status: MemberStatus) => { | ||
if (status === "on") { | ||
return 2; | ||
} | ||
|
||
if (status === "away") { | ||
return 1; | ||
} | ||
|
||
return 0; | ||
}; | ||
|
||
const sortMemberByStatus = ( | ||
member1: LandingMemberDTO, | ||
member2: LandingMemberDTO | ||
) => { | ||
const member1Status = getStatusOrder(member1.status); | ||
const member2Status = getStatusOrder(member2.status); | ||
if (member1Status > member2Status) { | ||
return -1; | ||
} | ||
|
||
if (member1Status < member2Status) { | ||
return 1; | ||
} | ||
|
||
return 0; | ||
}; | ||
|
||
export default sortMemberByStatus; |