-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
マイルストーン編集用のfetchロジックを作る #39
The head ref may contain hidden characters: "38-\u30DE\u30A4\u30EB\u30B9\u30C8\u30FC\u30F3\u7DE8\u96C6\u7528\u306Efetch\u30ED\u30B8\u30C3\u30AF\u3092\u4F5C\u308B"
Conversation
062838c
to
45d3264
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/hooks/useFetchUser.ts
Outdated
} from "../../proto/typescript/pb_out/main"; | ||
import useApiPBClient from "@/hooks/useApiPBClient"; | ||
|
||
const protobuf = require("protobufjs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const protobuf = require("protobufjs"); |
src/hooks/useFetchMilestone.ts
Outdated
|
||
import useApiPBClient from "@/hooks/useApiPBClient"; | ||
|
||
const protobuf = require("protobufjs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const protobuf = require("protobufjs"); |
src/hooks/useImageUploder.ts
Outdated
const protobuf = require("protobufjs"); | ||
|
||
const useImageUploder = () => { | ||
const upload = async (image: File): Promise<string | void> => { | ||
const token = localStorage.getItem("token"); | ||
|
||
const ImageUploadRequest = protobuf.roots.default.lookupType( | ||
"main.ImageUploadRequest", | ||
); | ||
const payload = { image: image }; | ||
const errMsg = ImageUploadRequest.verify(payload); | ||
if (errMsg) throw Error(`ImageUploadRequest: ${errMsg}`); | ||
|
||
const imageUpload = ImageUploadRequest.create(payload); | ||
const buffer = ImageUploadRequest.encode(imageUpload).finish(); | ||
await axios | ||
.post(`${process.env.BACKEND_DOMAIN}/api/v1/image/upload`, buffer, { | ||
headers: { | ||
Authorization: `token ${token}`, | ||
}, | ||
}) | ||
.then((response) => { | ||
const ImageUploadResponse = protobuf.roots.default.lookupType( | ||
"main.ImageUploadResponse", | ||
); | ||
const res = ImageUploadResponse.decode(new Uint8Array(response.data)); | ||
return res; | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
}; | ||
|
||
return { upload }; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const protobuf = require("protobufjs"); | |
const useImageUploder = () => { | |
const upload = async (image: File): Promise<string | void> => { | |
const token = localStorage.getItem("token"); | |
const ImageUploadRequest = protobuf.roots.default.lookupType( | |
"main.ImageUploadRequest", | |
); | |
const payload = { image: image }; | |
const errMsg = ImageUploadRequest.verify(payload); | |
if (errMsg) throw Error(`ImageUploadRequest: ${errMsg}`); | |
const imageUpload = ImageUploadRequest.create(payload); | |
const buffer = ImageUploadRequest.encode(imageUpload).finish(); | |
await axios | |
.post(`${process.env.BACKEND_DOMAIN}/api/v1/image/upload`, buffer, { | |
headers: { | |
Authorization: `token ${token}`, | |
}, | |
}) | |
.then((response) => { | |
const ImageUploadResponse = protobuf.roots.default.lookupType( | |
"main.ImageUploadResponse", | |
); | |
const res = ImageUploadResponse.decode(new Uint8Array(response.data)); | |
return res; | |
}) | |
.catch((error) => { | |
console.log(error); | |
}); | |
}; | |
return { upload }; | |
}; | |
const useImageUploder = () => { | |
const upload = async (image: File): Promise<string | void> => { | |
const token = localStorage.getItem("token"); | |
}; | |
return { upload }; | |
}; |
src/hooks/useFetchMilestone.ts
Outdated
newMilestoen: MilestoneCreateRequest, | ||
): Promise<MilestoneUpdateResponse> => { | ||
return await client | ||
.put(`/milestone/${newMilestoen.milestone?.milestoneId}`, newMilestoen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clientなんですが 現状 /api/v1/
つけないといけない仕様になっています..
[Add] image uploader
PRで実装される機能
PRで修正される機能
レビューをお願いしたいポイント