Skip to content

Commit

Permalink
updated typescript types from Team to Organization
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Vostrak authored and Gregor Vostrak committed Jan 21, 2024
1 parent 7539b66 commit 0dbe614
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 24 deletions.
6 changes: 3 additions & 3 deletions resources/js/Layouts/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ 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;
}>();
const page = usePage<{
auth: {
user: User;
user: JetstreamUser;
};
}>();
const enabling = ref(false);
Expand Down
12 changes: 8 additions & 4 deletions resources/js/Pages/Teams/Partials/TeamMemberManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>();
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Pages/Teams/Partials/UpdateTeamNameForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>();
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Pages/Teams/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}>();
Expand Down
5 changes: 5 additions & 0 deletions resources/js/types/jetstream.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { User } from '@/types/models';

export interface Permissions {
canAddTeamMembers: boolean;
canDeleteTeam: boolean;
Expand Down Expand Up @@ -28,6 +30,9 @@ export interface Role {
description: string;
}

export type JetstreamUser = User & {
two_factor_enabled: boolean;
};
export interface Token {
name: string;
token: string;
Expand Down
94 changes: 83 additions & 11 deletions resources/js/types/models.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand All @@ -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[];
}

0 comments on commit 0dbe614

Please sign in to comment.