diff --git a/src/App.tsx b/src/App.tsx index 44cbafb..343fee3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -28,7 +28,7 @@ export function App() { const [openSection, setOpenSection] = useState('family'); const [needRefresh, setNeedRefresh] = useState(true); const [isFullnessHighlighted, setIsFullnessHighlighted] = useState(false); - const [mobileShowFilters, setMobileShowFilters] = useState(true); + const [mobileShowFilters, setMobileShowFilters] = useState(false); const {setInitial, precision} = useGlobalZustandState((state) => state); const dispatch = useAppDispatch(); @@ -344,8 +344,8 @@ const Container = styled.main<{$fullHeight: boolean}>` overflow: hidden; @media (max-width: 900px) { - flex-direction: column; - height: ${$fullHeight => $fullHeight ? 'auto' : '90vh'}; + //flex-direction: column; + height: 90vh; } ${({ theme }) => theme.media.mobile(css<{$fullHeight: boolean}>` @@ -387,6 +387,7 @@ const LeftColumn = styled(Column)<{$dataShow: boolean}>` position: relative; ${props => props.theme.media.mobile(css` display: ${props.$dataShow ? 'flex' : 'none'}; + max-width: 100%; `)} `; diff --git a/src/components/Cart/Cart.tsx b/src/components/Cart/Cart.tsx index c012af2..d1ddd31 100644 --- a/src/components/Cart/Cart.tsx +++ b/src/components/Cart/Cart.tsx @@ -35,13 +35,14 @@ export function Cart({ }: CartProps) { const [showNotEnoughPopup, setShowNotEnoughPopup] = useState(false); const [visibleCount, setVisibleCount] = useState(5); + const [showMore, setShowMore] = useState(true); const [displayText, setDisplayText] = useState(''); const [selectedProduct, setSelectedProduct] = useState(null); const [processingProductName, setProcessingProductName] = useState(null); const {showFullRefreshButton, excess} = useGlobalZustandState((state) => state); - const visibleProducts = products.slice(0, visibleCount); + const visibleProducts = showMore ? products.slice(0, visibleCount) : products; const remaining = products.length - visibleProducts.length; const totalPrice = useMemo( @@ -144,9 +145,11 @@ export function Cart({ )} - {remaining > 0 && ( + {showMore && remaining > 0 && ( - setVisibleCount(products.length)}> + { + setShowMore(false); + }}> Показать ещё {remaining} товаров { const [email, setEmail] = useState(""); + const [error, setError] = useState(""); const [value, setValue] = useState(''); const [sent, setSent] = useState(false); @@ -37,7 +38,15 @@ export const NotEnoughPopup = ({onClose}: any) => { }}> - subscribeOnFail(email, value).then(() => {setSent(true)})}>Отправить + subscribeOnFail(email, value) + .then((d) => { + if (d.status === 400) { + setError(d.error_message) + } else { + setSent(true) + } + })}>Отправить + {error ? error : <> } } @@ -158,4 +167,9 @@ const ActiveButton = styled(Button)` &:active { background-color: #4A8D19; } -`; \ No newline at end of file +`; +const Error = styled.div` + text-align: center; + height: 16px; + padding-top: 8px; +` \ No newline at end of file diff --git a/src/components/Family/PersonModal.tsx b/src/components/Family/PersonModal.tsx index 56d609f..96f1430 100644 --- a/src/components/Family/PersonModal.tsx +++ b/src/components/Family/PersonModal.tsx @@ -19,7 +19,7 @@ interface PersonForm { age: string; weight: string; height: string; - avoided: string[]; + avoid: string[]; favorite: string[]; } @@ -29,7 +29,7 @@ const defaultForm: PersonForm = { age: '', weight: '', height: '', - avoided: [], + avoid: [], favorite: [], }; @@ -54,7 +54,7 @@ export function PersonModal({ age: String(user.age), weight: user.weight ? String(user.weight) : '', height: user.height ? String(user.height) : '', - avoided: user.avoided ?? [], + avoid: user.avoid ?? [], favorite: user.favorite ?? [], }); } else { @@ -74,7 +74,7 @@ export function PersonModal({ function handleAvoidChange(tags: string[]) { setForm(current => ({ ...current, - avoided: tags, + avoid: tags, favorite: current.favorite.filter(tag => !tags.includes(tag)), })); } @@ -83,7 +83,7 @@ export function PersonModal({ setForm(current => ({ ...current, favorite: tags, - avoided: current.avoided.filter(tag => !tags.includes(tag)), + avoid: current.avoid.filter(tag => !tags.includes(tag)), })); } @@ -107,7 +107,7 @@ export function PersonModal({ age, weight: form.weight ? Number(form.weight) : undefined, height: form.height ? Number(form.height) : undefined, - avoided: form.avoided, + avoid: form.avoid, favorite: form.favorite, }); } @@ -128,20 +128,20 @@ export function PersonModal({ - {/*{((showExpanded == 'favorite' ? form.favorite : form.avoided) || []).map(tag => (*/} + {/*{((showExpanded == 'favorite' ? form.favorite : form.avoid) || []).map(tag => (*/} {availableTags.map(tag => ( -1} + $active={(showExpanded == 'favorite' ? form.favorite : form.avoid).indexOf(tag) > -1} onClick={() => { - if ((showExpanded == 'favorite' ? form.favorite : form.avoided).indexOf(tag) > -1) { + if ((showExpanded == 'favorite' ? form.favorite : form.avoid).indexOf(tag) > -1) { (showExpanded == 'favorite' ? handleFavoriteChange : handleAvoidChange)( - ((showExpanded == 'favorite' ? form.favorite : form.avoided) || []).filter(item => item != tag) + ((showExpanded == 'favorite' ? form.favorite : form.avoid) || []).filter(item => item != tag) ) } else { (showExpanded == 'favorite' ? handleFavoriteChange : handleAvoidChange)( - ((showExpanded == 'favorite' ? form.favorite : form.avoided) || []).concat(tag) + ((showExpanded == 'favorite' ? form.favorite : form.avoid) || []).concat(tag) ) } }} @@ -225,7 +225,7 @@ export function PersonModal({ setShowExpanded('favorite')} /> @@ -412,14 +412,11 @@ const SaveButton = styled.button` `; const MobileBack = styled.div` - display: none; + display: flex; top:0; left:0; width: 24px; height: 24px; justify-content: center; align-items: center; - ${({ theme }) => theme.media.mobile(css` - display: flex; - `)} ` \ No newline at end of file diff --git a/src/types/user.ts b/src/types/user.ts index de63ddb..9b7a7fc 100644 --- a/src/types/user.ts +++ b/src/types/user.ts @@ -7,6 +7,6 @@ export interface User { age: number; weight?: number; height?: number; - avoided: string[]; + avoid: string[]; favorite: string[]; } \ No newline at end of file diff --git a/src_static/autocart.js b/src_static/autocart.js index 1744d8e..7cf6c26 100644 --- a/src_static/autocart.js +++ b/src_static/autocart.js @@ -2352,7 +2352,7 @@ function wholeRender(initialData) { favTags.push(el.textContent.trim().replace('×', '').trim()); }); - const personData = { name, age, weight, height, gender, avoided: forbTags, favorite: favTags }; + const personData = { name, age, weight, height, gender, avoid: forbTags, favorite: favTags }; if (editingIndex !== null) { people[editingIndex] = personData; editingIndex = null;