BLOG-140 Label management (list and create) #144

Merged
squid merged 6 commits from BLOG-140_label_management into main 2025-10-15 12:21:42 +08:00
4 changed files with 20 additions and 6 deletions
Showing only changes of commit 9b33ea6c7a - Show all commits

View File

@ -30,7 +30,7 @@
onSubmit: createLabel,
}: {
disabled: boolean;
onSubmit: (params: FormParams) => Promise<void>;
onSubmit: (params: FormParams) => Promise<boolean>;
} = $props();
let open = $state(false);
@ -62,7 +62,11 @@
return;
}
await createLabel(formData);
const isSuccess = await createLabel(formData);
if (!isSuccess) {
return;
}
formData = {
name: '',
color: '#dddddd',

View File

@ -23,7 +23,7 @@
const labelsListedState = $derived($labelsListedStore);
const { trigger: loadLabels } = labelsListedStore;
async function onCreateLabelDialogSubmit(params: CreateLabelDialogFormParams) {
async function onCreateLabelDialogSubmit(params: CreateLabelDialogFormParams): Promise<boolean> {
const colorViewModel = ColorViewModel.fromHex(params.color);
const color = colorViewModel.toEntity();
@ -39,7 +39,10 @@
toast.error('Failed to create label', {
description: state.error.message,
});
return false;
}
return true;
}
onMount(() => loadLabels());

View File

@ -30,7 +30,7 @@
onSubmit: createPost,
}: {
disabled: boolean;
onSubmit: (params: FormParams) => Promise<void>;
onSubmit: (params: FormParams) => Promise<boolean>;
} = $props();
let open = $state(false);
@ -50,7 +50,11 @@
return;
}
await createPost(formData);
const isSuccess = await createPost(formData);
if (!isSuccess) {
return;
}
formData = { semanticId: '', title: '' };
open = false;
}

View File

@ -22,7 +22,7 @@
const postsListedState = $derived($postsListedStore);
const { trigger: loadPosts } = postsListedStore;
async function onCreatePostDialogSubmit(params: CreatePostDialogFormParams) {
async function onCreatePostDialogSubmit(params: CreatePostDialogFormParams): Promise<boolean> {
const state = await createPost(params);
if (state.isSuccess()) {
@ -32,7 +32,10 @@
toast.error('Failed to create post', {
description: state.error.message,
});
return false;
}
return true;
}
onMount(() => loadPosts({ showUnpublished: true }));