22 lines
647 B
TypeScript
22 lines
647 B
TypeScript
import { type ActionReturnType, actions } from 'astro:actions';
|
|
import { writable } from 'svelte/store';
|
|
import { actionErrorPopup } from '@util/action.ts';
|
|
|
|
// types
|
|
export type Feedbacks = Exclude<ActionReturnType<typeof actions.feedback.feedbacks>['data'], undefined>['feedbacks'];
|
|
export type Feedback = Feedbacks[0];
|
|
|
|
// state
|
|
export const feedbacks = writable<Feedbacks>([]);
|
|
|
|
// actions
|
|
export async function fetchFeedbacks(includeBlanks: boolean) {
|
|
const { data, error } = await actions.feedback.feedbacks({ includeBlanks: includeBlanks });
|
|
if (error) {
|
|
actionErrorPopup(error);
|
|
return;
|
|
}
|
|
|
|
feedbacks.set(data.feedbacks);
|
|
}
|