This commit is contained in:
ct
2025-07-03 00:48:06 +08:00
parent 0aa0d9569f
commit db892fc4f5
26 changed files with 807 additions and 59 deletions

View File

@@ -14,9 +14,28 @@ const useUserStore = create(
tier: 'free',
},
billing: null,
credits: null,
isLoadingUser: false,
isRedirectingToBilling: false,
redirectBillingPortal: async () => {
set({ isRedirectingToBilling: true });
console.log('redirectBillingPortal');
try {
const response = await axiosInstance.post(route('api.user.billing_portal'));
if (response?.data?.success?.data) {
window.location.href = response.data.success.data.redirect;
}
} catch (error) {
console.error(route('api.user.billing_portal'));
console.error('Error fetching:', error);
} finally {
set({ isRedirectingToBilling: false });
}
},
// Fetch backgrounds
fetchUser: async () => {
set({ isLoadingUser: true });
@@ -27,6 +46,7 @@ const useUserStore = create(
user_usage: response.data.success.data.user.user_usage,
plan: response.data.success.data.user.plan,
billing: response.data.success.data.billing,
credits: response.data.success.data.credits,
});
//return response.data.success.data;
} catch (error) {