mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 11:42:15 +01:00
add project members to project show page
This commit is contained in:
@@ -24,6 +24,18 @@ export type CreateProjectBody = ZodiosBodyByAlias<
|
||||
'createProject'
|
||||
>;
|
||||
|
||||
export type ProjectMemberResponse = ZodiosResponseByAlias<
|
||||
SolidTimeApi,
|
||||
'getProjectMembers'
|
||||
>;
|
||||
|
||||
export type CreateProjectMemberBody = ZodiosBodyByAlias<
|
||||
SolidTimeApi,
|
||||
'createProjectMember'
|
||||
>;
|
||||
|
||||
export type ProjectMember = ProjectMemberResponse['data'][0];
|
||||
|
||||
export type CreateTaskBody = ZodiosBodyByAlias<SolidTimeApi, 'createTask'>;
|
||||
|
||||
export type CreateClientBody = ZodiosBodyByAlias<SolidTimeApi, 'createClient'>;
|
||||
|
||||
3
resources/js/utils/format.ts
Normal file
3
resources/js/utils/format.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function capitalizeFirstLetter(string: string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
@@ -1,6 +1,21 @@
|
||||
export function formatMoney(amount: number, currency: string) {
|
||||
export function formatMoney(
|
||||
amount: number,
|
||||
currency: string = getOrganizationCurrencyString()
|
||||
) {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
}).format(amount);
|
||||
}
|
||||
|
||||
export function formatCents(amount: number) {
|
||||
return formatMoney(amount / 100);
|
||||
}
|
||||
|
||||
export function getOrganizationCurrencyString() {
|
||||
return 'EUR';
|
||||
}
|
||||
|
||||
export function getOrganizationCurrencySymbol() {
|
||||
return '€';
|
||||
}
|
||||
|
||||
71
resources/js/utils/useProjectMembers.ts
Normal file
71
resources/js/utils/useProjectMembers.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { api } from '../../../openapi.json.client';
|
||||
import { computed, ref } from 'vue';
|
||||
import type {
|
||||
CreateProjectMemberBody,
|
||||
ProjectMember,
|
||||
ProjectMemberResponse,
|
||||
} from '@/utils/api';
|
||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||
|
||||
export const useProjectMembersStore = defineStore('project-members', () => {
|
||||
const projectMemberResponse = ref<ProjectMemberResponse | null>(null);
|
||||
|
||||
async function fetchProjectMembers(projectId: string) {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
projectMemberResponse.value = await api.getProjectMembers({
|
||||
params: {
|
||||
organization: organization,
|
||||
project: projectId,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function createProjectMember(
|
||||
projectId: string,
|
||||
projectMemberBody: CreateProjectMemberBody
|
||||
) {
|
||||
const organization = getCurrentOrganizationId();
|
||||
if (organization) {
|
||||
await api.createProjectMember(projectMemberBody, {
|
||||
params: {
|
||||
organization: organization,
|
||||
project: projectId,
|
||||
},
|
||||
});
|
||||
await fetchProjectMembers(projectId);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteProjectMember(
|
||||
projectId: string,
|
||||
projectMemberId: string
|
||||
) {
|
||||
const organizationId = getCurrentOrganizationId();
|
||||
if (organizationId) {
|
||||
await api.deleteProjectMember(
|
||||
{},
|
||||
{
|
||||
params: {
|
||||
organization: organizationId,
|
||||
projectMember: projectMemberId,
|
||||
},
|
||||
}
|
||||
);
|
||||
await fetchProjectMembers(projectId);
|
||||
}
|
||||
}
|
||||
|
||||
const projectMembers = computed<ProjectMember[]>(
|
||||
() => projectMemberResponse.value?.data || []
|
||||
);
|
||||
|
||||
return {
|
||||
projectMembers,
|
||||
fetchProjectMembers,
|
||||
createProjectMember,
|
||||
deleteProjectMember,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user