Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 6x 6x 6x 2x 2x 6x 1x 1x 6x | import { useState } from 'react';
import type { Additive } from '@/src/lib/supabase';
/**
* 添加剂详情模态框管理 Hook
* 负责添加剂详情模态框的状态管理
*/
export function useAdditiveModal() {
const [selectedAdditive, setSelectedAdditive] = useState<Additive | null>(null);
const [modalVisible, setModalVisible] = useState(false);
// 显示添加剂详情
const handleAdditivePress = (additive: Additive) => {
setSelectedAdditive(additive);
setModalVisible(true);
};
// 关闭模态框
const handleCloseModal = () => {
setModalVisible(false);
setSelectedAdditive(null);
};
return {
selectedAdditive,
modalVisible,
handleAdditivePress,
handleCloseModal,
};
}
|