App : page Campagnes retravaillée
Audience mise en avant, rédaction dans une carte, aperçu en direct de la notification, compteur de caractères, historique avec date, auteur et nombre de cartes en pastilles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
935f3f9354
commit
f07e899d8a
1 changed files with 91 additions and 51 deletions
|
|
@ -69,17 +69,42 @@ export default function Campaigns() {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const shownTitle = (title ?? data?.defaultTitle ?? '').trim() || store.name;
|
||||||
|
const maxLength = data?.maxLength ?? 160;
|
||||||
|
const input = {
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: c.border,
|
||||||
|
borderRadius: 14,
|
||||||
|
padding: 14,
|
||||||
|
backgroundColor: c.bg,
|
||||||
|
color: c.text,
|
||||||
|
fontFamily: font.regular,
|
||||||
|
fontSize: 17,
|
||||||
|
opacity: blocked ? 0.6 : 1,
|
||||||
|
} as const;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView contentContainerStyle={{ padding: 20, gap: 16 }} keyboardShouldPersistTaps="handled">
|
<ScrollView contentContainerStyle={{ padding: 20, gap: 18 }} keyboardShouldPersistTaps="handled" bounces={false} overScrollMode="never">
|
||||||
{error && <Banner tone="error">{error}</Banner>}
|
{error && <Banner tone="error">{error}</Banner>}
|
||||||
{sent && <Banner tone="ok">Campagne envoyée. Les cartes de vos clients se mettent à jour dans les minutes qui suivent.</Banner>}
|
{sent && <Banner tone="ok">Campagne envoyée. Les cartes de vos clients se mettent à jour dans les minutes qui suivent.</Banner>}
|
||||||
{data && !data.allowed && <Banner tone="warn">Le module Campagnes n'est pas actif : activez-le dans Modules, ou contactez MonEspacePro s'il n'est pas inclus dans votre formule.</Banner>}
|
{data && !data.allowed && <Banner tone="warn">Le module Campagnes n'est pas actif : activez-le dans Configuration → Modules, ou contactez MonEspacePro s'il n'est pas inclus dans votre formule.</Banner>}
|
||||||
|
{data?.nextAllowedAt && <Banner tone="warn">Prochain envoi possible le {when(data.nextAllowedAt)}.</Banner>}
|
||||||
|
|
||||||
<T v="muted">
|
{/* Audience */}
|
||||||
Votre message apparaît en notification sur le téléphone de vos clients et reste visible sur leur carte.
|
<View style={{ backgroundColor: c.primary, borderRadius: 22, padding: 20, flexDirection: 'row', alignItems: 'center', gap: 14 }}>
|
||||||
{data ? ` ${data.audience.cards} cartes au total.` : ''}
|
<View style={{ width: 52, height: 52, borderRadius: 16, backgroundColor: 'rgba(255,255,255,0.18)', alignItems: 'center', justifyContent: 'center' }}>
|
||||||
</T>
|
<T style={{ fontSize: 26 }}>📣</T>
|
||||||
<T v="label">Titre de la notification</T>
|
</View>
|
||||||
|
<View style={{ flex: 1 }}>
|
||||||
|
<T style={{ color: c.onPrimary, fontFamily: font.extrabold, fontSize: 28 }}>{data?.audience.cards ?? '—'}</T>
|
||||||
|
<T style={{ color: c.onPrimary, opacity: 0.85, fontSize: 14 }}>clients recevront la notification sur leur téléphone</T>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* Rédaction */}
|
||||||
|
<Card style={{ gap: 12 }}>
|
||||||
|
<T v="h2">Nouvelle campagne</T>
|
||||||
|
<T v="label">Titre</T>
|
||||||
<TextInput
|
<TextInput
|
||||||
value={title ?? data?.defaultTitle ?? ''}
|
value={title ?? data?.defaultTitle ?? ''}
|
||||||
onChangeText={setTitle}
|
onChangeText={setTitle}
|
||||||
|
|
@ -88,47 +113,62 @@ export default function Campaigns() {
|
||||||
placeholder={store.name}
|
placeholder={store.name}
|
||||||
placeholderTextColor={c.text3}
|
placeholderTextColor={c.text3}
|
||||||
accessibilityLabel="Titre de la notification"
|
accessibilityLabel="Titre de la notification"
|
||||||
style={{ borderWidth: 1, borderColor: c.border, borderRadius: 14, padding: 14, backgroundColor: c.surface, color: c.text, fontFamily: font.regular, fontSize: 17, opacity: blocked ? 0.6 : 1 }}
|
style={input}
|
||||||
/>
|
/>
|
||||||
<T v="muted" style={{ fontSize: 13, marginTop: -8 }}>Affiché sur Google Wallet ; sur iPhone, le nom du magasin apparaît toujours.</T>
|
|
||||||
<T v="label">Message</T>
|
<T v="label">Message</T>
|
||||||
<TextInput
|
<TextInput
|
||||||
value={message}
|
value={message}
|
||||||
onChangeText={setMessage}
|
onChangeText={setMessage}
|
||||||
editable={!blocked && !busy}
|
editable={!blocked && !busy}
|
||||||
multiline
|
multiline
|
||||||
maxLength={data?.maxLength ?? 160}
|
maxLength={maxLength}
|
||||||
placeholder="Ex. : -20 % sur les viennoiseries ce samedi !"
|
placeholder="Ex. : -20 % sur les viennoiseries ce samedi !"
|
||||||
placeholderTextColor={c.text3}
|
placeholderTextColor={c.text3}
|
||||||
accessibilityLabel="Message de la campagne"
|
accessibilityLabel="Message de la campagne"
|
||||||
style={{
|
style={{ ...input, minHeight: 110, textAlignVertical: 'top' }}
|
||||||
minHeight: 110,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: c.border,
|
|
||||||
borderRadius: 14,
|
|
||||||
padding: 14,
|
|
||||||
backgroundColor: c.surface,
|
|
||||||
color: c.text,
|
|
||||||
fontFamily: font.regular,
|
|
||||||
fontSize: 17,
|
|
||||||
textAlignVertical: 'top',
|
|
||||||
opacity: blocked ? 0.6 : 1,
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<T v="muted" style={{ fontSize: 13 }}>{text.length} / {data?.maxLength ?? 160} · une campagne toutes les {data?.minIntervalHours ?? 24} h maximum</T>
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
||||||
{data?.nextAllowedAt && <Banner tone="warn">Prochain envoi possible le {when(data.nextAllowedAt)}.</Banner>}
|
<T v="muted" style={{ fontSize: 13 }}>1 campagne toutes les {data?.minIntervalHours ?? 24} h maximum</T>
|
||||||
<Button label="Envoyer la campagne" onPress={send} disabled={blocked || text.length < 5} loading={busy} />
|
<T style={{ fontSize: 13, fontFamily: font.semibold, color: text.length > maxLength - 15 ? c.warn : c.text3 }}>
|
||||||
|
{text.length} / {maxLength}
|
||||||
|
</T>
|
||||||
|
</View>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{/* Aperçu de la notification */}
|
||||||
|
<View style={{ gap: 8 }}>
|
||||||
|
<T v="label" style={{ color: c.text3, textTransform: 'uppercase', fontSize: 13, letterSpacing: 0.5 }}>Aperçu</T>
|
||||||
|
<View style={{ backgroundColor: c.surface2, borderRadius: 22, padding: 14, flexDirection: 'row', gap: 12, alignItems: 'flex-start' }}>
|
||||||
|
<View style={{ width: 40, height: 40, borderRadius: 10, backgroundColor: store.design.backgroundColor, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
|
<T style={{ color: store.design.foregroundColor, fontFamily: font.extrabold, fontSize: 18 }}>{store.name.charAt(0).toUpperCase()}</T>
|
||||||
|
</View>
|
||||||
|
<View style={{ flex: 1, gap: 2 }}>
|
||||||
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
||||||
|
<T v="label" numberOfLines={1} style={{ flex: 1 }}>{shownTitle}</T>
|
||||||
|
<T v="muted" style={{ fontSize: 12 }}>maintenant</T>
|
||||||
|
</View>
|
||||||
|
<T style={{ fontSize: 15, lineHeight: 20, color: text ? c.text : c.text3 }}>{text || 'Votre message apparaîtra ici.'}</T>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<T v="muted" style={{ fontSize: 12 }}>Sur iPhone, le nom du magasin remplace toujours le titre.</T>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<Button large label="Envoyer la campagne" onPress={send} disabled={blocked || text.length < 5} loading={busy} />
|
||||||
|
|
||||||
{!!data?.items.length && (
|
{!!data?.items.length && (
|
||||||
<View style={{ gap: 10, marginTop: 8 }}>
|
<View style={{ gap: 10, marginTop: 6 }}>
|
||||||
<T v="h2">Campagnes envoyées</T>
|
<T v="h2">Campagnes envoyées</T>
|
||||||
{data.items.map((i) => (
|
{data.items.map((i) => (
|
||||||
<Card key={i.id} style={{ padding: 14, gap: 4 }}>
|
<Card key={i.id} style={{ padding: 14, gap: 6 }}>
|
||||||
{!!i.title && <T v="label">{i.title}</T>}
|
{!!i.title && <T v="label">{i.title}</T>}
|
||||||
<T>{i.message}</T>
|
<T style={{ fontSize: 15, lineHeight: 21 }}>{i.message}</T>
|
||||||
<T v="muted" style={{ fontSize: 13 }}>
|
<View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 6, marginTop: 2 }}>
|
||||||
{when(i.createdAt)} · {i.sentByName} · {i.cards} cartes
|
{[when(i.createdAt), i.sentByName, `${i.cards} cartes`].map((chip) => (
|
||||||
</T>
|
<View key={chip} style={{ paddingHorizontal: 8, paddingVertical: 2, borderRadius: 999, backgroundColor: c.surface2 }}>
|
||||||
|
<T v="muted" style={{ fontSize: 12 }}>{chip}</T>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue