Skip to content

Commit 490be72

Browse files
authored
Merge branch 'main' into fix-member-merge
2 parents 7cc3fef + 3e74e37 commit 490be72

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

frontend/src/modules/contributor/components/shared/contributor-work-position.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { storeToRefs } from 'pinia';
4141
import LfAvatar from '@/ui-kit/avatar/Avatar.vue';
4242
import LfIcon from '@/ui-kit/icon/Icon.vue';
4343
import { Contributor } from '@/modules/contributor/types/Contributor';
44+
import useContributorHelpers from '@/modules/contributor/helpers/contributor.helpers';
4445
4546
const props = defineProps<{
4647
contributor: Contributor,
@@ -49,7 +50,9 @@ const props = defineProps<{
4950
const lsSegmentsStore = useLfSegmentsStore();
5051
const { selectedProjectGroup } = storeToRefs(lsSegmentsStore);
5152
52-
const organization = computed(() => props.contributor.organizations?.[0]);
53+
const { activeOrganization } = useContributorHelpers();
54+
55+
const organization = computed(() => activeOrganization(props.contributor));
5356
const jobTitle = computed(() => organization.value?.memberOrganizations?.title
5457
|| props.contributor.attributes?.jobTitle?.default);
5558
</script>

frontend/src/modules/contributor/helpers/contributor.helpers.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,15 @@ const useContributorHelpers = () => {
6666
}));
6767
};
6868

69-
const activeOrganization = (contributor: Contributor) => contributor.organizations?.[0];
69+
const activeOrganization = (contributor: Contributor) => {
70+
const { organizations } = contributor;
71+
console.log(organizations);
72+
return organizations.find((org) => org.memberOrganizations.affiliationOverride?.isPrimaryWorkExperience
73+
&& !!org.memberOrganizations.dateStart
74+
&& !org.memberOrganizations.dateEnd)
75+
|| organizations.find((org) => !!org.memberOrganizations.dateStart && !org.memberOrganizations.dateEnd)
76+
|| organizations.find((org) => !org.memberOrganizations.dateStart && !org.memberOrganizations.dateEnd) || null;
77+
};
7078

7179
return {
7280
avatar,

frontend/src/modules/member/components/member-organizations-vertical.vue

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import { computed } from 'vue';
9494
import pluralize from 'pluralize';
9595
import LfOrganizationLfMemberTag from '@/modules/organization/components/lf-member/organization-lf-member-tag.vue';
9696
import LfIcon from '@/ui-kit/icon/Icon.vue';
97+
import useContributorHelpers from '@/modules/contributor/helpers/contributor.helpers';
9798
9899
const props = defineProps({
99100
member: {
@@ -104,21 +105,11 @@ const props = defineProps({
104105
105106
const lsSegmentsStore = useLfSegmentsStore();
106107
const { selectedProjectGroup } = storeToRefs(lsSegmentsStore);
108+
const { activeOrganization } = useContributorHelpers();
107109
108110
const currentOrganizations = computed(() => {
109-
const orgsWithNoEndDate = props.member.organizations
110-
.filter((o) => o.memberOrganizations?.dateStart && !o.memberOrganizations?.dateEnd);
111-
112-
// If there are organizations with no endDate
113-
if (orgsWithNoEndDate.length) {
114-
// Sort by startDate descending and pick the most recent one
115-
return [orgsWithNoEndDate.sort(
116-
(firstOrg, secondaryOrg) => new Date(secondaryOrg.memberOrganizations?.dateStart) - new Date(firstOrg.memberOrganizations?.dateStart),
117-
)[0]];
118-
}
119-
120-
// If there are no organizations with only startDate, return all with startDate and endDate
121-
return props.member.organizations.filter((o) => !o.memberOrganizations?.dateEnd);
111+
const active = activeOrganization(props.member);
112+
return active ? [active] : [];
122113
});
123114
124115
const slicedOrganizations = computed(() => currentOrganizations.value.slice(0, 3));

0 commit comments

Comments
 (0)