Remove prediction API endpoint and integrate into stations search
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

Consolidate prediction functionality by merging /api/prediction endpoint into /api/stations response. Move prediction logic from PredictionController into StationController, returning prediction data alongside station results. Replace usePrediction composable with unified useStations that returns {stations, meta, prediction}. Remove PredictionRequest, related tests, and unused Vue components (FuelFinderTest, MapTest, RecommendationTest, StationListTest). Add PredictionFull component and UpsellBanner. Extend NationalFuelPredictionService to include weekly_summary (7-day series, yesterday/today averages, cheapest/priciest days) and oil signal from price_predictions table. Update Home.vue to consume prediction from stations response. Add Plan::resolveCadenceForUser helper and configure Cashier to use custom Subscription model.
This commit is contained in:
Ovidiu U
2026-04-29 13:28:33 +01:00
parent ee6de23709
commit 088fd11058
29 changed files with 1046 additions and 499 deletions

View File

@@ -19,6 +19,22 @@ export function useAuth() {
return ['basic', 'plus', 'pro'].includes(userTier.value)
})
const subscriptionCancelled = computed(() => {
return user.value?.subscription_cancelled ?? false
})
const subscriptionCadence = computed(() => {
return user.value?.subscription_cadence ?? null
})
const subscribedAt = computed(() => {
return user.value?.subscribed_at ?? null
})
const subscriptionExpiresAt = computed(() => {
return user.value?.subscription_expires_at ?? null
})
async function fetchUser() {
if (fetched.value) {
return
@@ -68,6 +84,10 @@ export function useAuth() {
isAuthenticated,
userTier,
isPaidTier,
subscriptionCancelled,
subscriptionCadence,
subscribedAt,
subscriptionExpiresAt,
fetchUser,
clearUser,
logout,

View File

@@ -1,31 +0,0 @@
import { ref } from 'vue'
import api from '../axios.js'
export function usePrediction() {
const prediction = ref(null)
const loading = ref(false)
const error = ref(null)
async function fetch({ lat, lng } = {}) {
loading.value = true
error.value = null
prediction.value = null
const params = {}
if (lat && lng) {
params.lat = lat
params.lng = lng
}
try {
const response = await api.get('/prediction', { params })
prediction.value = response.data
} catch (err) {
error.value = 'Unable to load prediction.'
} finally {
loading.value = false
}
}
return { prediction, loading, error, fetch }
}

View File

@@ -4,6 +4,7 @@ import api from '../axios.js'
export function useStations() {
const stations = ref([])
const meta = ref(null)
const prediction = ref(null)
const loading = ref(false)
const error = ref(null)
@@ -12,6 +13,7 @@ export function useStations() {
error.value = null
stations.value = []
meta.value = null
prediction.value = null
const params = { fuel_type: fuelType, radius, sort }
@@ -26,6 +28,7 @@ export function useStations() {
const response = await api.get('/stations', { params })
stations.value = response.data.data
meta.value = response.data.meta
prediction.value = response.data.prediction ?? null
} catch (err) {
error.value = err.response?.data?.errors
?? { general: ['Unable to load stations. Please try again.'] }
@@ -37,9 +40,10 @@ export function useStations() {
function reset() {
stations.value = []
meta.value = null
prediction.value = null
error.value = null
loading.value = false
}
return { stations, meta, loading, error, search, reset }
return { stations, meta, prediction, loading, error, search, reset }
}