Skip to content
Snippets Groups Projects
Unverified Commit 74378813 authored by GyDi's avatar GyDi
Browse files

fix: profile field check

parent 8ea3e6fa
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,11 @@ const ProfileEdit = (props: Props) => { ...@@ -34,6 +34,11 @@ const ProfileEdit = (props: Props) => {
try { try {
const { uid } = itemData; const { uid } = itemData;
const { name, desc, url } = form; const { name, desc, url } = form;
if (itemData.type === "remote" && !url) {
throw new Error("Remote URL should not be null");
}
await patchProfile(uid, { uid, name, desc, url }); await patchProfile(uid, { uid, name, desc, url });
mutate("getProfiles"); mutate("getProfiles");
onClose(); onClose();
......
...@@ -40,7 +40,13 @@ const ProfileNew = (props: Props) => { ...@@ -40,7 +40,13 @@ const ProfileNew = (props: Props) => {
} }
try { try {
await createProfile({ ...form }); const name = form.name || `${form.type} file`;
if (form.type === "remote" && !form.url) {
throw new Error("Remote URL should not be null");
}
await createProfile({ ...form, name });
setForm({ name: "", desc: "", type: "remote", url: "" }); setForm({ name: "", desc: "", type: "remote", url: "" });
mutate("getProfiles"); mutate("getProfiles");
onClose(); onClose();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment