refactor: notifications and settings view models; enhance login and registration UI

This commit is contained in:
2026-03-15 21:40:20 +07:00
parent 0947c048c1
commit 37b87ececd
45 changed files with 985 additions and 680 deletions
+5 -25
View File
@@ -5,23 +5,8 @@ struct LoginResponse: Decodable, Sendable {
let tokens: TokenPair
}
struct RegisterResponse: Decodable, Sendable {
let user: UserResponse
private enum CodingKeys: String, CodingKey {
case id, email, status, metadata, roles
case emailVerifiedAt = "email_verified_at"
case createdAt = "created_at"
case updatedAt = "updated_at"
}
init(from decoder: Decoder) throws {
user = try UserResponse(from: decoder)
}
}
struct VerifyEmailResponse: Decodable, Sendable {
let user: UserResponse
struct MessageResponse: Decodable, Sendable {
let message: String
}
actor AuthService {
@@ -42,13 +27,12 @@ actor AuthService {
return response
}
func verifyEmail(email: String, code: String) async throws -> UserResponse {
let response: VerifyEmailResponse = try await client.request(.verifyEmail(email: email, code: code))
return response.user
func verifyEmail(email: String, code: String) async throws {
let _: MessageResponse = try await client.request(.verifyEmail(email: email, code: code))
}
func resendCode(email: String) async throws {
let _: ResendCodeResponse = try await client.request(.resendCode(email: email))
let _: MessageResponse = try await client.request(.resendCode(email: email))
}
func logout() async throws {
@@ -64,8 +48,4 @@ actor AuthService {
}
}
struct ResendCodeResponse: Decodable, Sendable {
let message: String
}
struct EmptyResponse: Decodable, Sendable {}