Skip to content

Commit

Permalink
Refactor from Date to moment and fix autocomplete component
Browse files Browse the repository at this point in the history
  • Loading branch information
joanagmaia committed Jul 11, 2023
1 parent 7eab972 commit 44c36db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
:create-fn="createOrganizationFn"
placeholder="Select or create an organization"
input-class="organization-input"
store-key="memberOrganizations"
:create-if-not-found="true"
:in-memory-filter="false"
:clearable="false"
Expand Down Expand Up @@ -131,6 +132,7 @@ import { OrganizationService } from '@/modules/organization/organization-service
import AppAvatar from '@/shared/avatar/avatar.vue';
import { Member } from '@/modules/member/types/Member';
import { Organization } from '@/modules/organization/types/Organization';
import moment from 'moment';
type SelectOrganization = Organization & { label: string };
Expand Down Expand Up @@ -197,7 +199,7 @@ const createOrganizationFn = (value: string) => OrganizationService.create({
const onDatePickerChange = (key: 'dateStart' | 'dateEnd', value: Date, index: number) => {
if (value) {
const timezoneOffsetMinutes = value.getTimezoneOffset();
const date = new Date(value.getTime() - (timezoneOffsetMinutes * 60 * 1000)).toISOString();
const date = moment(value.getTime() - (timezoneOffsetMinutes * 60 * 1000)).toISOString();
organizations.value[index].memberOrganizations[key] = date;
} else {
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/shared/form/autocomplete-one-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export default {
type: Boolean,
default: true,
},
storeKey: {
type: String,
default: null,
},
},
emits: ['update:modelValue'],
data() {
Expand Down Expand Up @@ -174,7 +178,12 @@ export default {
this.localOptions.push(newItem);
this.$emit('update:modelValue', newItem);
} else {
this.$emit('update:modelValue', value || null);
this.$emit('update:modelValue', {
...value,
...this.storeKey && {
[this.storeKey]: this.modelValue[this.storeKey],
},
} || null);
}
},
Expand Down

0 comments on commit 44c36db

Please sign in to comment.