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