mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-17 12:42:15 +01:00
change color palette, change user_id to member_id
This commit is contained in:
@@ -73,8 +73,8 @@ export const useNotificationsStore = defineStore('notifications', () => {
|
||||
);
|
||||
}
|
||||
}
|
||||
throw new Error('Failed to handle API request', { cause: error });
|
||||
}
|
||||
throw new Error('Failed to handle API request');
|
||||
}
|
||||
|
||||
return { addNotification, notifications, handleApiRequestNotifications };
|
||||
|
||||
@@ -4,7 +4,11 @@ import { api } from '../../../openapi.json.client';
|
||||
import type { TimeEntry } from '@/utils/api';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { getCurrentOrganizationId, getCurrentUserId } from '@/utils/useUser';
|
||||
import {
|
||||
getCurrentMembershipId,
|
||||
getCurrentOrganizationId,
|
||||
getCurrentUserId,
|
||||
} from '@/utils/useUser';
|
||||
import { useLocalStorage } from '@vueuse/core';
|
||||
import { useTimeEntriesStore } from '@/utils/useTimeEntries';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
@@ -77,9 +81,9 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
|
||||
}
|
||||
|
||||
async function startTimer() {
|
||||
const user = getCurrentUserId();
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
const membership = getCurrentMembershipId();
|
||||
if (organization && membership) {
|
||||
const startTime =
|
||||
currentTimeEntry.value.start !== ''
|
||||
? currentTimeEntry.value.start
|
||||
@@ -87,7 +91,7 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
|
||||
const response = await handleApiRequestNotifications(
|
||||
api.createTimeEntry(
|
||||
{
|
||||
user_id: user,
|
||||
member_id: membership,
|
||||
start: startTime,
|
||||
description: currentTimeEntry.value?.description,
|
||||
project_id: currentTimeEntry.value?.project_id,
|
||||
|
||||
@@ -33,7 +33,7 @@ export const useMembersStore = defineStore('members', () => {
|
||||
{
|
||||
params: {
|
||||
organization: organization,
|
||||
membership: membershipId,
|
||||
member: membershipId,
|
||||
},
|
||||
}
|
||||
),
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { getCurrentOrganizationId, getCurrentUserId } from '@/utils/useUser';
|
||||
import {
|
||||
getCurrentMembershipId,
|
||||
getCurrentOrganizationId,
|
||||
} from '@/utils/useUser';
|
||||
import { api } from '../../../openapi.json.client';
|
||||
import { reactive, ref } from 'vue';
|
||||
import type { CreateTimeEntryBody, TimeEntry } from '@/utils/api';
|
||||
import dayjs from 'dayjs';
|
||||
import { useNotificationsStore } from '@/utils/notification';
|
||||
|
||||
export type TimeEntriesGroupedByType = TimeEntry & { timeEntries: TimeEntry[] };
|
||||
|
||||
export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
@@ -12,6 +16,7 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
|
||||
const allTimeEntriesLoaded = ref(false);
|
||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
||||
|
||||
async function fetchTimeEntries() {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
@@ -22,7 +27,7 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
},
|
||||
queries: {
|
||||
only_full_dates: 'true',
|
||||
user_id: getCurrentUserId(),
|
||||
member_id: getCurrentMembershipId(),
|
||||
},
|
||||
}),
|
||||
undefined,
|
||||
@@ -48,7 +53,7 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
},
|
||||
queries: {
|
||||
only_full_dates: 'true',
|
||||
user_id: getCurrentUserId(),
|
||||
member_id: getCurrentMembershipId(),
|
||||
before: dayjs(latestTimeEntry.start).utc().format(),
|
||||
},
|
||||
}),
|
||||
@@ -84,11 +89,18 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function createTimeEntry(timeEntry: CreateTimeEntryBody) {
|
||||
async function createTimeEntry(
|
||||
timeEntry: Omit<CreateTimeEntryBody, 'member_id'>
|
||||
) {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
const memberId = getCurrentMembershipId();
|
||||
if (organizationId && memberId !== undefined) {
|
||||
const newTimeEntry = {
|
||||
...timeEntry,
|
||||
member_id: memberId,
|
||||
} as CreateTimeEntryBody;
|
||||
await handleApiRequestNotifications(
|
||||
api.createTimeEntry(timeEntry, {
|
||||
api.createTimeEntry(newTimeEntry, {
|
||||
params: {
|
||||
organization: organizationId,
|
||||
},
|
||||
|
||||
@@ -18,6 +18,12 @@ function getCurrentOrganizationId() {
|
||||
return page.props.auth.user.current_team_id;
|
||||
}
|
||||
|
||||
function getCurrentMembershipId() {
|
||||
return page.props.auth.user.all_teams.find(
|
||||
(team) => team.id === getCurrentOrganizationId()
|
||||
)?.membership.id;
|
||||
}
|
||||
|
||||
function getUserTimezone() {
|
||||
return page.props.auth.user.timezone;
|
||||
}
|
||||
@@ -27,4 +33,5 @@ export {
|
||||
getCurrentUserId,
|
||||
getUserTimezone,
|
||||
getWeekStart,
|
||||
getCurrentMembershipId,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user