add format check, update prettier rules, apply rules consistently

This commit is contained in:
Gregor Vostrak
2025-07-29 18:58:31 +02:00
parent b11672732b
commit a3d7cdaf4d
323 changed files with 3728 additions and 5579 deletions

View File

@@ -35,10 +35,7 @@ export function daysLeftInTrial() {
}>();
return (
getDayJsInstance()(page.props.billing.trial_until).diff(
getDayJsInstance()(),
'days'
) + 1
getDayJsInstance()(page.props.billing.trial_until).diff(getDayJsInstance()(), 'days') + 1
);
}

View File

@@ -18,11 +18,7 @@ export const useNotificationsStore = defineStore('notifications', () => {
const showActionBlockedModal = ref(false);
function addNotification(
type: NotificationType,
title: string,
message?: string
) {
function addNotification(type: NotificationType, title: string, message?: string) {
const uuid = Math.random().toString(36).substring(7);
notifications.value.push({ title, message, type, uuid });
@@ -32,9 +28,7 @@ export const useNotificationsStore = defineStore('notifications', () => {
}
function removeNotification(uuid: string) {
const index = notifications.value.findIndex(
(notification) => notification.uuid === uuid
);
const index = notifications.value.findIndex((notification) => notification.uuid === uuid);
if (index !== -1) {
notifications.value.splice(index, 1);
}
@@ -57,10 +51,7 @@ export const useNotificationsStore = defineStore('notifications', () => {
return response;
} catch (error) {
if (axios.isAxiosError(error)) {
if (
error?.response?.status === 403 ||
error?.response?.status === 400
) {
if (error?.response?.status === 403 || error?.response?.status === 400) {
if (
error?.response?.data?.key ===
'organization_has_no_subscription_but_multiple_members'
@@ -93,10 +84,7 @@ export const useNotificationsStore = defineStore('notifications', () => {
router.get(route('login'));
}
} else {
addNotification(
'error',
'The action failed. Please try again later.'
);
addNotification('error', 'The action failed. Please try again later.');
}
}
throw new Error('Failed to handle API request');

View File

@@ -1,18 +1,18 @@
import { usePreferredColorScheme, useStorage } from "@vueuse/core";
import { computed, watch } from "vue";
import { usePreferredColorScheme, useStorage } from '@vueuse/core';
import { computed, watch } from 'vue';
type themeOption = "system" | "light" | "dark";
const themeSetting = useStorage<themeOption>("theme", "system");
type themeOption = 'system' | 'light' | 'dark';
const themeSetting = useStorage<themeOption>('theme', 'system');
const preferredColor = usePreferredColorScheme();
const theme = computed(() => {
if(themeSetting.value === "system"){
if (themeSetting.value === 'system') {
console.log(preferredColor.value);
if (preferredColor.value === 'no-preference') {
return 'dark';
}
return preferredColor.value;
}
return themeSetting.value
return themeSetting.value;
});
function useTheme() {

View File

@@ -33,9 +33,7 @@ export const useClientsStore = defineStore('clients', () => {
}
}
async function createClient(
clientBody: CreateClientBody
): Promise<Client | undefined> {
async function createClient(clientBody: CreateClientBody): Promise<Client | undefined> {
const organization = getCurrentOrganizationId();
if (organization) {
const response = await handleApiRequestNotifications(
@@ -53,10 +51,7 @@ export const useClientsStore = defineStore('clients', () => {
}
}
async function updateClient(
clientId: string,
clientBody: UpdateClientBody
) {
async function updateClient(clientId: string, clientBody: UpdateClientBody) {
const organization = getCurrentOrganizationId();
if (organization) {
await handleApiRequestNotifications(

View File

@@ -1,49 +1,49 @@
import { ref, onMounted, onUnmounted } from 'vue'
import { ref, onMounted, onUnmounted } from 'vue';
export function useCssVariable(variableName: string) {
const value = ref('')
let observer: MutationObserver | null = null
let mediaQuery: MediaQueryList | null = null
const updateValue = () => {
const computedStyle = getComputedStyle(document.documentElement)
const cssValue = computedStyle.getPropertyValue(variableName).trim()
value.value = cssValue
}
onMounted(() => {
// Initialize with current value
updateValue()
// Watch for class changes on document.documentElement (where theme classes are applied)
observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
updateValue()
const value = ref('');
let observer: MutationObserver | null = null;
let mediaQuery: MediaQueryList | null = null;
const updateValue = () => {
const computedStyle = getComputedStyle(document.documentElement);
const cssValue = computedStyle.getPropertyValue(variableName).trim();
value.value = cssValue;
};
onMounted(() => {
// Initialize with current value
updateValue();
// Watch for class changes on document.documentElement (where theme classes are applied)
observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
updateValue();
}
});
});
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class'],
});
// Also watch for system color scheme changes
if (window.matchMedia) {
mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
mediaQuery.addEventListener('change', updateValue);
}
})
})
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class']
})
// Also watch for system color scheme changes
if (window.matchMedia) {
mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
mediaQuery.addEventListener('change', updateValue)
}
})
onUnmounted(() => {
if (observer) {
observer.disconnect()
}
if (mediaQuery) {
mediaQuery.removeEventListener('change', updateValue)
}
})
return value
}
});
onUnmounted(() => {
if (observer) {
observer.disconnect();
}
if (mediaQuery) {
mediaQuery.removeEventListener('change', updateValue);
}
});
return value;
}

View File

@@ -76,7 +76,7 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
currentTimeEntry.value = { ...emptyTimeEntry };
}
}
} catch{
} catch {
currentTimeEntry.value = { ...emptyTimeEntry };
}
} else {
@@ -144,9 +144,7 @@ export const useCurrentTimeEntryStore = defineStore('currentTimeEntry', () => {
);
$reset();
} else {
throw new Error(
'Failed to stop current timer because organization ID is missing.'
);
throw new Error('Failed to stop current timer because organization ID is missing.');
}
}

View File

@@ -29,9 +29,7 @@ export const useInvitationsStore = defineStore('invitations', () => {
}
}
async function createInvitation(
inviteBody: CreateInvitationBody
): Promise<undefined> {
async function createInvitation(inviteBody: CreateInvitationBody): Promise<undefined> {
const organization = getCurrentOrganizationId();
if (organization) {
await handleApiRequestNotifications(

View File

@@ -1,11 +1,7 @@
import { defineStore } from 'pinia';
import { api } from '@/packages/api/src';
import { computed, ref } from 'vue';
import type {
Member,
MemberIndexResponse,
UpdateMemberBody,
} from '@/packages/api/src';
import type { Member, MemberIndexResponse, UpdateMemberBody } from '@/packages/api/src';
import { getCurrentOrganizationId } from '@/utils/useUser';
import { useNotificationsStore } from '@/utils/notification';
@@ -49,10 +45,7 @@ export const useMembersStore = defineStore('members', () => {
}
}
async function updateMember(
memberId: string,
memberBody: UpdateMemberBody
) {
async function updateMember(memberId: string, memberBody: UpdateMemberBody) {
const organization = getCurrentOrganizationId();
if (organization) {
await handleApiRequestNotifications(

View File

@@ -46,9 +46,7 @@ export const useOrganizationStore = defineStore('organization', () => {
}
}
async function updateOrganization(
organizationBody: UpdateOrganizationBody
) {
async function updateOrganization(organizationBody: UpdateOrganizationBody) {
const organization = getCurrentOrganizationId();
if (organization) {
await handleApiRequestNotifications(

View File

@@ -73,10 +73,7 @@ export const useProjectMembersStore = defineStore('project-members', () => {
}
}
async function deleteProjectMember(
projectId: string,
projectMemberId: string
) {
async function deleteProjectMember(projectId: string, projectMemberId: string) {
const organizationId = getCurrentOrganizationId();
if (organizationId) {
await handleApiRequestNotifications(
@@ -94,9 +91,7 @@ export const useProjectMembersStore = defineStore('project-members', () => {
}
}
const projectMembers = computed<ProjectMember[]>(
() => projectMemberResponse.value?.data || []
);
const projectMembers = computed<ProjectMember[]>(() => projectMemberResponse.value?.data || []);
return {
projectMembers,

View File

@@ -70,10 +70,7 @@ export const useProjectsStore = defineStore('projects', () => {
}
}
async function updateProject(
projectId: string,
updateProjectBody: UpdateProjectBody
) {
async function updateProject(projectId: string, updateProjectBody: UpdateProjectBody) {
const organizationId = getCurrentOrganizationId();
if (organizationId) {
await handleApiRequestNotifications(
@@ -91,9 +88,7 @@ export const useProjectsStore = defineStore('projects', () => {
}
}
const projects = computed<Project[]>(
() => projectResponse.value?.data || []
);
const projects = computed<Project[]>(() => projectResponse.value?.data || []);
return {
projects,

View File

@@ -6,31 +6,17 @@ import type {
AggregatedTimeEntriesQueryParams,
ReportingResponse,
} from '@/packages/api/src';
import {
getCurrentOrganizationId,
getCurrentRole,
getCurrentUser,
} from '@/utils/useUser';
import { getCurrentOrganizationId, getCurrentRole, getCurrentUser } from '@/utils/useUser';
import { useNotificationsStore } from '@/utils/notification';
import { useProjectsStore } from '@/utils/useProjects';
import { useMembersStore } from '@/utils/useMembers';
import { useTasksStore } from '@/utils/useTasks';
import { useClientsStore } from '@/utils/useClients';
import {
CheckCircleIcon,
UserCircleIcon,
UserGroupIcon,
} from '@heroicons/vue/20/solid';
import { CheckCircleIcon, UserCircleIcon, UserGroupIcon } from '@heroicons/vue/20/solid';
import { DocumentTextIcon, FolderIcon } from '@heroicons/vue/16/solid';
import BillableIcon from '@/packages/ui/src/Icons/BillableIcon.vue';
export type GroupingOption =
| 'project'
| 'task'
| 'user'
| 'billable'
| 'client'
| 'description';
export type GroupingOption = 'project' | 'task' | 'user' | 'billable' | 'client' | 'description';
export const useReportingStore = defineStore('reporting', () => {
const reportingGraphResponse = ref<ReportingResponse | null>(null);
@@ -38,9 +24,7 @@ export const useReportingStore = defineStore('reporting', () => {
const { handleApiRequestNotifications } = useNotificationsStore();
async function fetchGraphReporting(
params: AggregatedTimeEntriesQueryParams
) {
async function fetchGraphReporting(params: AggregatedTimeEntriesQueryParams) {
const organization = getCurrentOrganizationId();
if (organization) {
reportingGraphResponse.value = await handleApiRequestNotifications(
@@ -57,9 +41,7 @@ export const useReportingStore = defineStore('reporting', () => {
}
}
async function fetchTableReporting(
params: AggregatedTimeEntriesQueryParams
) {
async function fetchTableReporting(params: AggregatedTimeEntriesQueryParams) {
const organization = getCurrentOrganizationId();
if (organization) {
reportingTableResponse.value = await handleApiRequestNotifications(
@@ -93,10 +75,7 @@ export const useReportingStore = defineStore('reporting', () => {
description: 'No Description',
} as Record<string, string>;
function getNameForReportingRowEntry(
key: string | null,
type: string | null
) {
function getNameForReportingRowEntry(key: string | null, type: string | null) {
if (type === null) {
return null;
}

View File

@@ -25,9 +25,7 @@ export const useTagsStore = defineStore('tags', () => {
tags.value = response.data;
}
} else {
throw new Error(
'Failed to fetch current tags because organization ID is missing.'
);
throw new Error('Failed to fetch current tags because organization ID is missing.');
}
}
@@ -72,9 +70,7 @@ export const useTagsStore = defineStore('tags', () => {
return response.data;
}
} else {
throw new Error(
'Failed to create tag because organization ID is missing.'
);
throw new Error('Failed to create tag because organization ID is missing.');
}
}

View File

@@ -1,8 +1,5 @@
import { defineStore } from 'pinia';
import {
getCurrentMembershipId,
getCurrentOrganizationId,
} from '@/utils/useUser';
import { getCurrentMembershipId, getCurrentOrganizationId } from '@/utils/useUser';
import { reactive, ref } from 'vue';
import {
@@ -14,7 +11,7 @@ import {
import dayjs from 'dayjs';
import { useNotificationsStore } from '@/utils/notification';
import type { UpdateMultipleTimeEntriesChangeset } from '@/packages/api/src';
import { useQueryClient } from "@tanstack/vue-query";
import { useQueryClient } from '@tanstack/vue-query';
export const useTimeEntriesStore = defineStore('timeEntries', () => {
const timeEntries = ref<TimeEntry[]>(reactive([]));
@@ -49,10 +46,7 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
const missingTimeEntries = timeEntriesResponse.data.filter(
(entry) => !timeEntries.value.find((e) => e.id === entry.id)
);
timeEntries.value = [
...missingTimeEntries,
...timeEntries.value,
];
timeEntries.value = [...missingTimeEntries, ...timeEntries.value];
}
}
}
@@ -86,8 +80,7 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
async function fetchMoreTimeEntries() {
const organizationId = getCurrentOrganizationId();
if (organizationId) {
const latestTimeEntry =
timeEntries.value[timeEntries.value.length - 1];
const latestTimeEntry = timeEntries.value[timeEntries.value.length - 1];
dayjs(latestTimeEntry.start).utc().format('YYYY-MM-DD');
const timeEntriesResponse = await handleApiRequestNotifications(
@@ -105,23 +98,15 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
undefined,
'Failed to fetch time entries'
);
if (
timeEntriesResponse?.data &&
timeEntriesResponse.data.length > 0
) {
timeEntries.value = timeEntries.value.concat(
timeEntriesResponse.data
);
if (timeEntriesResponse?.data && timeEntriesResponse.data.length > 0) {
timeEntries.value = timeEntries.value.concat(timeEntriesResponse.data);
} else {
allTimeEntriesLoaded.value = true;
}
}
}
async function updateTimeEntries(
ids: string[],
changes: UpdateMultipleTimeEntriesChangeset
) {
async function updateTimeEntries(ids: string[], changes: UpdateMultipleTimeEntriesChangeset) {
const organizationId = getCurrentOrganizationId();
if (organizationId) {
await handleApiRequestNotifications(
@@ -160,13 +145,11 @@ export const useTimeEntriesStore = defineStore('timeEntries', () => {
timeEntries.value = timeEntries.value.map((entry) =>
entry.id === timeEntry.id ? response.data : entry
);
queryClient.invalidateQueries({queryKey: ['timeEntry']});
queryClient.invalidateQueries({ queryKey: ['timeEntry'] });
}
}
async function createTimeEntry(
timeEntry: Omit<CreateTimeEntryBody, 'member_id'>
) {
async function createTimeEntry(timeEntry: Omit<CreateTimeEntryBody, 'member_id'>) {
const organizationId = getCurrentOrganizationId();
const memberId = getCurrentMembershipId();
if (organizationId && memberId !== undefined) {

View File

@@ -19,15 +19,13 @@ function getCurrentOrganizationId() {
}
function getCurrentMembershipId() {
return page.props.auth.user.all_teams.find(
(team) => team.id === getCurrentOrganizationId()
)?.membership.id;
return page.props.auth.user.all_teams.find((team) => team.id === getCurrentOrganizationId())
?.membership.id;
}
function getCurrentRole() {
return page.props.auth.user.all_teams.find(
(team) => team.id === getCurrentOrganizationId()
)?.membership.role;
return page.props.auth.user.all_teams.find((team) => team.id === getCurrentOrganizationId())
?.membership.role;
}
export {