feat: Add create and update DTOs for Company, Customer, Project, Activity, User, and TimeEntry entities
This commit is contained in:
parent
0402b8ac65
commit
9749d5658c
@ -4,6 +4,7 @@ go 1.23.6
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-gonic/gin v1.10.0
|
github.com/gin-gonic/gin v1.10.0
|
||||||
|
github.com/oklog/ulid/v2 v2.1.0
|
||||||
github.com/swaggo/files v1.0.1
|
github.com/swaggo/files v1.0.1
|
||||||
github.com/swaggo/gin-swagger v1.6.0
|
github.com/swaggo/gin-swagger v1.6.0
|
||||||
github.com/swaggo/swag v1.16.4
|
github.com/swaggo/swag v1.16.4
|
||||||
@ -32,7 +33,6 @@ require (
|
|||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/oklog/ulid/v2 v2.1.0 // indirect
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||||
|
@ -1,9 +1,22 @@
|
|||||||
package entities
|
package entities
|
||||||
|
|
||||||
import "github.com/oklog/ulid/v2"
|
import (
|
||||||
|
"github.com/oklog/ulid/v2"
|
||||||
|
)
|
||||||
|
|
||||||
type Activity struct {
|
type Activity struct {
|
||||||
ID ulid.ULID
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
BillingRate float64
|
BillingRate float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ActivityUpdate struct {
|
||||||
|
ID ulid.ULID
|
||||||
|
Name *string
|
||||||
|
BillingRate *float64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActivityCreate struct {
|
||||||
|
Name string
|
||||||
|
BillingRate float64
|
||||||
|
}
|
||||||
|
@ -6,3 +6,12 @@ type Company struct {
|
|||||||
ID ulid.ULID
|
ID ulid.ULID
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CompanyCreate struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
type CompanyUpdate struct {
|
||||||
|
ID ulid.ULID
|
||||||
|
Name *string
|
||||||
|
}
|
||||||
|
@ -7,3 +7,14 @@ type Customer struct {
|
|||||||
Name string
|
Name string
|
||||||
CompanyID int
|
CompanyID int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CustomerCreate struct {
|
||||||
|
Name string
|
||||||
|
CompanyID int
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomerUpdate struct {
|
||||||
|
ID ulid.ULID
|
||||||
|
Name *string
|
||||||
|
CompanyID *int
|
||||||
|
}
|
||||||
|
@ -7,3 +7,14 @@ type Project struct {
|
|||||||
Name string
|
Name string
|
||||||
CustomerID int
|
CustomerID int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProjectCreate struct {
|
||||||
|
Name string
|
||||||
|
CustomerID int
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectUpdate struct {
|
||||||
|
ID ulid.ULID
|
||||||
|
Name *string
|
||||||
|
CustomerID *int
|
||||||
|
}
|
||||||
|
@ -16,3 +16,24 @@ type TimeEntry struct {
|
|||||||
Description string
|
Description string
|
||||||
Billable int // Percentage (0-100)
|
Billable int // Percentage (0-100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TimeEntryCreate struct {
|
||||||
|
UserID int
|
||||||
|
ProjectID int
|
||||||
|
ActivityID int
|
||||||
|
Start time.Time
|
||||||
|
End time.Time
|
||||||
|
Description string
|
||||||
|
Billable int // Percentage (0-100)
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimeEntryUpdate struct {
|
||||||
|
ID ulid.ULID
|
||||||
|
UserID *int
|
||||||
|
ProjectID *int
|
||||||
|
ActivityID *int
|
||||||
|
Start *time.Time
|
||||||
|
End *time.Time
|
||||||
|
Description *string
|
||||||
|
Billable *int // Percentage (0-100)
|
||||||
|
}
|
||||||
|
@ -10,3 +10,20 @@ type User struct {
|
|||||||
CompanyID int
|
CompanyID int
|
||||||
HourlyRate float64
|
HourlyRate float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserCreate struct {
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
Role string
|
||||||
|
CompanyID int
|
||||||
|
HourlyRate float64
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserUpdate struct {
|
||||||
|
ID ulid.ULID
|
||||||
|
Username *string
|
||||||
|
Password *string
|
||||||
|
Role *string
|
||||||
|
CompanyID *int
|
||||||
|
HourlyRate *float64
|
||||||
|
}
|
||||||
|
@ -9,3 +9,14 @@ type ActivityDto struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
BillingRate float64 `json:"billingRate"`
|
BillingRate float64 `json:"billingRate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ActivityCreateDto struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
BillingRate float64 `json:"billingRate"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActivityUpdateDto struct {
|
||||||
|
ID ulid.ULID `json:"id"`
|
||||||
|
Name *string `json:"name"`
|
||||||
|
BillingRate *float64 `json:"billingRate"`
|
||||||
|
}
|
||||||
|
@ -8,3 +8,12 @@ type CompanyDto struct {
|
|||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CompanyCreateDto struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CompanyUpdateDto struct {
|
||||||
|
ID ulid.ULID `json:"id"`
|
||||||
|
Name *string `json:"name"`
|
||||||
|
}
|
||||||
|
@ -9,3 +9,14 @@ type CustomerDto struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
CompanyID int `json:"companyId"`
|
CompanyID int `json:"companyId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CustomerCreateDto struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
CompanyID int `json:"companyId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomerUpdateDto struct {
|
||||||
|
ID ulid.ULID `json:"id"`
|
||||||
|
Name *string `json:"name"`
|
||||||
|
CompanyID *int `json:"companyId"`
|
||||||
|
}
|
||||||
|
@ -1,9 +1,22 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import "github.com/oklog/ulid/v2"
|
import (
|
||||||
|
"github.com/oklog/ulid/v2"
|
||||||
|
)
|
||||||
|
|
||||||
type ProjectDto struct {
|
type ProjectDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
CustomerID int `json:"customerId"`
|
CustomerID int `json:"customerId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProjectCreateDto struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
CustomerID int `json:"customerId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectUpdateDto struct {
|
||||||
|
ID ulid.ULID `json:"id"`
|
||||||
|
Name *string `json:"name"`
|
||||||
|
CustomerID *int `json:"customerId"`
|
||||||
|
}
|
||||||
|
@ -16,3 +16,24 @@ type TimeEntryDto struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Billable int `json:"billable"` // Percentage (0-100)
|
Billable int `json:"billable"` // Percentage (0-100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TimeEntryCreateDto struct {
|
||||||
|
UserID int `json:"userId"`
|
||||||
|
ProjectID int `json:"projectId"`
|
||||||
|
ActivityID int `json:"activityId"`
|
||||||
|
Start time.Time `json:"start"`
|
||||||
|
End time.Time `json:"end"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Billable int `json:"billable"` // Percentage (0-100)
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimeEntryUpdateDto struct {
|
||||||
|
ID ulid.ULID `json:"id"`
|
||||||
|
UserID *int `json:"userId"`
|
||||||
|
ProjectID *int `json:"projectId"`
|
||||||
|
ActivityID *int `json:"activityId"`
|
||||||
|
Start *time.Time `json:"start"`
|
||||||
|
End *time.Time `json:"end"`
|
||||||
|
Description *string `json:"description"`
|
||||||
|
Billable *int `json:"billable"` // Percentage (0-100)
|
||||||
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package dto
|
package dto
|
||||||
|
|
||||||
import "github.com/oklog/ulid/v2"
|
import (
|
||||||
|
"github.com/oklog/ulid/v2"
|
||||||
|
)
|
||||||
|
|
||||||
type UserDto struct {
|
type UserDto struct {
|
||||||
ID ulid.ULID `json:"id"`
|
ID ulid.ULID `json:"id"`
|
||||||
@ -10,3 +12,20 @@ type UserDto struct {
|
|||||||
CompanyID int `json:"companyId"`
|
CompanyID int `json:"companyId"`
|
||||||
HourlyRate float64 `json:"hourlyRate"`
|
HourlyRate float64 `json:"hourlyRate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserCreateDto struct {
|
||||||
|
Username string `json:"username"`
|
||||||
|
Password string `json:"password"` // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
|
Role string `json:"role"`
|
||||||
|
CompanyID int `json:"companyId"`
|
||||||
|
HourlyRate float64 `json:"hourlyRate"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserUpdateDto struct {
|
||||||
|
ID ulid.ULID `json:"id"`
|
||||||
|
Username *string `json:"username"`
|
||||||
|
Password *string `json:"password"` // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
|
Role *string `json:"role"`
|
||||||
|
CompanyID *int `json:"companyId"`
|
||||||
|
HourlyRate *float64 `json:"hourlyRate"`
|
||||||
|
}
|
||||||
|
@ -3,4 +3,4 @@ packages:
|
|||||||
type_mappings:
|
type_mappings:
|
||||||
"time.Time": "string"
|
"time.Time": "string"
|
||||||
"ulid.ULID": "string"
|
"ulid.ULID": "string"
|
||||||
output_path: ../frontend/src/types
|
output_path: ../frontend/src/types/dto.ts
|
||||||
|
19
frontend/src/types/activity.ts
Normal file
19
frontend/src/types/activity.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { ActivityDto, ActivityCreateDto, ActivityUpdateDto } from "./dto";
|
||||||
|
|
||||||
|
export type Activity = ActivityDto;
|
||||||
|
|
||||||
|
export const mapActivityDtoToActivity = (dto: ActivityDto): Activity => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ActivityCreate = ActivityCreateDto;
|
||||||
|
|
||||||
|
export const mapActivityCreateDtoToActivityCreate = (dto: ActivityCreateDto): ActivityCreate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ActivityUpdate = ActivityUpdateDto;
|
||||||
|
|
||||||
|
export const mapActivityUpdateDtoToActivityUpdate = (dto: ActivityUpdateDto): ActivityUpdate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
19
frontend/src/types/company.ts
Normal file
19
frontend/src/types/company.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { CompanyDto, CompanyCreateDto, CompanyUpdateDto } from "./dto";
|
||||||
|
|
||||||
|
export type Company = CompanyDto;
|
||||||
|
|
||||||
|
export const mapCompanyDtoToCompany = (dto: CompanyDto): Company => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type CompanyCreate = CompanyCreateDto;
|
||||||
|
|
||||||
|
export const mapCompanyCreateDtoToCompanyCreate = (dto: CompanyCreateDto): CompanyCreate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type CompanyUpdate = CompanyUpdateDto;
|
||||||
|
|
||||||
|
export const mapCompanyUpdateDtoToCompanyUpdate = (dto: CompanyUpdateDto): CompanyUpdate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
19
frontend/src/types/customer.ts
Normal file
19
frontend/src/types/customer.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { CustomerDto, CustomerCreateDto, CustomerUpdateDto } from "./dto";
|
||||||
|
|
||||||
|
export type Customer = CustomerDto;
|
||||||
|
|
||||||
|
export const mapCustomerDtoToCustomer = (dto: CustomerDto): Customer => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type CustomerCreate = CustomerCreateDto;
|
||||||
|
|
||||||
|
export const mapCustomerCreateDtoToCustomerCreate = (dto: CustomerCreateDto): CustomerCreate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type CustomerUpdate = CustomerUpdateDto;
|
||||||
|
|
||||||
|
export const mapCustomerUpdateDtoToCustomerUpdate = (dto: CustomerUpdateDto): CustomerUpdate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
130
frontend/src/types/dto.ts
Normal file
130
frontend/src/types/dto.ts
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
// Code generated by tygo. DO NOT EDIT.
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// source: activity_dto.go
|
||||||
|
|
||||||
|
export interface ActivityDto {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
billingRate: number /* float64 */;
|
||||||
|
}
|
||||||
|
export interface ActivityCreateDto {
|
||||||
|
name: string;
|
||||||
|
billingRate: number /* float64 */;
|
||||||
|
}
|
||||||
|
export interface ActivityUpdateDto {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
billingRate?: number /* float64 */;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// source: company_dto.go
|
||||||
|
|
||||||
|
export interface CompanyDto {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
export interface CompanyCreateDto {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
export interface CompanyUpdateDto {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// source: customer_dto.go
|
||||||
|
|
||||||
|
export interface CustomerDto {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
companyId: number /* int */;
|
||||||
|
}
|
||||||
|
export interface CustomerCreateDto {
|
||||||
|
name: string;
|
||||||
|
companyId: number /* int */;
|
||||||
|
}
|
||||||
|
export interface CustomerUpdateDto {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
companyId?: number /* int */;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// source: project_dto.go
|
||||||
|
|
||||||
|
export interface ProjectDto {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
customerId: number /* int */;
|
||||||
|
}
|
||||||
|
export interface ProjectCreateDto {
|
||||||
|
name: string;
|
||||||
|
customerId: number /* int */;
|
||||||
|
}
|
||||||
|
export interface ProjectUpdateDto {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
customerId?: number /* int */;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// source: timeentry_dto.go
|
||||||
|
|
||||||
|
export interface TimeEntryDto {
|
||||||
|
id: string;
|
||||||
|
userId: number /* int */;
|
||||||
|
projectId: number /* int */;
|
||||||
|
activityId: number /* int */;
|
||||||
|
start: string;
|
||||||
|
end: string;
|
||||||
|
description: string;
|
||||||
|
billable: number /* int */; // Percentage (0-100)
|
||||||
|
}
|
||||||
|
export interface TimeEntryCreateDto {
|
||||||
|
userId: number /* int */;
|
||||||
|
projectId: number /* int */;
|
||||||
|
activityId: number /* int */;
|
||||||
|
start: string;
|
||||||
|
end: string;
|
||||||
|
description: string;
|
||||||
|
billable: number /* int */; // Percentage (0-100)
|
||||||
|
}
|
||||||
|
export interface TimeEntryUpdateDto {
|
||||||
|
id: string;
|
||||||
|
userId?: number /* int */;
|
||||||
|
projectId?: number /* int */;
|
||||||
|
activityId?: number /* int */;
|
||||||
|
start?: string;
|
||||||
|
end?: string;
|
||||||
|
description?: string;
|
||||||
|
billable?: number /* int */; // Percentage (0-100)
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// source: user_dto.go
|
||||||
|
|
||||||
|
export interface UserDto {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
|
role: string;
|
||||||
|
companyId: number /* int */;
|
||||||
|
hourlyRate: number /* float64 */;
|
||||||
|
}
|
||||||
|
export interface UserCreateDto {
|
||||||
|
username: string;
|
||||||
|
password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
|
role: string;
|
||||||
|
companyId: number /* int */;
|
||||||
|
hourlyRate: number /* float64 */;
|
||||||
|
}
|
||||||
|
export interface UserUpdateDto {
|
||||||
|
id: string;
|
||||||
|
username?: string;
|
||||||
|
password?: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
||||||
|
role?: string;
|
||||||
|
companyId?: number /* int */;
|
||||||
|
hourlyRate?: number /* float64 */;
|
||||||
|
}
|
@ -1,62 +0,0 @@
|
|||||||
// Code generated by tygo. DO NOT EDIT.
|
|
||||||
|
|
||||||
//////////
|
|
||||||
// source: activity_dto.go
|
|
||||||
|
|
||||||
export interface ActivityDto {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
billingRate: number /* float64 */;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////
|
|
||||||
// source: company_dto.go
|
|
||||||
|
|
||||||
export interface CompanyDto {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////
|
|
||||||
// source: customer_dto.go
|
|
||||||
|
|
||||||
export interface CustomerDto {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
companyId: number /* int */;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////
|
|
||||||
// source: project_dto.go
|
|
||||||
|
|
||||||
export interface ProjectDto {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
customerId: number /* int */;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////
|
|
||||||
// source: timeentry_dto.go
|
|
||||||
|
|
||||||
export interface TimeEntryDto {
|
|
||||||
id: string;
|
|
||||||
userId: number /* int */;
|
|
||||||
projectId: number /* int */;
|
|
||||||
activityId: number /* int */;
|
|
||||||
start: string;
|
|
||||||
end: string;
|
|
||||||
description: string;
|
|
||||||
billable: number /* int */; // Percentage (0-100)
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////
|
|
||||||
// source: user_dto.go
|
|
||||||
|
|
||||||
export interface UserDto {
|
|
||||||
id: string;
|
|
||||||
username: string;
|
|
||||||
password: string; // Note: In a real application, you would NEVER send the password in a DTO. This is just for demonstration.
|
|
||||||
role: string;
|
|
||||||
companyId: number /* int */;
|
|
||||||
hourlyRate: number /* float64 */;
|
|
||||||
}
|
|
19
frontend/src/types/project.ts
Normal file
19
frontend/src/types/project.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { ProjectDto, ProjectCreateDto, ProjectUpdateDto } from "./dto";
|
||||||
|
|
||||||
|
export type Project = ProjectDto;
|
||||||
|
|
||||||
|
export const mapProjectDtoToProject = (dto: ProjectDto): Project => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ProjectCreate = ProjectCreateDto;
|
||||||
|
|
||||||
|
export const mapProjectCreateDtoToProjectCreate = (dto: ProjectCreateDto): ProjectCreate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ProjectUpdate = ProjectUpdateDto;
|
||||||
|
|
||||||
|
export const mapProjectUpdateDtoToProjectUpdate = (dto: ProjectUpdateDto): ProjectUpdate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
34
frontend/src/types/timeentry.ts
Normal file
34
frontend/src/types/timeentry.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { TimeEntryDto, TimeEntryCreateDto, TimeEntryUpdateDto } from "./dto";
|
||||||
|
|
||||||
|
export type TimeEntry = Omit<TimeEntryDto, "start" | "end"> & {
|
||||||
|
start: Date;
|
||||||
|
end: Date;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mapTimeEntryDtoToTimeEntry = (dto: TimeEntryDto): TimeEntry => ({
|
||||||
|
...dto,
|
||||||
|
start: new Date(dto.start),
|
||||||
|
end: new Date(dto.end),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type TimeEntryCreate = Omit<TimeEntryCreateDto, "start" | "end"> & {
|
||||||
|
start: Date;
|
||||||
|
end: Date;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mapTimeEntryCreateDtoToTimeEntryCreate = (dto: TimeEntryCreateDto): TimeEntryCreate => ({
|
||||||
|
...dto,
|
||||||
|
start: new Date(dto.start),
|
||||||
|
end: new Date(dto.end),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type TimeEntryUpdate = Omit<TimeEntryUpdateDto, "start" | "end"> & {
|
||||||
|
start?: Date;
|
||||||
|
end?: Date;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const mapTimeEntryUpdateDtoToTimeEntryUpdate = (dto: TimeEntryUpdateDto): TimeEntryUpdate => ({
|
||||||
|
...dto,
|
||||||
|
start: dto.start ? new Date(dto.start) : undefined,
|
||||||
|
end: dto.end ? new Date(dto.end) : undefined,
|
||||||
|
});
|
19
frontend/src/types/user.ts
Normal file
19
frontend/src/types/user.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { UserDto, UserCreateDto, UserUpdateDto } from "./dto";
|
||||||
|
|
||||||
|
export type User = Omit<UserDto, never>;
|
||||||
|
|
||||||
|
export const mapUserDtoToUser = (dto: UserDto): User => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserCreate = Omit<UserCreateDto, never>;
|
||||||
|
|
||||||
|
export const mapUserCreateDtoToUserCreate = (dto: UserCreateDto): UserCreate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserUpdate = Omit<UserUpdateDto, never>;
|
||||||
|
|
||||||
|
export const mapUserUpdateDtoToUserUpdate = (dto: UserUpdateDto): UserUpdate => ({
|
||||||
|
...dto,
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user