589 lines
15 KiB
TypeScript
589 lines
15 KiB
TypeScript
import { defineComponent, ref, computed } from 'vue';
|
|
import { useRouter } from 'vue-router';
|
|
import { CRISBalanceBar } from '@src/components/CRISBalanceBar';
|
|
|
|
const isTest = true; // Cambia a false in produzione
|
|
|
|
export default defineComponent({
|
|
name: 'RisoHomeModern',
|
|
components: { CRISBalanceBar },
|
|
setup() {
|
|
const $router = useRouter();
|
|
|
|
// State
|
|
const showAnnunciDialog = ref(false);
|
|
|
|
const selectedCircuit = ref<'provinciale' | 'italia'>('provinciale');
|
|
const handshakesView = ref<'mine' | 'all'>('mine');
|
|
|
|
// Dati wallet (da collegare allo store)
|
|
const availableBalance = ref(0); // Saldo utilizzabile (include fido)
|
|
const realBalance = ref(0); // Saldo reale effettivo
|
|
const trustLimit = ref(-100); // Fido concesso (negativo)
|
|
const maxAccumulation = ref(200); // Massimo accumulo
|
|
const receivedCount = ref(0);
|
|
const sentCount = ref(0);
|
|
|
|
// Dati eventi (da collegare allo store)
|
|
const upcomingEventsCount = ref(0);
|
|
const recentEvents = ref<any[]>([
|
|
// Esempio struttura:
|
|
// { day: '15', month: 'DIC', title: 'Mercatino', location: 'Roma' }
|
|
]);
|
|
|
|
// Dati attività (da collegare allo store)
|
|
const recentTrades = ref<any[]>([
|
|
// Esempio struttura:
|
|
// { userInitial: 'M', description: 'Scambio completato', time: '2h fa', amount: 50 }
|
|
]);
|
|
|
|
const recentConnections = ref<any[]>([
|
|
// Esempio struttura:
|
|
// { userInitial: 'A', name: 'Mario Rossi', time: '1 giorno fa' }
|
|
]);
|
|
|
|
// Stats
|
|
const totalMembers = ref(0);
|
|
const totalTrades = ref(0);
|
|
const totalEvents = ref(0);
|
|
|
|
const totalTransactions = ref(0);
|
|
const uniqueMembers = ref(0);
|
|
const lastTradeTime = ref('Mai');
|
|
|
|
// Organizzazioni
|
|
const organizations = ref<any[]>([
|
|
// Esempio struttura:
|
|
// { initial: 'AS', name: 'Associazione Locale', membersCount: 45 }
|
|
]);
|
|
|
|
// Telegram
|
|
const telegramLinks = ref<any[]>([
|
|
// Esempio struttura:
|
|
// { title: 'Canale Principale', url: 'https://t.me/...', image: '/path/to/img' }
|
|
]);
|
|
|
|
// Computed
|
|
const hasEvents = computed(() => recentEvents.value.length > 0);
|
|
const hasOrganizations = computed(() => organizations.value.length > 0);
|
|
const hasTelegramLinks = computed(() => telegramLinks.value.length > 0);
|
|
|
|
// ========== METODI DA IMPLEMENTARE ==========
|
|
|
|
// Dialog Annunci
|
|
const openAnnunciDialog = () => {
|
|
showAnnunciDialog.value = true;
|
|
// TODO: implementare logica apertura dialog
|
|
};
|
|
|
|
// Navigazione Annunci
|
|
const goToGoods = () => {
|
|
showAnnunciDialog.value = false;
|
|
// TODO: navigare a /goods
|
|
// $router.push('/goods')
|
|
};
|
|
|
|
const goToServices = () => {
|
|
showAnnunciDialog.value = false;
|
|
// TODO: navigare a /services
|
|
// $router.push('/services')
|
|
};
|
|
|
|
const goToHospitality = () => {
|
|
showAnnunciDialog.value = false;
|
|
// TODO: navigare a /hosps
|
|
// $router.push('/hosps')
|
|
};
|
|
|
|
const goToTransport = () => {
|
|
showAnnunciDialog.value = false;
|
|
// TODO: navigare a /transport (da creare?)
|
|
// $router.push('/transport')
|
|
};
|
|
|
|
// Hero Cards
|
|
const goToWallet = () => {
|
|
// TODO: navigare al portafoglio dettagliato
|
|
// $router.push('/wallet')
|
|
};
|
|
|
|
const goToCircuits = () => {
|
|
// TODO: navigare ai circuiti RIS
|
|
// $router.push('/circuits')
|
|
};
|
|
|
|
const goToEvents = () => {
|
|
// TODO: navigare alla lista eventi
|
|
// $router.push('/events')
|
|
};
|
|
|
|
const goToProfile = () => {
|
|
// TODO: navigare al profilo utente
|
|
// $router.push('/profile')
|
|
};
|
|
|
|
// Azioni Rapide
|
|
const sendRIS = () => {
|
|
// TODO: aprire dialog/pagina invio RIS
|
|
};
|
|
|
|
const receiveRIS = () => {
|
|
// TODO: aprire dialog/pagina ricezione RIS
|
|
};
|
|
|
|
const inviteFriend = () => {
|
|
// TODO: aprire dialog/pagina invito amico
|
|
};
|
|
|
|
const showMembers = () => {
|
|
// TODO: navigare alla lista iscritti
|
|
// $router.push('/members')
|
|
};
|
|
|
|
// Wallet
|
|
const refreshWallet = () => {
|
|
// TODO: ricaricare dati wallet dallo store/API
|
|
};
|
|
|
|
const goToTransactions = () => {
|
|
// TODO: navigare alla lista transazioni
|
|
// $router.push('/transactions')
|
|
};
|
|
|
|
// Eventi
|
|
const goToAllEvents = () => {
|
|
// TODO: navigare a tutti gli eventi
|
|
// $router.push('/events')
|
|
};
|
|
|
|
const openEvent = (event: any) => {
|
|
// TODO: aprire dettaglio evento
|
|
// $router.push(`/events/${event.id}`)
|
|
};
|
|
|
|
// Community
|
|
const openTrade = (trade: any) => {
|
|
// TODO: aprire dettaglio scambio
|
|
};
|
|
|
|
const openConnection = (connection: any) => {
|
|
// TODO: aprire profilo utente connesso
|
|
};
|
|
|
|
const goToAllTrades = () => {
|
|
// TODO: navigare a lista completa scambi
|
|
// $router.push('/trades')
|
|
};
|
|
|
|
const goToAllConnections = () => {
|
|
// TODO: navigare a lista completa connessioni
|
|
// $router.push('/connections')
|
|
};
|
|
|
|
// Organizzazioni
|
|
const createOrganization = () => {
|
|
// TODO: aprire form creazione organizzazione
|
|
};
|
|
|
|
const openOrganization = (org: any) => {
|
|
// TODO: aprire dettaglio organizzazione
|
|
// $router.push(`/groups/${org.id}`)
|
|
};
|
|
|
|
const goToAllOrganizations = () => {
|
|
// TODO: navigare a lista completa organizzazioni
|
|
// $router.push('/groups')
|
|
};
|
|
|
|
// Footer
|
|
const openFAQ = () => {
|
|
// TODO: navigare a FAQ
|
|
// $router.push('/faq')
|
|
};
|
|
|
|
const openGuide = () => {
|
|
// TODO: navigare a guida
|
|
// $router.push('/guide')
|
|
};
|
|
|
|
const openInfo = () => {
|
|
// TODO: navigare a info
|
|
// $router.push('/info')
|
|
};
|
|
|
|
const loadTestData = () => {
|
|
if (!isTest) return;
|
|
|
|
// Circuito Provinciale
|
|
circuits.value.provinciale = {
|
|
title: 'RIS Provinciale',
|
|
availableBalance: 50,
|
|
realBalance: -50,
|
|
trustLimit: -100,
|
|
maxAccumulation: 200,
|
|
totalTransactions: 15,
|
|
sentCount: 8,
|
|
receivedCount: 7,
|
|
uniqueMembers: 12,
|
|
lastTradeTime: '2 giorni fa',
|
|
recentTransactions: [
|
|
{ userInitial: 'M', description: 'Ortaggi freschi', time: '2h fa', amount: 15 },
|
|
{
|
|
userInitial: 'L',
|
|
description: 'Lezione chitarra',
|
|
time: '5h fa',
|
|
amount: -25,
|
|
},
|
|
{
|
|
userInitial: 'G',
|
|
description: 'Riparazione bici',
|
|
time: '1 giorno fa',
|
|
amount: 30,
|
|
},
|
|
],
|
|
};
|
|
|
|
// Circuito Italia
|
|
circuits.value.italia = {
|
|
title: 'RIS Italia',
|
|
availableBalance: -50,
|
|
realBalance: 150,
|
|
trustLimit: -200,
|
|
maxAccumulation: 400,
|
|
totalTransactions: 8,
|
|
sentCount: 3,
|
|
receivedCount: 5,
|
|
uniqueMembers: 7,
|
|
lastTradeTime: '5 giorni fa',
|
|
recentTransactions: [
|
|
{
|
|
userInitial: 'A',
|
|
description: 'Consulenza legale',
|
|
time: '3 giorni fa',
|
|
amount: -80,
|
|
},
|
|
{
|
|
userInitial: 'F',
|
|
description: 'Prodotti artigianali',
|
|
time: '4 giorni fa',
|
|
amount: 50,
|
|
},
|
|
{
|
|
userInitial: 'S',
|
|
description: 'Corso di cucina',
|
|
time: '5 giorni fa',
|
|
amount: -40,
|
|
},
|
|
],
|
|
};
|
|
|
|
// Community
|
|
invitesSent.value = 7;
|
|
|
|
myHandshakes.value = [
|
|
{ userInitial: 'M', name: 'Mario Rossi', time: '2 giorni fa' },
|
|
{ userInitial: 'L', name: 'Laura Bianchi', time: '3 giorni fa' },
|
|
{ userInitial: 'G', name: 'Giovanni Verdi', time: '1 settimana fa' },
|
|
{ userInitial: 'C', name: 'Chiara Neri', time: '2 settimane fa' },
|
|
{ userInitial: 'P', name: 'Paolo Conti', time: '3 settimane fa' },
|
|
];
|
|
|
|
allHandshakes.value = [
|
|
{
|
|
user1Initial: 'A',
|
|
user2Initial: 'B',
|
|
user1Name: 'Anna',
|
|
user2Name: 'Bruno',
|
|
time: '1h fa',
|
|
},
|
|
{
|
|
user1Initial: 'C',
|
|
user2Initial: 'D',
|
|
user1Name: 'Carlo',
|
|
user2Name: 'Diana',
|
|
time: '3h fa',
|
|
},
|
|
{
|
|
user1Initial: 'E',
|
|
user2Initial: 'F',
|
|
user1Name: 'Elena',
|
|
user2Name: 'Franco',
|
|
time: '5h fa',
|
|
},
|
|
{
|
|
user1Initial: 'G',
|
|
user2Initial: 'H',
|
|
user1Name: 'Giulia',
|
|
user2Name: 'Hugo',
|
|
time: '1 giorno fa',
|
|
},
|
|
{
|
|
user1Initial: 'I',
|
|
user2Initial: 'L',
|
|
user1Name: 'Irene',
|
|
user2Name: 'Luca',
|
|
time: '2 giorni fa',
|
|
},
|
|
];
|
|
|
|
// Eventi test data con immagini
|
|
upcomingEventsCount.value = 7;
|
|
recentEvents.value = [
|
|
{
|
|
day: '15',
|
|
month: 'DIC',
|
|
title: 'Mercatino di Natale',
|
|
location: 'Roma Centro',
|
|
id: 1,
|
|
image: '',
|
|
},
|
|
{
|
|
day: '20',
|
|
month: 'DIC',
|
|
title: 'Corso di Panificazione',
|
|
location: 'Milano',
|
|
id: 2,
|
|
image: '',
|
|
},
|
|
{
|
|
day: '22',
|
|
month: 'DIC',
|
|
title: 'Scambio Semi e Piante',
|
|
location: 'Bologna',
|
|
id: 3,
|
|
image: '',
|
|
},
|
|
{
|
|
day: '28',
|
|
month: 'DIC',
|
|
title: 'Incontro Produttori Locali',
|
|
location: 'Firenze',
|
|
id: 4,
|
|
image: '',
|
|
},
|
|
{
|
|
day: '05',
|
|
month: 'GEN',
|
|
title: 'Festa della Comunità',
|
|
location: 'Torino',
|
|
id: 5,
|
|
image: '',
|
|
},
|
|
];
|
|
|
|
// Scambi test data
|
|
recentTrades.value = [
|
|
{
|
|
userInitial: 'M',
|
|
description: 'Scambio ortaggi freschi',
|
|
time: '2h fa',
|
|
amount: 15,
|
|
},
|
|
{
|
|
userInitial: 'L',
|
|
description: 'Lezione di chitarra',
|
|
time: '5h fa',
|
|
amount: -25,
|
|
},
|
|
{
|
|
userInitial: 'G',
|
|
description: 'Riparazione bicicletta',
|
|
time: '1 giorno fa',
|
|
amount: 30,
|
|
},
|
|
{
|
|
userInitial: 'A',
|
|
description: 'Pane fatto in casa',
|
|
time: '2 giorni fa',
|
|
amount: -10,
|
|
},
|
|
{
|
|
userInitial: 'S',
|
|
description: 'Consulenza informatica',
|
|
time: '3 giorni fa',
|
|
amount: 40,
|
|
},
|
|
];
|
|
|
|
// Statistiche test data
|
|
totalMembers.value = 342;
|
|
totalTrades.value = 1567;
|
|
totalEvents.value = 89;
|
|
|
|
// Organizzazioni test data
|
|
organizations.value = [
|
|
{ initial: 'AS', name: 'Associazione Scambio Locale', membersCount: 45, id: 1 },
|
|
{ initial: 'GP', name: 'Gruppo Produttori Bio', membersCount: 32, id: 2 },
|
|
{ initial: 'CE', name: 'Comunità Energetica', membersCount: 28, id: 3 },
|
|
{ initial: 'RT', name: 'Rete Tempo', membersCount: 56, id: 4 },
|
|
{ initial: 'OC', name: 'Orto Condiviso', membersCount: 23, id: 5 },
|
|
{ initial: 'LB', name: 'La Banca del Tempo', membersCount: 41, id: 6 },
|
|
{ initial: 'MP', name: 'Mercato Popolare', membersCount: 38, id: 7 },
|
|
{ initial: 'CC', name: 'Casa Comune', membersCount: 19, id: 8 },
|
|
{ initial: 'SF', name: 'Sharing Food', membersCount: 27, id: 9 },
|
|
{ initial: 'EA', name: 'Economia Alternativa', membersCount: 34, id: 10 },
|
|
];
|
|
|
|
// Telegram test data con immagini
|
|
telegramLinks.value = [
|
|
{
|
|
title: 'Canale Principale RISO',
|
|
url: 'https://t.me/riso_italia',
|
|
image: '/images/telegram-main.jpg',
|
|
},
|
|
{
|
|
title: 'Gruppo Scambi Locali',
|
|
url: 'https://t.me/riso_scambi',
|
|
image: '/images/telegram-scambi.jpg',
|
|
},
|
|
{
|
|
title: 'Eventi e Incontri',
|
|
url: 'https://t.me/riso_eventi',
|
|
image: '/images/telegram-eventi.jpg',
|
|
},
|
|
];
|
|
};
|
|
|
|
// Dati circuiti
|
|
const circuits = ref({
|
|
provinciale: {
|
|
availableBalance: 0,
|
|
realBalance: 0,
|
|
trustLimit: -100,
|
|
maxAccumulation: 200,
|
|
totalTransactions: 0,
|
|
sentCount: 0,
|
|
receivedCount: 0,
|
|
uniqueMembers: 0,
|
|
lastTradeTime: 'Mai',
|
|
recentTransactions: [] as any[],
|
|
title: 'RIS Provinciale',
|
|
},
|
|
italia: {
|
|
availableBalance: 0,
|
|
realBalance: 0,
|
|
trustLimit: -200,
|
|
maxAccumulation: 400,
|
|
totalTransactions: 0,
|
|
sentCount: 0,
|
|
receivedCount: 0,
|
|
uniqueMembers: 0,
|
|
lastTradeTime: 'Mai',
|
|
recentTransactions: [] as any[],
|
|
title: 'RIS Italia',
|
|
},
|
|
});
|
|
|
|
// Dati community
|
|
const invitesSent = ref(0);
|
|
const myHandshakes = ref<any[]>([]);
|
|
const allHandshakes = ref<any[]>([]);
|
|
|
|
// Circuiti overview
|
|
const activeCircuitsCount = ref(2);
|
|
const totalCircuitsAvailable = ref(12);
|
|
|
|
// Computed per circuito corrente
|
|
const currentCircuitData = computed(() => {
|
|
return circuits.value[selectedCircuit.value];
|
|
});
|
|
|
|
// Metodi
|
|
const openTransaction = (tx: any) => {
|
|
// TODO: aprire dettaglio transazione
|
|
};
|
|
|
|
const openHandshake = (handshake: any) => {
|
|
// TODO: aprire dettaglio stretta di mano
|
|
};
|
|
|
|
const goToAllCircuits = () => {
|
|
// TODO: navigare a lista circuiti
|
|
// $router.push('/circuits')
|
|
};
|
|
|
|
loadTestData();
|
|
|
|
// ========== LIFECYCLE (da implementare) ==========
|
|
// onMounted(() => {
|
|
// loadWalletData()
|
|
// loadRecentEvents()
|
|
// loadRecentActivity()
|
|
// loadStats()
|
|
// loadOrganizations()
|
|
// loadTelegramLinks()
|
|
// })
|
|
|
|
return {
|
|
// State
|
|
showAnnunciDialog,
|
|
|
|
// Data
|
|
availableBalance,
|
|
realBalance,
|
|
trustLimit,
|
|
maxAccumulation,
|
|
receivedCount,
|
|
sentCount,
|
|
upcomingEventsCount,
|
|
recentEvents,
|
|
recentTrades,
|
|
recentConnections,
|
|
totalMembers,
|
|
totalTrades,
|
|
totalEvents,
|
|
organizations,
|
|
telegramLinks,
|
|
|
|
// Computed
|
|
hasEvents,
|
|
hasOrganizations,
|
|
hasTelegramLinks,
|
|
|
|
// Methods
|
|
openAnnunciDialog,
|
|
goToGoods,
|
|
goToServices,
|
|
goToHospitality,
|
|
goToTransport,
|
|
goToWallet,
|
|
goToEvents,
|
|
goToProfile,
|
|
sendRIS,
|
|
receiveRIS,
|
|
inviteFriend,
|
|
showMembers,
|
|
refreshWallet,
|
|
goToTransactions,
|
|
goToAllEvents,
|
|
openEvent,
|
|
openTrade,
|
|
openConnection,
|
|
goToAllTrades,
|
|
goToAllConnections,
|
|
createOrganization,
|
|
openOrganization,
|
|
goToAllOrganizations,
|
|
openFAQ,
|
|
openGuide,
|
|
openInfo,
|
|
totalTransactions,
|
|
uniqueMembers,
|
|
lastTradeTime,
|
|
goToCircuits,
|
|
selectedCircuit,
|
|
handshakesView,
|
|
circuits,
|
|
currentCircuitData,
|
|
invitesSent,
|
|
myHandshakes,
|
|
allHandshakes,
|
|
activeCircuitsCount,
|
|
totalCircuitsAvailable,
|
|
openTransaction,
|
|
openHandshake,
|
|
goToAllCircuits,
|
|
};
|
|
},
|
|
});
|