Widgets work
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 35s

This commit is contained in:
2026-04-30 19:39:53 +02:00
parent ffb23b08eb
commit 139e7d0ef5
16 changed files with 512 additions and 296 deletions

View File

@@ -1,12 +1,41 @@
import Server from './Server';
const SELECTED_CAMPAIGN_KEY = 'selectedCampaignId';
export const useCampaignService = () => {
const Campaign = useState('campaign', () => null)
const SetCampaign = (data) => {
Campaign.value = data;
if (data?._id) {
localStorage.setItem(SELECTED_CAMPAIGN_KEY, data._id);
} else {
localStorage.removeItem(SELECTED_CAMPAIGN_KEY);
}
}
const RestoreCampaign = async () => {
const campaignId = localStorage.getItem(SELECTED_CAMPAIGN_KEY);
if (!campaignId) return false;
try {
const response = await Server().get(`/campaign/retrieve/${campaignId}`);
if (response.data.status !== 'ok') {
SetCampaign(null);
return false;
}
SetCampaign(response.data.campaign);
return true;
} catch (error) {
SetCampaign(null);
return false;
}
}
return {
Campaign,
SetCampaign
SetCampaign,
RestoreCampaign
}
}
}