chore: build

This commit is contained in:
2026-06-11 14:50:59 +02:00
parent 9b50dca96c
commit 3e02aaa9b2
8 changed files with 80 additions and 42 deletions
+5
View File
@@ -246,6 +246,11 @@ func InitDB() *Database {
log.Fatalf("❌ Erreur migration products.coming_soon: %v", err)
}
// Migration: prix actif/inactif sur les prix de produits
if _, err = database.Exec(`ALTER TABLE product_prices ADD COLUMN IF NOT EXISTS active_price BOOLEAN NOT NULL DEFAULT TRUE`); err != nil {
log.Fatalf("❌ Erreur migration product_prices.active_price: %v", err)
}
// Migration: table contacts (SAV Telegram)
if _, err = database.Exec(`CREATE TABLE IF NOT EXISTS contacts (
id SERIAL PRIMARY KEY,
@@ -851,7 +851,7 @@ export default function ProductsScreen() {
key={i}
style={[
styles.info,
!p.active_price && {
p.active_price === false && {
textDecorationLine: "line-through",
color: colors.textMuted,
opacity: 0.5,
+3
View File
@@ -1859,6 +1859,7 @@ export interface PublicSettings {
nowpayments_currencies: string[];
shop_name: string;
two_fa_enabled: boolean;
contact_telegram: string;
}
export const getPublicSettings = async (): Promise<PublicSettings> => {
@@ -1875,6 +1876,7 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
nowpayments_currencies: [],
shop_name: "Milieu-Nantais",
two_fa_enabled: false,
contact_telegram: "",
};
try {
const response = await fetch(`${API_URL}/app-settings`);
@@ -1898,6 +1900,7 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
: [],
shop_name: data.shop_name || "Milieu-Nantais",
two_fa_enabled: data.two_fa_enabled ?? false,
contact_telegram: data.contact_telegram || "",
};
} catch {
return defaults;
+19 -10
View File
@@ -1,7 +1,7 @@
import { useState, useEffect, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import { useCart } from '../../context/useCart';
import { createCheckout, clearCart, extractUsernameFromToken, isUserAuthenticated, getReferralBalance, getPublicSettings, getMyProfile, getCryptoPaymentStatus, getProductById, getMediaUrl } from '../../api/api';
import { createCheckout, clearCart, extractUsernameFromToken, isUserAuthenticated, getReferralBalance, getPublicSettings, getMyProfile, getCryptoPaymentStatus, getProductById, getMediaUrl, getTelegramStatus } from '../../api/api';
import type { CheckoutData, CryptoPaymentStatus } from '../../api/api';
import type { Product } from '../../api/api';
import Navbar from '../../components/Navbar';
@@ -80,6 +80,9 @@ function Checkout() {
const [referralEnabled, setReferralEnabled] = useState(false);
const [useReferral, setUseReferral] = useState(false);
// Telegram
const [telegramLinked, setTelegramLinked] = useState(false);
// Crypto
const [cryptoEnabled, setCryptoEnabled] = useState(false);
const [cryptoOnly, setCryptoOnly] = useState(false);
@@ -129,6 +132,10 @@ function Checkout() {
if (res.client.prenom) setFirstName(res.client.prenom);
}
});
getTelegramStatus().then((res) => {
if (res.linked) setTelegramLinked(true);
});
}, []);
// Charger settings publics (parrainage + crypto)
@@ -578,16 +585,18 @@ function Checkout() {
</div>
)}
<div className="checkout-telegram-note">
<i className="fab fa-telegram" />
<div>
<strong>Compte Telegram requis</strong>
<p>
Votre commande ne pourra être validée que si votre compte Telegram est lié.
Rendez-vous dans votre <a href="/user/profil">profil</a> pour le lier avant de confirmer.
</p>
{!telegramLinked && (
<div className="checkout-telegram-note">
<i className="fab fa-telegram" />
<div>
<strong>Compte Telegram requis</strong>
<p>
Votre commande ne pourra être validée que si votre compte Telegram est lié.
Rendez-vous dans votre <a href="/user/profil">profil</a> pour le lier avant de confirmer.
</p>
</div>
</div>
</div>
)}
<div className="form-actions">
<button
+17 -16
View File
@@ -5,7 +5,6 @@ import { getReferralBalance, isUserAuthenticated, getPublicSettings } from '../.
import type { PublicSettings } from '../../api/api';
import './Parrainage.css';
const TELEGRAM_URL = 'https://t.me/';
const steps = [
{
@@ -140,21 +139,23 @@ export default function Parrainage() {
</div>
{/* Bouton Telegram */}
<div className="parrainage-cta">
<p className="cta-text">
Prêt à parrainer ? Contactez-nous sur Telegram pour enregistrer votre
filleul.
</p>
<a
href={TELEGRAM_URL}
target="_blank"
rel="noopener noreferrer"
className="telegram-btn"
>
<i className="fab fa-telegram telegram-icon"></i>
Contacter sur Telegram
</a>
</div>
{settings?.contact_telegram && (
<div className="parrainage-cta">
<p className="cta-text">
Prêt à parrainer ? Contactez-nous sur Telegram pour enregistrer votre
filleul.
</p>
<a
href={`https://t.me/${settings.contact_telegram}`}
target="_blank"
rel="noopener noreferrer"
className="telegram-btn"
>
<i className="fab fa-telegram telegram-icon"></i>
Contacter @{settings.contact_telegram}
</a>
</div>
)}
</div>
</>
);
+3
View File
@@ -777,6 +777,7 @@ export interface PublicSettings {
nowpayments_currencies: string[];
telegram_notifications_enabled: boolean;
two_fa_enabled: boolean;
contact_telegram: string;
}
export const getPublicSettings = async (): Promise<PublicSettings> => {
@@ -792,6 +793,7 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
nowpayments_currencies: [],
telegram_notifications_enabled: false,
two_fa_enabled: false,
contact_telegram: "",
};
try {
const { data } = await apiClient.get(`${V1}/app-settings`);
@@ -813,6 +815,7 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
telegram_notifications_enabled:
data.telegram_notifications_enabled ?? false,
two_fa_enabled: data.two_fa_enabled ?? false,
contact_telegram: data.contact_telegram || "",
};
} catch {
return defaults;
+7 -1
View File
@@ -21,6 +21,7 @@ import {
getReferralBalance,
getPublicSettings,
getCryptoPaymentStatus,
getTelegramStatus,
} from "../../api/api";
import type { CryptoPaymentStatus } from "../../api/api";
import type { ClientStackParamList } from "../../navigation/types";
@@ -57,6 +58,7 @@ export default function CheckoutScreen() {
// Notif telegram
const [telegramNotificationEnabled, setTelegramNotificationEnabled] =
useState(false);
const [telegramLinked, setTelegramLinked] = useState(false);
// Crypto
const [cryptoEnabled, setCryptoEnabled] = useState(false);
@@ -105,6 +107,10 @@ export default function CheckoutScreen() {
if (savedPhone) setTelephone(savedPhone);
});
getTelegramStatus().then((res) => {
if (res.linked) setTelegramLinked(true);
});
return () => {
if (pollRef.current) clearInterval(pollRef.current);
};
@@ -1027,7 +1033,7 @@ export default function CheckoutScreen() {
)}
{/* Note Telegram */}
{telegramNotificationEnabled && (
{telegramNotificationEnabled && !telegramLinked && (
<View style={styles.telegramNote}>
<Ionicons
name="paper-plane-outline"
+25 -14
View File
@@ -5,27 +5,36 @@ import {
ScrollView,
StyleSheet,
Linking,
TouchableOpacity,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { useTheme } from "../../context/ThemeContext";
import { spacing, borderRadius, fontSize, fontWeight } from "../../theme";
import { getReferralBalance } from "../../api/api";
import { getReferralBalance, getPublicSettings } from "../../api/api";
export default function ParrainageScreen() {
const { colors } = useTheme();
const [balance, setBalance] = useState<number>(0);
const [contactTelegram, setContactTelegram] = useState<string>("");
useEffect(() => {
getReferralBalance().then((res) => {
if (res.success) setBalance(res.balance);
});
getPublicSettings().then((settings) => {
if (settings.contact_telegram) {
setContactTelegram(settings.contact_telegram);
}
});
}, []);
const steps = [
{
icon: "chatbubble-ellipses-outline" as const,
title: "1. Contacte-nous sur Telegram",
desc: "Envoie un message à @milieu_nantais en indiquant ton username et le username de la personne que tu as parrainée.",
desc: contactTelegram
? `Envoie un message à @${contactTelegram} en indiquant ton username et le username de la personne que tu as parrainée.`
: "Envoie-nous un message sur Telegram en indiquant ton username et le username de la personne que tu as parrainée.",
},
{
icon: "checkmark-circle-outline" as const,
@@ -152,6 +161,12 @@ export default function ParrainageScreen() {
[colors],
);
const handleTelegramPress = () => {
if (contactTelegram) {
Linking.openURL(`https://t.me/${contactTelegram}`);
}
};
return (
<ScrollView style={styles.container} contentContainerStyle={styles.content}>
{/* Solde actuel */}
@@ -190,18 +205,14 @@ export default function ParrainageScreen() {
</View>
{/* Bouton Telegram */}
<View
style={styles.telegramBtn}
// Utiliser TouchableOpacity si besoin d'interaction
>
<Ionicons name="paper-plane-outline" size={20} color="#fff" />
<Text
style={styles.telegramText}
onPress={() => Linking.openURL("https://t.me/milieu_nantais")}
>
Contacter @milieu_nantais
</Text>
</View>
{contactTelegram ? (
<TouchableOpacity style={styles.telegramBtn} onPress={handleTelegramPress}>
<Ionicons name="paper-plane-outline" size={20} color="#fff" />
<Text style={styles.telegramText}>
Contacter @{contactTelegram}
</Text>
</TouchableOpacity>
) : null}
</ScrollView>
);
}