Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
886577a8
Commit
886577a8
authored
Jun 15, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update upload API
parent
11afc6d2
Pipeline
#27786
passed with stages
in 8 minutes and 5 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
27 deletions
+51
-27
src/api/mdproDeck/sync.ts
src/api/mdproDeck/sync.ts
+0
-1
src/api/mdproDeck/upload.ts
src/api/mdproDeck/upload.ts
+42
-16
src/ui/BuildDeck/DeckSelect/index.tsx
src/ui/BuildDeck/DeckSelect/index.tsx
+9
-10
No files found.
src/api/mdproDeck/sync.ts
View file @
886577a8
...
@@ -15,7 +15,6 @@ export interface SyncReq {
...
@@ -15,7 +15,6 @@ export interface SyncReq {
deckName
:
string
;
deckName
:
string
;
deckCase
:
number
;
deckCase
:
number
;
deckYdk
:
string
;
deckYdk
:
string
;
isDelete
:
boolean
;
};
};
}
}
...
...
src/api/mdproDeck/upload.ts
View file @
886577a8
import
{
useConfig
}
from
"
@/config
"
;
import
{
generateDeck
}
from
"
./generate
"
;
import
{
MdproResp
}
from
"
./schema
"
;
import
{
syncDeck
}
from
"
./sync
"
;
import
{
updatePublic
}
from
"
./updatePulibc
"
;
import
{
MdproDeck
,
MdproResp
}
from
"
./schema
"
;
export
interface
UploadReq
{
import
{
handleHttps
,
mdproHeaders
}
from
"
./util
"
;
userId
:
number
;
token
:
string
;
const
{
mdproServer
}
=
useConfig
();
deckContributor
:
string
;
const
API_PATH
=
"
api/mdpro3/deck/upload
"
;
deck
:
{
deckName
:
string
;
deckCase
:
number
;
deckYdk
:
string
;
};
}
export
async
function
uploadDeck
(
export
async
function
uploadDeck
(
req
:
MdproDeck
,
req
:
UploadReq
,
):
Promise
<
MdproResp
<
MdproDeck
>
|
undefined
>
{
):
Promise
<
MdproResp
<
void
>
|
undefined
>
{
const
myHeaders
=
mdproHeaders
();
const
deckId
=
await
generateDeck
();
myHeaders
.
append
(
"
Content-Type
"
,
"
application/json
"
)
;
if
(
deckId
===
undefined
)
return
undefined
;
const
resp
=
await
fetch
(
`
${
mdproServer
}
/
${
API_PATH
}
`
,
{
const
syncRes
=
await
syncDeck
({
method
:
"
POST
"
,
userId
:
req
.
userId
,
headers
:
myHeaders
,
token
:
req
.
token
,
body
:
JSON
.
stringify
(
req
),
deckContributor
:
req
.
deckContributor
,
redirect
:
"
follow
"
,
deck
:
{
deckId
,
deckName
:
req
.
deck
.
deckName
,
deckCase
:
req
.
deck
.
deckCase
,
deckYdk
:
req
.
deck
.
deckYdk
,
},
});
});
return
await
handleHttps
(
resp
,
API_PATH
);
if
(
syncRes
===
undefined
)
return
undefined
;
if
(
syncRes
.
code
===
0
&&
syncRes
.
data
===
true
)
{
// succeed in syncing
return
await
updatePublic
({
userId
:
req
.
userId
,
token
:
req
.
token
,
deckId
:
deckId
,
isPublic
:
true
,
});
}
else
{
return
{
code
:
syncRes
.
code
,
message
:
syncRes
.
message
};
}
}
}
src/ui/BuildDeck/DeckSelect/index.tsx
View file @
886577a8
...
@@ -11,7 +11,6 @@ import React, { useRef, useState } from "react";
...
@@ -11,7 +11,6 @@ import React, { useRef, useState } from "react";
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
{
uploadDeck
}
from
"
@/api
"
;
import
{
uploadDeck
}
from
"
@/api
"
;
import
{
MdproDeck
}
from
"
@/api/mdproDeck/schema
"
;
import
{
accountStore
,
deckStore
,
IDeck
}
from
"
@/stores
"
;
import
{
accountStore
,
deckStore
,
IDeck
}
from
"
@/stores
"
;
import
{
Uploader
}
from
"
../../Shared
"
;
import
{
Uploader
}
from
"
../../Shared
"
;
...
@@ -130,16 +129,16 @@ export const DeckSelect: React.FC<{
...
@@ -130,16 +129,16 @@ export const DeckSelect: React.FC<{
const
user
=
accountStore
.
user
;
const
user
=
accountStore
.
user
;
if
(
user
)
{
if
(
user
)
{
// TODO: Deck Case
// TODO: Deck Case
const
mdproDeck
:
MdproDeck
=
{
const
resp
=
await
uploadDeck
({
deckId
:
""
,
deckContributor
:
user
.
username
,
deckName
:
deck
.
deckName
,
deckYdk
:
genYdkText
(
deck
),
deckCase
:
DEFAULT_DECK_CASE
,
userId
:
user
.
id
,
userId
:
user
.
id
,
};
token
:
user
.
token
,
deckContributor
:
user
.
username
,
const
resp
=
await
uploadDeck
(
mdproDeck
);
deck
:
{
deckName
:
deck
.
deckName
,
deckCase
:
DEFAULT_DECK_CASE
,
deckYdk
:
genYdkText
(
deck
),
},
});
if
(
resp
)
{
if
(
resp
)
{
if
(
resp
.
code
)
{
if
(
resp
.
code
)
{
message
.
error
(
resp
.
message
);
message
.
error
(
resp
.
message
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment