Skip to content

Commit

Permalink
Merge branch 'develop' into fix#419
Browse files Browse the repository at this point in the history
  • Loading branch information
naohanpen authored Sep 25, 2024
2 parents 0d5760b + 782696a commit a3c6cb4
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cd-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
ln -s ${{ github.workspace }} /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}
- uses: actions/setup-node@v4
with:
node-version: "latest"
node-version: 'lts/*'
check-latest: true
- name: cache
uses: actions/cache@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cd-feture-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
ln -s ${{ github.workspace }} /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}
- uses: actions/setup-node@v4
with:
node-version: "latest"
node-version: 'lts/*'
check-latest: true
- name: cache
uses: actions/cache@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cd-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
ln -s ${{ github.workspace }} /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}
- uses: actions/setup-node@v4
with:
node-version: "latest"
node-version: 'lts/*'
check-latest: true
- name: cache
uses: actions/cache@v4
with:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "latest"
node-version: 'lts/*'
check-latest: true
cache: "npm"
cache-dependency-path: "**/package-lock.json"

Expand All @@ -30,7 +31,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "latest"
node-version: 'lts/*'
check-latest: true
cache: "npm"
cache-dependency-path: "**/package-lock.json"

Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.17.0
16 changes: 15 additions & 1 deletion src/app/committee/news/new/NewNewsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,22 @@ export const NewNewsForm: FC<{
]);
};

const onSubmitHandler = handleSubmit(async (data) => {
onSubmit(data);
});

return (
<form onSubmit={handleSubmit(onSubmit)} className={stack({ gap: 4, marginBottom: "100px" })}>
<form
onSubmit={(e) => {
e.preventDefault();
if (!window.confirm("この内容で送信しますか?")) {
toast("送信をキャンセルしました");
return;
} else {
return onSubmitHandler(onSubmit);
}
}}
className={stack({ gap: 4, marginBottom: "100px" })}>
<div
className={hstack({
justifyContent: "space-between",
Expand Down
72 changes: 41 additions & 31 deletions src/common_components/form_editor/FormEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,40 @@ export const FormEditor: FC<{
);
}

const onSubmitHandler = handleSubmit(async (data) => {
if (fileErrors.get("attachments")) {
toast.error("正しいファイルをアップロードしてください");
return;
}
let fileIds: FileIds = { attachments: attachmentsStatus.map((attachmentStatus) => attachmentStatus.uuid) };
const body = {
...data,
attributes: data.attributes.length === 0 ? [...projectAttributes] : data.attributes,
categories: data.categories.length === 0 ? [...projectCategories] : data.categories,
starts_at: (data.starts_at === "" ? dayjs() : dayjs(data.starts_at)).toISOString(),
ends_at: dayjs(data.ends_at).toISOString(),
attachments: fileIds.attachments ?? [],
items: [
...data.items.map((item) => {
if (item.type === "choose_many" || item.type === "choose_one") {
return {
...item,
options: item.options.split("\n"),
};
}
if (item.type === "file") {
return {
...item,
extensions: item.extensions.split("\n"),
};
}
return item;
}),
],
};
return onSubmit(body);
});

return (
<>
<Divider />
Expand All @@ -142,39 +176,15 @@ export const FormEditor: FC<{
)}
<form
className={stack({ gap: 4 })}
onSubmit={handleSubmit(async (data) => {
if (fileErrors.get("attachments")) {
toast.error("正しいファイルをアップロードしてください");
onSubmit={(e) => {
e.preventDefault();
if (!window.confirm("この内容で送信しますか?")) {
toast("送信をキャンセルしました");
return;
} else {
return onSubmitHandler();
}
let fileIds: FileIds = { attachments: attachmentsStatus.map((attachmentStatus) => attachmentStatus.uuid) };
const body = {
...data,
attributes: data.attributes.length === 0 ? [...projectAttributes] : data.attributes,
categories: data.categories.length === 0 ? [...projectCategories] : data.categories,
starts_at: (data.starts_at === "" ? dayjs() : dayjs(data.starts_at)).toISOString(),
ends_at: dayjs(data.ends_at).toISOString(),
attachments: fileIds.attachments ?? [],
items: [
...data.items.map((item) => {
if (item.type === "choose_many" || item.type === "choose_one") {
return {
...item,
options: item.options.split("\n"),
};
}
if (item.type === "file") {
return {
...item,
extensions: item.extensions.split("\n"),
};
}
return item;
}),
],
};
return onSubmit(body);
})}>
}}>
<fieldset
className={stack({
gap: 5,
Expand Down

0 comments on commit a3c6cb4

Please sign in to comment.