Skip to content
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

Merged

Conversation

hirokiwa
Copy link
Contributor

PRで実装される機能

  • マイルストーンの編集のためのfetchを行うカスタムフックを作成する

PRで修正される機能

レビューをお願いしたいポイント

@hirokiwa hirokiwa linked an issue Mar 14, 2024 that may be closed by this pull request
Copy link

@Shion1305 Shion1305 force-pushed the 38-マイルストーン編集用のfetchロジックを作る branch from 062838c to 45d3264 Compare March 15, 2024 18:13
Copy link

Copy link

Copy link

Copy link
Contributor

@daiki0381 daiki0381 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daiki0381 daiki0381 marked this pull request as ready for review March 15, 2024 21:37
} from "../../proto/typescript/pb_out/main";
import useApiPBClient from "@/hooks/useApiPBClient";

const protobuf = require("protobufjs");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const protobuf = require("protobufjs");


import useApiPBClient from "@/hooks/useApiPBClient";

const protobuf = require("protobufjs");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const protobuf = require("protobufjs");

Comment on lines 2 to 36
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 };
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 };
};

newMilestoen: MilestoneCreateRequest,
): Promise<MilestoneUpdateResponse> => {
return await client
.put(`/milestone/${newMilestoen.milestone?.milestoneId}`, newMilestoen)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clientなんですが 現状 /api/v1/ つけないといけない仕様になっています..

Copy link

1 similar comment
Copy link

@daiki0381 daiki0381 enabled auto-merge March 15, 2024 22:29
@Shion1305 Shion1305 self-requested a review March 15, 2024 22:29
@daiki0381 daiki0381 merged commit f713fd2 into main Mar 15, 2024
1 check passed
@daiki0381 daiki0381 deleted the 38-マイルストーン編集用のfetchロジックを作る branch March 15, 2024 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

マイルストーン編集用のfetchロジックを作る
5 participants