import { type ActionReturnType, actions } from 'astro:actions'; import { writable } from 'svelte/store'; import { actionErrorPopup } from '@util/action.ts'; // types export type Feedbacks = Exclude['data'], undefined>['feedbacks']; export type Feedback = Feedbacks[0]; // state export const feedbacks = writable([]); // actions export async function fetchFeedbacks(reporter?: string | null, reported?: string | null) { const { data, error } = await actions.feedback.feedbacks({ reporter: reporter, reported: reported }); if (error) { actionErrorPopup(error); return; } feedbacks.set(data.feedbacks); }