Compare commits
No commits in common. "e98d2c65094efa8a5bb52b70102905287b1c5e1e" and "cb9fba6fbc5f2ec5e9b581bdea6cddde9508b071" have entirely different histories.
e98d2c6509
...
cb9fba6fbc
20 changed files with 283 additions and 461 deletions
|
|
@ -20,9 +20,9 @@ jobs:
|
||||||
go-version: '^1.25'
|
go-version: '^1.25'
|
||||||
check-latest: false
|
check-latest: false
|
||||||
cache-dependency-path: |
|
cache-dependency-path: |
|
||||||
go.sum
|
modules/backend/go.sum
|
||||||
|
|
||||||
- name: Build backend
|
- name: Build Go app
|
||||||
run: |
|
run: |
|
||||||
cd modules/backend
|
cd modules/backend
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
@ -35,19 +35,6 @@ jobs:
|
||||||
name: nyanimedb-backend.tar.gz
|
name: nyanimedb-backend.tar.gz
|
||||||
path: modules/backend/nyanimedb-backend.tar.gz
|
path: modules/backend/nyanimedb-backend.tar.gz
|
||||||
|
|
||||||
- name: Build auth
|
|
||||||
run: |
|
|
||||||
cd modules/auth
|
|
||||||
go mod tidy
|
|
||||||
go build -o auth .
|
|
||||||
tar -czvf nyanimedb-auth.tar.gz auth
|
|
||||||
|
|
||||||
- name: Upload built auth to artifactory
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: nyanimedb-auth.tar.gz
|
|
||||||
path: modules/auth/nyanimedb-auth.tar.gz
|
|
||||||
|
|
||||||
# Build frontend
|
# Build frontend
|
||||||
- uses: actions/setup-node@v5
|
- uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -89,14 +76,6 @@ jobs:
|
||||||
push: true
|
push: true
|
||||||
tags: meowgit.nekoea.red/nihonium/nyanimedb-backend:latest
|
tags: meowgit.nekoea.red/nihonium/nyanimedb-backend:latest
|
||||||
|
|
||||||
- name: Build and push auth image
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: Dockerfiles/Dockerfile_auth
|
|
||||||
push: true
|
|
||||||
tags: meowgit.nekoea.red/nihonium/nyanimedb-auth:latest
|
|
||||||
|
|
||||||
- name: Build and push frontend image
|
- name: Build and push frontend image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -11,52 +11,52 @@ paths:
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/cursor'
|
- $ref: '#/components/parameters/cursor'
|
||||||
- $ref: '#/components/parameters/title_sort'
|
- $ref: '#/components/parameters/title_sort'
|
||||||
- name: sort_forward
|
- in: query
|
||||||
in: query
|
name: sort_forward
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
- name: word
|
- in: query
|
||||||
in: query
|
name: word
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
- name: status
|
- in: query
|
||||||
in: query
|
name: status
|
||||||
description: List of title statuses to filter
|
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/TitleStatus'
|
$ref: '#/components/schemas/TitleStatus'
|
||||||
explode: false
|
description: List of title statuses to filter
|
||||||
style: form
|
style: form
|
||||||
- name: rating
|
explode: false
|
||||||
in: query
|
- in: query
|
||||||
|
name: rating
|
||||||
schema:
|
schema:
|
||||||
type: number
|
type: number
|
||||||
format: double
|
format: double
|
||||||
- name: release_year
|
- in: query
|
||||||
in: query
|
name: release_year
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
- name: release_season
|
- in: query
|
||||||
in: query
|
name: release_season
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/ReleaseSeason'
|
$ref: '#/components/schemas/ReleaseSeason'
|
||||||
- name: limit
|
- in: query
|
||||||
in: query
|
name: limit
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
default: 10
|
default: 10
|
||||||
- name: offset
|
- in: query
|
||||||
in: query
|
name: offset
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
default: 0
|
default: 0
|
||||||
- name: fields
|
- in: query
|
||||||
in: query
|
name: fields
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
default: all
|
default: all
|
||||||
|
|
@ -69,10 +69,10 @@ paths:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
data:
|
data:
|
||||||
description: List of titles
|
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/Title'
|
$ref: '#/components/schemas/Title'
|
||||||
|
description: List of titles
|
||||||
cursor:
|
cursor:
|
||||||
$ref: '#/components/schemas/CursorObj'
|
$ref: '#/components/schemas/CursorObj'
|
||||||
required:
|
required:
|
||||||
|
|
@ -86,17 +86,16 @@ paths:
|
||||||
description: Unknown server error
|
description: Unknown server error
|
||||||
'/titles/{title_id}':
|
'/titles/{title_id}':
|
||||||
get:
|
get:
|
||||||
operationId: getTitle
|
|
||||||
summary: Get title description
|
summary: Get title description
|
||||||
parameters:
|
parameters:
|
||||||
- name: title_id
|
- in: path
|
||||||
in: path
|
name: title_id
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
- name: fields
|
- in: query
|
||||||
in: query
|
name: fields
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
default: all
|
default: all
|
||||||
|
|
@ -117,16 +116,15 @@ paths:
|
||||||
description: Unknown server error
|
description: Unknown server error
|
||||||
'/users/{user_id}':
|
'/users/{user_id}':
|
||||||
get:
|
get:
|
||||||
operationId: getUsersId
|
|
||||||
summary: Get user info
|
summary: Get user info
|
||||||
parameters:
|
parameters:
|
||||||
- name: user_id
|
- in: path
|
||||||
in: path
|
name: user_id
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
- name: fields
|
- in: query
|
||||||
in: query
|
name: fields
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
default: all
|
default: all
|
||||||
|
|
@ -144,59 +142,59 @@ paths:
|
||||||
'500':
|
'500':
|
||||||
description: Unknown server error
|
description: Unknown server error
|
||||||
patch:
|
patch:
|
||||||
operationId: updateUser
|
|
||||||
summary: Partially update a user account
|
summary: Partially update a user account
|
||||||
description: |
|
description: |
|
||||||
Update selected user profile fields (excluding password).
|
Update selected user profile fields (excluding password).
|
||||||
Password updates must be done via the dedicated auth-service (`/auth/`).
|
Password updates must be done via the dedicated auth-service (`/auth/`).
|
||||||
Fields not provided in the request body remain unchanged.
|
Fields not provided in the request body remain unchanged.
|
||||||
|
operationId: updateUser
|
||||||
parameters:
|
parameters:
|
||||||
- name: user_id
|
- name: user_id
|
||||||
in: path
|
in: path
|
||||||
description: User ID (primary key)
|
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
description: User ID (primary key)
|
||||||
example: 123
|
example: 123
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
description: Only provided fields are updated. Omitted fields remain unchanged.
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
avatar_id:
|
avatar_id:
|
||||||
description: ID of the user avatar (references `images.id`); set to `null` to remove avatar
|
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
example: 42
|
|
||||||
nullable: true
|
nullable: true
|
||||||
|
description: ID of the user avatar (references `images.id`); set to `null` to remove avatar
|
||||||
|
example: 42
|
||||||
mail:
|
mail:
|
||||||
description: User email (must be unique and valid)
|
|
||||||
type: string
|
type: string
|
||||||
format: email
|
format: email
|
||||||
example: john.doe.updated@example.com
|
|
||||||
pattern: '^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.[a-zA-Z0-9_-]+$'
|
pattern: '^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.[a-zA-Z0-9_-]+$'
|
||||||
|
description: User email (must be unique and valid)
|
||||||
|
example: john.doe.updated@example.com
|
||||||
nickname:
|
nickname:
|
||||||
description: 'Username (alphanumeric + `_` or `-`, 3–16 chars)'
|
|
||||||
type: string
|
type: string
|
||||||
example: john_doe_43
|
pattern: '^[a-zA-Z0-9_-]{3,16}$'
|
||||||
|
description: 'Username (alphanumeric + `_` or `-`, 3–16 chars)'
|
||||||
maxLength: 16
|
maxLength: 16
|
||||||
minLength: 3
|
minLength: 3
|
||||||
pattern: '^[a-zA-Z0-9_-]{3,16}$'
|
example: john_doe_43
|
||||||
disp_name:
|
disp_name:
|
||||||
|
type: string
|
||||||
description: Display name
|
description: Display name
|
||||||
type: string
|
|
||||||
example: John Smith
|
|
||||||
maxLength: 32
|
maxLength: 32
|
||||||
|
example: John Smith
|
||||||
user_desc:
|
user_desc:
|
||||||
description: User description / bio
|
|
||||||
type: string
|
type: string
|
||||||
example: Just a curious developer.
|
description: User description / bio
|
||||||
maxLength: 512
|
maxLength: 512
|
||||||
|
example: Just a curious developer.
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
description: Only provided fields are updated. Omitted fields remain unchanged.
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: User updated successfully. Returns updated user representation (excluding sensitive fields).
|
description: User updated successfully. Returns updated user representation (excluding sensitive fields).
|
||||||
|
|
@ -224,64 +222,64 @@ paths:
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/cursor'
|
- $ref: '#/components/parameters/cursor'
|
||||||
- $ref: '#/components/parameters/title_sort'
|
- $ref: '#/components/parameters/title_sort'
|
||||||
- name: user_id
|
- in: path
|
||||||
in: path
|
name: user_id
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
- name: sort_forward
|
- in: query
|
||||||
in: query
|
name: sort_forward
|
||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
- name: word
|
- in: query
|
||||||
in: query
|
name: word
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
- name: status
|
- in: query
|
||||||
in: query
|
name: status
|
||||||
description: List of title statuses to filter
|
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/TitleStatus'
|
$ref: '#/components/schemas/TitleStatus'
|
||||||
explode: false
|
description: List of title statuses to filter
|
||||||
style: form
|
style: form
|
||||||
- name: watch_status
|
explode: false
|
||||||
in: query
|
- in: query
|
||||||
|
name: watch_status
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/UserTitleStatus'
|
$ref: '#/components/schemas/UserTitleStatus'
|
||||||
explode: false
|
|
||||||
style: form
|
style: form
|
||||||
- name: rating
|
explode: false
|
||||||
in: query
|
- in: query
|
||||||
|
name: rating
|
||||||
schema:
|
schema:
|
||||||
type: number
|
type: number
|
||||||
format: double
|
format: double
|
||||||
- name: my_rate
|
- in: query
|
||||||
in: query
|
name: my_rate
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
- name: release_year
|
- in: query
|
||||||
in: query
|
name: release_year
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
- name: release_season
|
- in: query
|
||||||
in: query
|
name: release_season
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/ReleaseSeason'
|
$ref: '#/components/schemas/ReleaseSeason'
|
||||||
- name: limit
|
- in: query
|
||||||
in: query
|
name: limit
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
default: 10
|
default: 10
|
||||||
- name: fields
|
- in: query
|
||||||
in: query
|
name: fields
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
default: all
|
default: all
|
||||||
|
|
@ -311,17 +309,17 @@ paths:
|
||||||
'500':
|
'500':
|
||||||
description: Unknown server error
|
description: Unknown server error
|
||||||
post:
|
post:
|
||||||
operationId: addUserTitle
|
|
||||||
summary: Add a title to a user
|
summary: Add a title to a user
|
||||||
description: 'User adding title to list af watched, status required'
|
description: 'User adding title to list af watched, status required'
|
||||||
|
operationId: addUserTitle
|
||||||
parameters:
|
parameters:
|
||||||
- name: user_id
|
- name: user_id
|
||||||
in: path
|
in: path
|
||||||
description: ID of the user to assign the title to
|
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
description: ID of the user to assign the title to
|
||||||
example: 123
|
example: 123
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -329,6 +327,9 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- title_id
|
||||||
|
- status
|
||||||
properties:
|
properties:
|
||||||
title_id:
|
title_id:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
@ -338,16 +339,36 @@ paths:
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
required:
|
|
||||||
- title_id
|
|
||||||
- status
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully added to user
|
description: Title successfully added to user
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/UserTitleMini'
|
type: object
|
||||||
|
required:
|
||||||
|
- user_id
|
||||||
|
- title_id
|
||||||
|
- status
|
||||||
|
properties:
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
title_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
status:
|
||||||
|
$ref: '#/components/schemas/UserTitleStatus'
|
||||||
|
rate:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
review_id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
ctime:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
additionalProperties: false
|
||||||
'400':
|
'400':
|
||||||
description: 'Invalid request body (missing fields, invalid types, etc.)'
|
description: 'Invalid request body (missing fields, invalid types, etc.)'
|
||||||
'401':
|
'401':
|
||||||
|
|
@ -361,17 +382,17 @@ paths:
|
||||||
'500':
|
'500':
|
||||||
description: Internal server error
|
description: Internal server error
|
||||||
patch:
|
patch:
|
||||||
operationId: updateUserTitle
|
|
||||||
summary: Update a usertitle
|
summary: Update a usertitle
|
||||||
description: User updating title list of watched
|
description: User updating title list of watched
|
||||||
|
operationId: updateUserTitle
|
||||||
parameters:
|
parameters:
|
||||||
- name: user_id
|
- name: user_id
|
||||||
in: path
|
in: path
|
||||||
description: ID of the user to assign the title to
|
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
description: ID of the user to assign the title to
|
||||||
example: 123
|
example: 123
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -379,6 +400,8 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- title_id
|
||||||
properties:
|
properties:
|
||||||
title_id:
|
title_id:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
@ -388,15 +411,13 @@ paths:
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
required:
|
|
||||||
- title_id
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully updated
|
description: Title successfully updated
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/UserTitleMini'
|
$ref: '#/paths/~1users~1%7Buser_id%7D~1titles/post/responses/200/content/application~1json/schema'
|
||||||
'400':
|
'400':
|
||||||
description: 'Invalid request body (missing fields, invalid types, etc.)'
|
description: 'Invalid request body (missing fields, invalid types, etc.)'
|
||||||
'401':
|
'401':
|
||||||
|
|
@ -422,36 +443,25 @@ components:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/TitleSort'
|
$ref: '#/components/schemas/TitleSort'
|
||||||
schemas:
|
schemas:
|
||||||
TitleSort:
|
CursorObj:
|
||||||
description: Title sort order
|
type: object
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
param:
|
||||||
type: string
|
type: string
|
||||||
|
TitleSort:
|
||||||
|
type: string
|
||||||
|
description: Title sort order
|
||||||
default: id
|
default: id
|
||||||
enum:
|
enum:
|
||||||
- id
|
- id
|
||||||
- year
|
- year
|
||||||
- rating
|
- rating
|
||||||
- views
|
- views
|
||||||
TitleStatus:
|
|
||||||
description: Title status
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- finished
|
|
||||||
- ongoing
|
|
||||||
- planned
|
|
||||||
ReleaseSeason:
|
|
||||||
description: Title release season
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- winter
|
|
||||||
- spring
|
|
||||||
- summer
|
|
||||||
- fall
|
|
||||||
StorageType:
|
|
||||||
description: Image storage type
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- s3
|
|
||||||
- local
|
|
||||||
Image:
|
Image:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|
@ -459,11 +469,65 @@ components:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
storage_type:
|
storage_type:
|
||||||
$ref: '#/components/schemas/StorageType'
|
type: string
|
||||||
|
description: Image storage type
|
||||||
|
enum:
|
||||||
|
- s3
|
||||||
|
- local
|
||||||
image_path:
|
image_path:
|
||||||
type: string
|
type: string
|
||||||
|
TitleStatus:
|
||||||
|
type: string
|
||||||
|
description: Title status
|
||||||
|
enum:
|
||||||
|
- finished
|
||||||
|
- ongoing
|
||||||
|
- planned
|
||||||
|
ReleaseSeason:
|
||||||
|
type: string
|
||||||
|
description: Title release season
|
||||||
|
enum:
|
||||||
|
- winter
|
||||||
|
- spring
|
||||||
|
- summer
|
||||||
|
- fall
|
||||||
|
UserTitleStatus:
|
||||||
|
type: string
|
||||||
|
description: User's title status
|
||||||
|
enum:
|
||||||
|
- finished
|
||||||
|
- planned
|
||||||
|
- dropped
|
||||||
|
- in-progress
|
||||||
|
Review:
|
||||||
|
type: object
|
||||||
|
additionalProperties: true
|
||||||
|
Tag:
|
||||||
|
type: object
|
||||||
|
description: 'A localized tag: keys are language codes (ISO 639-1), values are tag names'
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
example:
|
||||||
|
en: Shojo
|
||||||
|
ru: Сёдзё
|
||||||
|
ja: 少女
|
||||||
|
Tags:
|
||||||
|
type: array
|
||||||
|
description: Array of localized tags
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Tag'
|
||||||
|
example:
|
||||||
|
- en: Shojo
|
||||||
|
ru: Сёдзё
|
||||||
|
ja: 少女
|
||||||
|
- en: Shounen
|
||||||
|
ru: Сёнен
|
||||||
|
ja: 少年
|
||||||
Studio:
|
Studio:
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- name
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
@ -474,50 +538,21 @@ components:
|
||||||
$ref: '#/components/schemas/Image'
|
$ref: '#/components/schemas/Image'
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- name
|
|
||||||
Tag:
|
|
||||||
description: 'A localized tag: keys are language codes (ISO 639-1), values are tag names'
|
|
||||||
type: object
|
|
||||||
example:
|
|
||||||
en: Shojo
|
|
||||||
ru: Сёдзё
|
|
||||||
ja: 少女
|
|
||||||
additionalProperties:
|
|
||||||
type: string
|
|
||||||
Tags:
|
|
||||||
description: Array of localized tags
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Tag'
|
|
||||||
example:
|
|
||||||
- en: Shojo
|
|
||||||
ru: Сёдзё
|
|
||||||
ja: 少女
|
|
||||||
- en: Shounen
|
|
||||||
ru: Сёнен
|
|
||||||
ja: 少年
|
|
||||||
Title:
|
Title:
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- title_names
|
||||||
|
- tags
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
description: Unique title ID (primary key)
|
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
description: Unique title ID (primary key)
|
||||||
example: 1
|
example: 1
|
||||||
title_names:
|
title_names:
|
||||||
description: 'Localized titles. Key = language (ISO 639-1), value = list of names'
|
|
||||||
type: object
|
type: object
|
||||||
example:
|
description: 'Localized titles. Key = language (ISO 639-1), value = list of names'
|
||||||
en:
|
|
||||||
- Attack on Titan
|
|
||||||
- AoT
|
|
||||||
ru:
|
|
||||||
- Атака титанов
|
|
||||||
- Титаны
|
|
||||||
ja:
|
|
||||||
- 進撃の巨人
|
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
|
@ -527,6 +562,15 @@ components:
|
||||||
example:
|
example:
|
||||||
- Attack on Titan
|
- Attack on Titan
|
||||||
- AoT
|
- AoT
|
||||||
|
example:
|
||||||
|
en:
|
||||||
|
- Attack on Titan
|
||||||
|
- AoT
|
||||||
|
ru:
|
||||||
|
- Атака титанов
|
||||||
|
- Титаны
|
||||||
|
ja:
|
||||||
|
- 進撃の巨人
|
||||||
studio:
|
studio:
|
||||||
$ref: '#/components/schemas/Studio'
|
$ref: '#/components/schemas/Studio'
|
||||||
tags:
|
tags:
|
||||||
|
|
@ -557,68 +601,51 @@ components:
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: number
|
type: number
|
||||||
format: double
|
format: double
|
||||||
required:
|
additionalProperties: true
|
||||||
- id
|
|
||||||
- title_names
|
|
||||||
- tags
|
|
||||||
CursorObj:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
param:
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
User:
|
User:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
description: Unique user ID (primary key)
|
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
description: Unique user ID (primary key)
|
||||||
example: 1
|
example: 1
|
||||||
image:
|
image:
|
||||||
$ref: '#/components/schemas/Image'
|
$ref: '#/components/schemas/Image'
|
||||||
mail:
|
mail:
|
||||||
description: User email
|
|
||||||
type: string
|
type: string
|
||||||
format: email
|
format: email
|
||||||
|
description: User email
|
||||||
example: john.doe@example.com
|
example: john.doe@example.com
|
||||||
nickname:
|
nickname:
|
||||||
|
type: string
|
||||||
description: Username (alphanumeric + _ or -)
|
description: Username (alphanumeric + _ or -)
|
||||||
type: string
|
|
||||||
example: john_doe_42
|
|
||||||
maxLength: 16
|
maxLength: 16
|
||||||
|
example: john_doe_42
|
||||||
disp_name:
|
disp_name:
|
||||||
|
type: string
|
||||||
description: Display name
|
description: Display name
|
||||||
type: string
|
|
||||||
example: John Doe
|
|
||||||
maxLength: 32
|
maxLength: 32
|
||||||
|
example: John Doe
|
||||||
user_desc:
|
user_desc:
|
||||||
description: User description
|
|
||||||
type: string
|
type: string
|
||||||
example: Just a regular user.
|
description: User description
|
||||||
maxLength: 512
|
maxLength: 512
|
||||||
|
example: Just a regular user.
|
||||||
creation_date:
|
creation_date:
|
||||||
description: Timestamp when the user was created
|
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
description: Timestamp when the user was created
|
||||||
example: '2025-10-10T23:45:47.908073Z'
|
example: '2025-10-10T23:45:47.908073Z'
|
||||||
required:
|
required:
|
||||||
- user_id
|
- user_id
|
||||||
- nickname
|
- nickname
|
||||||
UserTitleStatus:
|
|
||||||
description: User's title status
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- finished
|
|
||||||
- planned
|
|
||||||
- dropped
|
|
||||||
- in-progress
|
|
||||||
UserTitle:
|
UserTitle:
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- user_id
|
||||||
|
- title_id
|
||||||
|
- status
|
||||||
properties:
|
properties:
|
||||||
user_id:
|
user_id:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
@ -636,34 +663,3 @@ components:
|
||||||
ctime:
|
ctime:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
required:
|
|
||||||
- user_id
|
|
||||||
- title_id
|
|
||||||
- status
|
|
||||||
UserTitleMini:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
user_id:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
title_id:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
status:
|
|
||||||
$ref: '#/components/schemas/UserTitleStatus'
|
|
||||||
rate:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
review_id:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
ctime:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
required:
|
|
||||||
- user_id
|
|
||||||
- title_id
|
|
||||||
- status
|
|
||||||
Review:
|
|
||||||
type: object
|
|
||||||
additionalProperties: true
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
get:
|
get:
|
||||||
summary: Get title description
|
summary: Get title description
|
||||||
operationId: getTitle
|
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: title_id
|
name: title_id
|
||||||
|
|
|
||||||
|
|
@ -117,10 +117,11 @@ post:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
status:
|
status:
|
||||||
$ref: '../schemas/enums/UserTitleStatus.yaml'
|
$ref: ../schemas/enums/UserTitleStatus.yaml
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Title successfully added to user
|
description: Title successfully added to user
|
||||||
|
|
@ -128,6 +129,7 @@ post:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '../schemas/UserTitleMini.yaml'
|
$ref: '../schemas/UserTitleMini.yaml'
|
||||||
|
|
||||||
'400':
|
'400':
|
||||||
description: Invalid request body (missing fields, invalid types, etc.)
|
description: Invalid request body (missing fields, invalid types, etc.)
|
||||||
'401':
|
'401':
|
||||||
|
|
@ -167,7 +169,7 @@ patch:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
status:
|
status:
|
||||||
$ref: '../schemas/enums/UserTitleStatus.yaml'
|
$ref: ../schemas/enums/UserTitleStatus.yaml
|
||||||
rate:
|
rate:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
|
@ -179,6 +181,7 @@ patch:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '../schemas/UserTitleMini.yaml'
|
$ref: '../schemas/UserTitleMini.yaml'
|
||||||
|
|
||||||
'400':
|
'400':
|
||||||
description: Invalid request body (missing fields, invalid types, etc.)
|
description: Invalid request body (missing fields, invalid types, etc.)
|
||||||
'401':
|
'401':
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
get:
|
get:
|
||||||
summary: Get user info
|
summary: Get user info
|
||||||
operationId: getUsersId
|
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: user_id
|
name: user_id
|
||||||
|
|
|
||||||
|
|
@ -60,3 +60,4 @@ properties:
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: number
|
type: number
|
||||||
format: double
|
format: double
|
||||||
|
additionalProperties: true
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,4 @@ properties:
|
||||||
ctime:
|
ctime:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
additionalProperties: false
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import React from "react";
|
||||||
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
||||||
import UsersIdPage from "./pages/UsersIdPage/UsersIdPage";
|
import UsersIdPage from "./pages/UsersIdPage/UsersIdPage";
|
||||||
import TitlesPage from "./pages/TitlesPage/TitlesPage";
|
import TitlesPage from "./pages/TitlesPage/TitlesPage";
|
||||||
import TitlePage from "./pages/TitlePage/TitlePage";
|
|
||||||
import { LoginPage } from "./pages/LoginPage/LoginPage";
|
import { LoginPage } from "./pages/LoginPage/LoginPage";
|
||||||
import { Header } from "./components/Header/Header";
|
import { Header } from "./components/Header/Header";
|
||||||
|
|
||||||
|
|
@ -25,9 +24,7 @@ const App: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Route path="/users/:id" element={<UsersIdPage />} />
|
<Route path="/users/:id" element={<UsersIdPage />} />
|
||||||
|
|
||||||
<Route path="/titles" element={<TitlesPage />} />
|
<Route path="/titles" element={<TitlesPage />} />
|
||||||
<Route path="/titles/:id" element={<TitlePage />} />
|
|
||||||
</Routes>
|
</Routes>
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export type OpenAPIConfig = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const OpenAPI: OpenAPIConfig = {
|
export const OpenAPI: OpenAPIConfig = {
|
||||||
BASE: 'http://10.1.0.65:8081/api/v1',
|
BASE: '/api/v1',
|
||||||
VERSION: '1.0.0',
|
VERSION: '1.0.0',
|
||||||
WITH_CREDENTIALS: false,
|
WITH_CREDENTIALS: false,
|
||||||
CREDENTIALS: 'include',
|
CREDENTIALS: 'include',
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ export type { CursorObj } from './models/CursorObj';
|
||||||
export type { Image } from './models/Image';
|
export type { Image } from './models/Image';
|
||||||
export type { ReleaseSeason } from './models/ReleaseSeason';
|
export type { ReleaseSeason } from './models/ReleaseSeason';
|
||||||
export type { Review } from './models/Review';
|
export type { Review } from './models/Review';
|
||||||
export type { StorageType } from './models/StorageType';
|
|
||||||
export type { Studio } from './models/Studio';
|
export type { Studio } from './models/Studio';
|
||||||
export type { Tag } from './models/Tag';
|
export type { Tag } from './models/Tag';
|
||||||
export type { Tags } from './models/Tags';
|
export type { Tags } from './models/Tags';
|
||||||
|
|
@ -22,7 +21,6 @@ export type { TitleSort } from './models/TitleSort';
|
||||||
export type { TitleStatus } from './models/TitleStatus';
|
export type { TitleStatus } from './models/TitleStatus';
|
||||||
export type { User } from './models/User';
|
export type { User } from './models/User';
|
||||||
export type { UserTitle } from './models/UserTitle';
|
export type { UserTitle } from './models/UserTitle';
|
||||||
export type { UserTitleMini } from './models/UserTitleMini';
|
|
||||||
export type { UserTitleStatus } from './models/UserTitleStatus';
|
export type { UserTitleStatus } from './models/UserTitleStatus';
|
||||||
|
|
||||||
export { DefaultService } from './services/DefaultService';
|
export { DefaultService } from './services/DefaultService';
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,12 @@
|
||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import type { StorageType } from './StorageType';
|
|
||||||
export type Image = {
|
export type Image = {
|
||||||
id?: number;
|
id?: number;
|
||||||
storage_type?: StorageType;
|
/**
|
||||||
|
* Image storage type
|
||||||
|
*/
|
||||||
|
storage_type?: 's3' | 'local';
|
||||||
image_path?: string;
|
image_path?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* Image storage type
|
|
||||||
*/
|
|
||||||
export type StorageType = 's3' | 'local';
|
|
||||||
|
|
@ -2,30 +2,4 @@
|
||||||
/* istanbul ignore file */
|
/* istanbul ignore file */
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import type { Image } from './Image';
|
export type Title = Record<string, any>;
|
||||||
import type { ReleaseSeason } from './ReleaseSeason';
|
|
||||||
import type { Studio } from './Studio';
|
|
||||||
import type { Tags } from './Tags';
|
|
||||||
import type { TitleStatus } from './TitleStatus';
|
|
||||||
export type Title = {
|
|
||||||
/**
|
|
||||||
* Unique title ID (primary key)
|
|
||||||
*/
|
|
||||||
id: number;
|
|
||||||
/**
|
|
||||||
* Localized titles. Key = language (ISO 639-1), value = list of names
|
|
||||||
*/
|
|
||||||
title_names: Record<string, Array<string>>;
|
|
||||||
studio?: Studio;
|
|
||||||
tags: Tags;
|
|
||||||
poster?: Image;
|
|
||||||
title_status?: TitleStatus;
|
|
||||||
rating?: number;
|
|
||||||
rating_count?: number;
|
|
||||||
release_year?: number;
|
|
||||||
release_season?: ReleaseSeason;
|
|
||||||
episodes_aired?: number;
|
|
||||||
episodes_all?: number;
|
|
||||||
episodes_len?: Record<string, number>;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
/* generated using openapi-typescript-codegen -- do not edit */
|
|
||||||
/* istanbul ignore file */
|
|
||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
import type { UserTitleStatus } from './UserTitleStatus';
|
|
||||||
export type UserTitleMini = {
|
|
||||||
user_id: number;
|
|
||||||
title_id: number;
|
|
||||||
status: UserTitleStatus;
|
|
||||||
rate?: number;
|
|
||||||
review_id?: number;
|
|
||||||
ctime?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -9,7 +9,6 @@ import type { TitleSort } from '../models/TitleSort';
|
||||||
import type { TitleStatus } from '../models/TitleStatus';
|
import type { TitleStatus } from '../models/TitleStatus';
|
||||||
import type { User } from '../models/User';
|
import type { User } from '../models/User';
|
||||||
import type { UserTitle } from '../models/UserTitle';
|
import type { UserTitle } from '../models/UserTitle';
|
||||||
import type { UserTitleMini } from '../models/UserTitleMini';
|
|
||||||
import type { UserTitleStatus } from '../models/UserTitleStatus';
|
import type { UserTitleStatus } from '../models/UserTitleStatus';
|
||||||
import type { CancelablePromise } from '../core/CancelablePromise';
|
import type { CancelablePromise } from '../core/CancelablePromise';
|
||||||
import { OpenAPI } from '../core/OpenAPI';
|
import { OpenAPI } from '../core/OpenAPI';
|
||||||
|
|
@ -79,7 +78,7 @@ export class DefaultService {
|
||||||
* @returns Title Title description
|
* @returns Title Title description
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static getTitle(
|
public static getTitles1(
|
||||||
titleId: number,
|
titleId: number,
|
||||||
fields: string = 'all',
|
fields: string = 'all',
|
||||||
): CancelablePromise<Title> {
|
): CancelablePromise<Title> {
|
||||||
|
|
@ -106,7 +105,7 @@ export class DefaultService {
|
||||||
* @returns User User info
|
* @returns User User info
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static getUsersId(
|
public static getUsers(
|
||||||
userId: string,
|
userId: string,
|
||||||
fields: string = 'all',
|
fields: string = 'all',
|
||||||
): CancelablePromise<User> {
|
): CancelablePromise<User> {
|
||||||
|
|
@ -249,17 +248,22 @@ export class DefaultService {
|
||||||
* User adding title to list af watched, status required
|
* User adding title to list af watched, status required
|
||||||
* @param userId ID of the user to assign the title to
|
* @param userId ID of the user to assign the title to
|
||||||
* @param requestBody
|
* @param requestBody
|
||||||
* @returns UserTitleMini Title successfully added to user
|
* @returns any Title successfully added to user
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static addUserTitle(
|
public static addUserTitle(
|
||||||
userId: number,
|
userId: number,
|
||||||
requestBody: {
|
requestBody: UserTitle,
|
||||||
|
): CancelablePromise<{
|
||||||
|
data?: {
|
||||||
|
user_id: number;
|
||||||
title_id: number;
|
title_id: number;
|
||||||
status: UserTitleStatus;
|
status: UserTitleStatus;
|
||||||
rate?: number;
|
rate?: number;
|
||||||
},
|
review_id?: number;
|
||||||
): CancelablePromise<UserTitleMini> {
|
ctime?: string;
|
||||||
|
};
|
||||||
|
}> {
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/users/{user_id}/titles',
|
url: '/users/{user_id}/titles',
|
||||||
|
|
@ -278,37 +282,4 @@ export class DefaultService {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Update a usertitle
|
|
||||||
* User updating title list of watched
|
|
||||||
* @param userId ID of the user to assign the title to
|
|
||||||
* @param requestBody
|
|
||||||
* @returns UserTitleMini Title successfully updated
|
|
||||||
* @throws ApiError
|
|
||||||
*/
|
|
||||||
public static updateUserTitle(
|
|
||||||
userId: number,
|
|
||||||
requestBody: {
|
|
||||||
title_id: number;
|
|
||||||
status?: UserTitleStatus;
|
|
||||||
rate?: number;
|
|
||||||
},
|
|
||||||
): CancelablePromise<UserTitleMini> {
|
|
||||||
return __request(OpenAPI, {
|
|
||||||
method: 'PATCH',
|
|
||||||
url: '/users/{user_id}/titles',
|
|
||||||
path: {
|
|
||||||
'user_id': userId,
|
|
||||||
},
|
|
||||||
body: requestBody,
|
|
||||||
mediaType: 'application/json',
|
|
||||||
errors: {
|
|
||||||
400: `Invalid request body (missing fields, invalid types, etc.)`,
|
|
||||||
401: `Unauthorized — missing or invalid auth token`,
|
|
||||||
403: `Forbidden — user not allowed to update title`,
|
|
||||||
404: `User or Title not found`,
|
|
||||||
500: `Internal server error`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export type OpenAPIConfig = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const OpenAPI: OpenAPIConfig = {
|
export const OpenAPI: OpenAPIConfig = {
|
||||||
BASE: 'http://10.1.0.65:8081/auth',
|
BASE: '/auth',
|
||||||
VERSION: '1.0.0',
|
VERSION: '1.0.0',
|
||||||
WITH_CREDENTIALS: false,
|
WITH_CREDENTIALS: false,
|
||||||
CREDENTIALS: 'include',
|
CREDENTIALS: 'include',
|
||||||
|
|
|
||||||
|
|
@ -1,140 +1,64 @@
|
||||||
import { useEffect, useState } from "react";
|
// import React, { useEffect, useState } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
// import { useParams } from "react-router-dom";
|
||||||
import { DefaultService } from "../../api/services/DefaultService";
|
// import { DefaultService } from "../../api/services/DefaultService";
|
||||||
import type { Title, UserTitleStatus } from "../../api";
|
// import type { User } from "../../api/models/User";
|
||||||
import {
|
// import styles from "./UserPage.module.css";
|
||||||
ClockIcon,
|
|
||||||
CheckCircleIcon,
|
|
||||||
PlayCircleIcon,
|
|
||||||
XCircleIcon,
|
|
||||||
} from "@heroicons/react/24/solid";
|
|
||||||
|
|
||||||
const STATUS_BUTTONS: { status: UserTitleStatus; icon: React.ReactNode; label: string }[] = [
|
// const UserPage: React.FC = () => {
|
||||||
{ status: "planned", icon: <ClockIcon className="w-6 h-6" />, label: "Planned" },
|
// const { id } = useParams<{ id: string }>();
|
||||||
{ status: "finished", icon: <CheckCircleIcon className="w-6 h-6" />, label: "Finished" },
|
// const [user, setUser] = useState<User | null>(null);
|
||||||
{ status: "in-progress", icon: <PlayCircleIcon className="w-6 h-6" />, label: "In Progress" },
|
// const [loading, setLoading] = useState(true);
|
||||||
{ status: "dropped", icon: <XCircleIcon className="w-6 h-6" />, label: "Dropped" },
|
// const [error, setError] = useState<string | null>(null);
|
||||||
];
|
|
||||||
|
|
||||||
export default function TitlePage() {
|
// useEffect(() => {
|
||||||
const params = useParams();
|
// if (!id) return;
|
||||||
const titleId = Number(params.id);
|
|
||||||
|
|
||||||
const [title, setTitle] = useState<Title | null>(null);
|
// const getTitleInfo = async () => {
|
||||||
const [loading, setLoading] = useState(true);
|
// try {
|
||||||
const [error, setError] = useState<string | null>(null);
|
// const userInfo = await DefaultService.getTitle(id, "all");
|
||||||
|
// setUser(userInfo);
|
||||||
|
// } catch (err) {
|
||||||
|
// console.error(err);
|
||||||
|
// setError("Failed to fetch user info.");
|
||||||
|
// } finally {
|
||||||
|
// setLoading(false);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// getTitleInfo();
|
||||||
|
// }, [id]);
|
||||||
|
|
||||||
const [userStatus, setUserStatus] = useState<UserTitleStatus | null>(null);
|
// if (loading) return <div className={styles.loader}>Loading...</div>;
|
||||||
const [updatingStatus, setUpdatingStatus] = useState(false);
|
// if (error) return <div className={styles.error}>{error}</div>;
|
||||||
|
// if (!user) return <div className={styles.error}>User not found.</div>;
|
||||||
|
|
||||||
useEffect(() => {
|
// return (
|
||||||
const fetchTitle = async () => {
|
// <div className={styles.container}>
|
||||||
setLoading(true);
|
// <div className={styles.card}>
|
||||||
try {
|
// <div className={styles.avatar}>
|
||||||
const data = await DefaultService.getTitle(titleId, "all");
|
// {user.avatar_id ? (
|
||||||
setTitle(data);
|
// <img
|
||||||
setError(null);
|
// src={`/images/${user.avatar_id}.png`}
|
||||||
} catch (err: any) {
|
// alt="User Avatar"
|
||||||
console.error(err);
|
// className={styles.avatarImg}
|
||||||
setError(err?.message || "Failed to fetch title");
|
// />
|
||||||
} finally {
|
// ) : (
|
||||||
setLoading(false);
|
// <div className={styles.avatarPlaceholder}>
|
||||||
}
|
// {user.disp_name?.[0] || "U"}
|
||||||
};
|
// </div>
|
||||||
fetchTitle();
|
// )}
|
||||||
}, [titleId]);
|
// </div>
|
||||||
|
|
||||||
const handleStatusClick = async (status: UserTitleStatus) => {
|
// <div className={styles.info}>
|
||||||
if (updatingStatus || userStatus === status) return;
|
// <h1 className={styles.name}>{user.disp_name || user.nickname}</h1>
|
||||||
|
// <p className={styles.nickname}>@{user.nickname}</p>
|
||||||
|
// {user.user_desc && <p className={styles.desc}>{user.user_desc}</p>}
|
||||||
|
// <p className={styles.created}>
|
||||||
|
// Joined: {new Date(user.creation_date).toLocaleDateString()}
|
||||||
|
// </p>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
|
||||||
const userId = Number(localStorage.getItem("userId"));
|
// export default UserPage;
|
||||||
if (!userId) {
|
|
||||||
alert("You must be logged in to set status.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setUpdatingStatus(true);
|
|
||||||
try {
|
|
||||||
await DefaultService.addUserTitle(userId, {
|
|
||||||
title_id: titleId,
|
|
||||||
status,
|
|
||||||
});
|
|
||||||
setUserStatus(status);
|
|
||||||
} catch (err: any) {
|
|
||||||
console.error(err);
|
|
||||||
alert(err?.message || "Failed to set status");
|
|
||||||
} finally {
|
|
||||||
setUpdatingStatus(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getTagsString = () =>
|
|
||||||
title?.tags?.map(tag => tag.en).filter(Boolean).join(", ");
|
|
||||||
|
|
||||||
if (loading) return <div className="mt-20 font-medium text-black">Loading title...</div>;
|
|
||||||
if (error) return <div className="mt-20 text-red-600 font-medium">{error}</div>;
|
|
||||||
if (!title) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-full min-h-screen bg-gray-50 p-6 flex justify-center">
|
|
||||||
<div className="flex flex-col md:flex-row bg-white shadow-lg rounded-xl max-w-4xl w-full p-6 gap-6">
|
|
||||||
{/* Постер */}
|
|
||||||
<div className="flex flex-col items-center">
|
|
||||||
<img
|
|
||||||
src={title.poster?.image_path || "/default-poster.png"}
|
|
||||||
alt={title.title_names?.en?.[0] || "Title poster"}
|
|
||||||
className="w-48 h-72 object-cover rounded-lg mb-4"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Статус кнопки с иконками */}
|
|
||||||
<div className="flex gap-2 mt-2 flex-wrap justify-center">
|
|
||||||
{STATUS_BUTTONS.map(btn => (
|
|
||||||
<button
|
|
||||||
key={btn.status}
|
|
||||||
onClick={() => handleStatusClick(btn.status)}
|
|
||||||
disabled={updatingStatus}
|
|
||||||
className={`p-2 rounded-lg transition flex items-center justify-center ${
|
|
||||||
userStatus === btn.status
|
|
||||||
? "bg-blue-600 text-white"
|
|
||||||
: "bg-gray-200 text-gray-700 hover:bg-gray-300"
|
|
||||||
}`}
|
|
||||||
title={btn.label}
|
|
||||||
>
|
|
||||||
{btn.icon}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Информация о тайтле */}
|
|
||||||
<div className="flex-1 flex flex-col">
|
|
||||||
<h1 className="text-3xl font-bold mb-2">
|
|
||||||
{title.title_names?.en?.[0] || "Untitled"}
|
|
||||||
</h1>
|
|
||||||
{title.studio && <p className="text-gray-700 mb-1">Studio: {title.studio.name}</p>}
|
|
||||||
{title.title_status && <p className="text-gray-700 mb-1">Status: {title.title_status}</p>}
|
|
||||||
{title.rating !== undefined && (
|
|
||||||
<p className="text-gray-700 mb-1">
|
|
||||||
Rating: {title.rating} ({title.rating_count} votes)
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
{title.release_year && (
|
|
||||||
<p className="text-gray-700 mb-1">
|
|
||||||
Released: {title.release_year} {title.release_season || ""}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
{title.episodes_aired !== undefined && (
|
|
||||||
<p className="text-gray-700 mb-1">
|
|
||||||
Episodes: {title.episodes_aired}/{title.episodes_all}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
{title.tags && title.tags.length > 0 && (
|
|
||||||
<p className="text-gray-700 mb-1">
|
|
||||||
Tags: {getTagsString()}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ const UserPage: React.FC = () => {
|
||||||
|
|
||||||
const getUserInfo = async () => {
|
const getUserInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const userInfo = await DefaultService.getUsersId(id, "all"); // <-- use dynamic id
|
const userInfo = await DefaultService.getUsers(id, "all"); // <-- use dynamic id
|
||||||
setUser(userInfo);
|
setUser(userInfo);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export default function UsersIdPage({ userId }: UsersIdPageProps) {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
setLoadingUser(true);
|
setLoadingUser(true);
|
||||||
try {
|
try {
|
||||||
const result = await DefaultService.getUsersId(id, "all");
|
const result = await DefaultService.getUsers(id, "all");
|
||||||
setUser(result);
|
setUser(result);
|
||||||
setErrorUser(null);
|
setErrorUser(null);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue