@acrsolutions/chat-components
Version:
Un set di componenti per la creazione di un'applicazione di messaggistica
250 lines (249 loc) • 8.3 kB
JavaScript
const convo1 = [
{
messageText: 'La notte è oscura e piena di terrori.',
contactName: '',
contactNumber: '333111111',
sentDate: '1300-10-01T12:13:00Z',
},
{
messageText: "L'inverno sta arrivando!",
contactName: 'Sansa Stark',
contactNumber: '333111111',
sentDate: '1500-10-01T12:03:00Z',
},
];
const convo2 = [
{
messageText: 'Hai la mia spada!',
contactName: '',
contactNumber: '333222222',
sentDate: '1300-10-01T12:06:00Z',
},
{
messageText: 'Non si entra facilmente a Mordor...',
contactName: 'Boromir',
contactNumber: '333222222',
sentDate: '1300-10-01T12:00:00Z',
},
];
export const data = [
{ id: 1, convo: convo1, notificationsNumber: 2, contactName: 'Sansa Stark' },
{ id: 2, convo: convo2, notificationsNumber: 0, contactName: 'Boromir' },
];
export const exampleResearchConvo = {
id: 3,
contactName: 'Pipino',
convo: [
{
id: '51',
messageText: 'Ne abbiamo fatta una, sì. Ma la seconda colazione?',
contactName: 'Pipino',
contactNumber: '33344444',
sentDate: '3018-09-23T09:00:00Z',
},
{
id: '52',
messageText: 'Non penso che lui conosca la seconda colazione, Pip.',
contactName: '',
contactNumber: '33344444',
sentDate: '3018-09-23T09:01:00Z',
},
{
id: '53',
messageText: 'E il tè delle undici? Pranzo? Merenda? Cena? Seconda cena?',
contactName: 'Pipino',
contactNumber: '33344444',
sentDate: '3018-09-23T09:02:00Z',
},
{
id: '54',
messageText: 'Se continui così, dovremo portarti in una carriola!',
contactName: '',
contactNumber: '33344444',
sentDate: '3018-09-23T09:03:00Z',
},
{
id: '55',
messageText: 'Ma siamo Hobbit! Mangiare è nei nostri diritti ancestrali.',
contactName: 'Pipino',
contactNumber: '33344444',
sentDate: '3018-09-23T09:04:00Z',
},
{
id: '56',
messageText: "E rubare fuochi d'artificio è nei tuoi diritti ancestrali?",
contactName: '',
contactNumber: '33344444',
sentDate: '3018-09-23T09:05:00Z',
},
{
id: '57',
messageText: 'Fu un piccolo esperimento pirotecnico!',
contactName: 'Pipino',
contactNumber: '33344444',
sentDate: '3018-09-23T09:06:00Z',
},
{
id: '58',
messageText: 'Che ha lasciato metà della Contea coperta di fumo.',
contactName: '',
contactNumber: '33344444',
sentDate: '3018-09-23T09:07:00Z',
},
{
id: '59',
messageText: 'Almeno ci siamo divertiti. E il pony ha riso!',
contactName: 'Pipino',
contactNumber: '33344444',
sentDate: '3018-09-23T09:08:00Z',
},
{
id: '510',
messageText: 'Un giorno finirai nei guai... e io verrò con te.',
contactName: '',
contactNumber: '33344444',
sentDate: '3018-09-23T09:09:00Z',
},
],
};
export const exampleCompanyPhones = ['333465607', '333465608', '333465609'];
export const exampleContactPhones = ['333111111', '333222222'];
export const exampleTemplates = {
wingardium_leviosa: {
id: 'wingardium_leviosa',
text: 'Se vuoi davvero diventare un bravo mago, devi iniziare dalle basi.\n\n La pronuncia è importante.\n La gestualità è importante.\nE soprattutto... la pazienza.\n Non si agita la bacchetta a caso gridando parole a metà!\n È {{1}}, non Leviosà!\n\n Hermione Granger',
footerText: '\n\n— {{1}}',
headerText: 'Inviato da: {{1}} \n\n',
},
i_am_your_father: {
id: 'wingardium_leviosa',
text: '{{1}}, sono tuo padre. \n\n Darth Vader',
footerText: null,
headerText: null,
},
valar_morghulis: {
id: 'wingardium_leviosa',
text: "Gentile Cliente,\n\nha mai desiderato... scomparire per un po'?\nO forse far scomparire qualcun altro?\nQui alla House of Black and White Inc., offriamo soluzioni su misura per problemi di identità, discrezione e rimozione strategica.\n(Nessuna domanda posta. Nessun volto necessario.)\nPrimo contratto gratuito se si fornisce un nome sussurrato con rispetto.\n\n{{1}}, Arya Stark\nBraavos HQ",
headerText: 'IMAGE',
footerText: null,
},
};
export const exampleTemplateOptions = Object.keys(exampleTemplates);
export const allPossibleMessageTypesExamples = [
{
id: 'simpleText',
text: 'ciao',
sentDate: '2023-10-01T12:00:00Z',
},
{
id: 'imageText',
text: null,
caption: 'immagine 1',
imgUrl: 'https://picsum.photos/200',
sentDate: '2023-10-01T12:00:00Z',
},
{
id: 'videoText',
text: null,
caption: 'video 1',
videoUrl: 'https://www.youtube.com/shorts/isRx40p7doI',
sentDate: '2023-10-01T12:00:00Z',
},
{
id: 'docText',
text: 'Ciao ciao',
caption: 'doc 1',
documentUrl: '/examples/sheldon_cooper.tsx',
sentDate: '2023-10-01T12:00:00Z',
fileName: 'sheldon_cooper.tsx',
},
{
id: 'templateText',
text: null,
sentDate: '2023-10-01T12:00:00Z',
templateName: exampleTemplates.wingardium_leviosa.id,
templateVariables: [
{ key: 'header_1', value: 'Consegna Thestral' },
{ key: 'body_1', value: 'Wingardium Leviosa' },
{ key: 'footer_1', value: 'Ordine della Fenice' },
],
getTemplateData: (template) => {
const templateName = template;
return {
bodyText: exampleTemplates[templateName].text,
headerText: exampleTemplates[templateName].headerText,
footerText: exampleTemplates[templateName].footerText,
templateImgUrl: undefined,
};
},
},
];
export const allPossibleMessageTypesExamplesConst = [
{
id: 'simpleText',
text: 'ciao',
sentDate: '2023-10-01T12:00:00Z',
},
{
id: 'imageText',
text: null,
caption: 'immagine 1',
imgUrl: 'https://picsum.photos/200',
sentDate: '2023-10-01T12:00:00Z',
},
{
id: 'videoText',
text: null,
caption: 'video 1',
videoUrl: 'https://www.youtube.com/shorts/isRx40p7doI',
sentDate: '2023-10-01T12:00:00Z',
},
{
id: 'docText',
text: 'Ciao ciao',
caption: 'doc 1',
documentUrl: '/examples/sheldon_cooper.tsx',
sentDate: '2023-10-01T12:00:00Z',
fileName: 'sheldon_cooper.tsx',
},
{
id: 'templateText',
text: '',
templateName: exampleTemplates.wingardium_leviosa.id,
templateVariables: [{ key: 'body_1', value: 'Wingardium Leviosa' }],
getTemplateData: (template) => {
const templateName = template;
const templateData = exampleTemplates[templateName];
return {
bodyText: templateData.text,
headerText: templateData.headerText,
footerText: templateData.footerText,
templateImgUrl: undefined,
};
},
sentDate: '2023-10-01T12:00:00Z',
},
];
export const wMessagesExamplesOptions = allPossibleMessageTypesExamplesConst.map((m) => m.id);
export const baseMessageProps = {
isReceived: true,
templateName: null,
searchString: null,
onSearchRefs: undefined,
focusedRefIndex: null,
focusedKey: null,
templateVariables: null,
getTemplateData: undefined,
text: null,
imgUrl: null,
caption: null,
videoUrl: null,
audioUrl: null,
documentUrl: null,
fileName: null,
buttonPayload: null,
sentDate: null,
readDate: null,
deliveredDate: null,
reaction: null,
};