From 0dbe6148fc5af764595d3caf8b4ae46180602c75 Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Sun, 21 Jan 2024 22:33:14 +0100 Subject: [PATCH] updated typescript types from Team to Organization --- resources/js/Layouts/AppLayout.vue | 6 +- .../Partials/TwoFactorAuthenticationForm.vue | 4 +- .../Teams/Partials/TeamMemberManager.vue | 12 ++- .../Teams/Partials/UpdateTeamNameForm.vue | 4 +- resources/js/Pages/Teams/Show.vue | 4 +- resources/js/types/jetstream.ts | 5 + resources/js/types/models.ts | 94 ++++++++++++++++--- 7 files changed, 105 insertions(+), 24 deletions(-) diff --git a/resources/js/Layouts/AppLayout.vue b/resources/js/Layouts/AppLayout.vue index 76155d51..487d040a 100644 --- a/resources/js/Layouts/AppLayout.vue +++ b/resources/js/Layouts/AppLayout.vue @@ -8,7 +8,7 @@ import DropdownLink from '@/Components/DropdownLink.vue'; import NavLink from '@/Components/NavLink.vue'; import ResponsiveNavLink from '@/Components/ResponsiveNavLink.vue'; import route from 'ziggy-js'; -import type { Team, User } from '@/types/models'; +import type { Organization, User } from '@/types/models'; defineProps({ title: String, @@ -24,11 +24,11 @@ const page = usePage<{ hasApiFeatures: boolean; }; auth: { - user: User & { all_teams: Team[] }; + user: User & { all_teams: Organization[] }; }; }>(); -const switchToTeam = (team: Team) => { +const switchToTeam = (team: Organization) => { router.put( route('current-team.update'), { diff --git a/resources/js/Pages/Profile/Partials/TwoFactorAuthenticationForm.vue b/resources/js/Pages/Profile/Partials/TwoFactorAuthenticationForm.vue index ddee7713..88c9a092 100644 --- a/resources/js/Pages/Profile/Partials/TwoFactorAuthenticationForm.vue +++ b/resources/js/Pages/Profile/Partials/TwoFactorAuthenticationForm.vue @@ -9,8 +9,8 @@ import InputLabel from '@/Components/InputLabel.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue'; import SecondaryButton from '@/Components/SecondaryButton.vue'; import TextInput from '@/Components/TextInput.vue'; -import type { User } from '@/types/models'; import axios from 'axios'; +import type { JetstreamUser } from '@/types/jetstream'; const props = defineProps<{ requiresConfirmation: boolean; @@ -18,7 +18,7 @@ const props = defineProps<{ const page = usePage<{ auth: { - user: User; + user: JetstreamUser; }; }>(); const enabling = ref(false); diff --git a/resources/js/Pages/Teams/Partials/TeamMemberManager.vue b/resources/js/Pages/Teams/Partials/TeamMemberManager.vue index 80c86278..30a3f074 100644 --- a/resources/js/Pages/Teams/Partials/TeamMemberManager.vue +++ b/resources/js/Pages/Teams/Partials/TeamMemberManager.vue @@ -13,13 +13,17 @@ import PrimaryButton from '@/Components/PrimaryButton.vue'; import SecondaryButton from '@/Components/SecondaryButton.vue'; import SectionBorder from '@/Components/SectionBorder.vue'; import TextInput from '@/Components/TextInput.vue'; -import type { Team, TeamInvitation, User } from '@/types/models'; +import type { + Organization, + OrganizationInvitation, + User, +} from '@/types/models'; import type { Membership, Permissions, Role } from '@/types/jetstream'; type UserWithMembership = User & { membership: Membership }; const props = defineProps<{ - team: Team; + team: Organization; availableRoles: Role[]; userPermissions: Permissions; }>(); @@ -59,13 +63,13 @@ const addTeamMember = () => { }); }; -const cancelTeamInvitation = (invitation: TeamInvitation) => { +const cancelTeamInvitation = (invitation: OrganizationInvitation) => { router.delete(route('team-invitations.destroy', invitation.id), { preserveScroll: true, }); }; -const manageRole = (teamMember: User & { membership?: Membership }) => { +const manageRole = (teamMember: User & { membership: Membership }) => { managingRoleFor.value = teamMember; updateRoleForm.role = teamMember.membership.role; currentlyManagingRole.value = true; diff --git a/resources/js/Pages/Teams/Partials/UpdateTeamNameForm.vue b/resources/js/Pages/Teams/Partials/UpdateTeamNameForm.vue index 69994137..ba008cdb 100644 --- a/resources/js/Pages/Teams/Partials/UpdateTeamNameForm.vue +++ b/resources/js/Pages/Teams/Partials/UpdateTeamNameForm.vue @@ -6,11 +6,11 @@ import InputError from '@/Components/InputError.vue'; import InputLabel from '@/Components/InputLabel.vue'; import PrimaryButton from '@/Components/PrimaryButton.vue'; import TextInput from '@/Components/TextInput.vue'; -import type { Team } from '@/types/models'; +import type { Organization } from '@/types/models'; import type { Permissions } from '@/types/jetstream'; const props = defineProps<{ - team: Team; + team: Organization; permissions: Permissions; }>(); diff --git a/resources/js/Pages/Teams/Show.vue b/resources/js/Pages/Teams/Show.vue index 97e92b63..cafd3319 100644 --- a/resources/js/Pages/Teams/Show.vue +++ b/resources/js/Pages/Teams/Show.vue @@ -4,11 +4,11 @@ import DeleteTeamForm from '@/Pages/Teams/Partials/DeleteTeamForm.vue'; import SectionBorder from '@/Components/SectionBorder.vue'; import TeamMemberManager from '@/Pages/Teams/Partials/TeamMemberManager.vue'; import UpdateTeamNameForm from '@/Pages/Teams/Partials/UpdateTeamNameForm.vue'; -import type { Team } from '@/types/models'; +import type { Organization } from '@/types/models'; import type { Permissions, Role } from '@/types/jetstream'; defineProps<{ - team: Team; + team: Organization; availableRoles: Role[]; permissions: Permissions; }>(); diff --git a/resources/js/types/jetstream.ts b/resources/js/types/jetstream.ts index 3d5cbe91..b1d77cca 100644 --- a/resources/js/types/jetstream.ts +++ b/resources/js/types/jetstream.ts @@ -1,3 +1,5 @@ +import type { User } from '@/types/models'; + export interface Permissions { canAddTeamMembers: boolean; canDeleteTeam: boolean; @@ -28,6 +30,9 @@ export interface Role { description: string; } +export type JetstreamUser = User & { + two_factor_enabled: boolean; +}; export interface Token { name: string; token: string; diff --git a/resources/js/types/models.ts b/resources/js/types/models.ts index 1fed786e..08fa5d7e 100644 --- a/resources/js/types/models.ts +++ b/resources/js/types/models.ts @@ -1,14 +1,25 @@ +export interface Client { + // columns + id: string; + name: string; + organization_id: string; + created_at: string | null; + updated_at: string | null; + // relations + organization: Organization; +} + export interface Membership { // columns id: string; - team_id: string; + organization_id: string; user_id: string; role: string | null; created_at: string | null; updated_at: string | null; } -export interface Team { +export interface Organization { // columns id: string; user_id: string; @@ -19,19 +30,80 @@ export interface Team { // relations owner: User; users: User[]; - team_invitations: TeamInvitation[]; + team_invitations: OrganizationInvitation[]; } -export interface TeamInvitation { +export interface OrganizationInvitation { // columns id: string; - team_id: string; + organization_id: string; email: string; role: string | null; created_at: string | null; updated_at: string | null; // relations - team: Team; + organization: Organization; + team: Organization; +} + +export interface Project { + // columns + id: string; + name: string; + color: string; + client_id: string | null; + organization_id: string; + created_at: string | null; + updated_at: string | null; + // relations + organization: Organization; + client: Client; + tasks: Task[]; +} + +export interface Tag { + // columns + id: string; + name: string; + organization_id: string; + created_at: string | null; + updated_at: string | null; + // relations + organization: Organization; +} + +export interface Task { + // columns + id: string; + name: string; + project_id: string; + organization_id: string; + created_at: string | null; + updated_at: string | null; + // relations + project: Project; + organization: Organization; +} + +export interface TimeEntry { + // columns + id: string; + description: string; + start: string; + end: string | null; + billable: boolean; + user_id: string; + organization_id: string; + project_id: string | null; + task_id: string | null; + tags: string[] | null; + created_at: string | null; + updated_at: string | null; + // relations + user: User; + organization: Organization; + project: Project; + task: Task; } export interface User { @@ -49,12 +121,12 @@ export interface User { two_factor_secret?: string | null; two_factor_recovery_codes?: string | null; two_factor_confirmed_at: string | null; - two_factor_enabled: boolean; // mutators profile_photo_url: string; // relations - membership: Membership[]; - current_team: Team; - owned_teams: Team[]; - teams: Team[]; + organizations: Organization[]; + clients: Client[]; + current_team: Organization; + owned_teams: Organization[]; + teams: Organization[]; }