avoided user groups

This commit is contained in:
Zakhar 2026-09-06 01:56:59 +03:00
parent 3480e3141d
commit 259dec1df6
6 changed files with 42 additions and 27 deletions

View File

@ -28,7 +28,7 @@ export function App() {
const [openSection, setOpenSection] = useState<string>('family');
const [needRefresh, setNeedRefresh] = useState<boolean>(true);
const [isFullnessHighlighted, setIsFullnessHighlighted] = useState<boolean>(false);
const [mobileShowFilters, setMobileShowFilters] = useState<boolean>(true);
const [mobileShowFilters, setMobileShowFilters] = useState<boolean>(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%;
`)}
`;

View File

@ -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<Product | null>(null);
const [processingProductName, setProcessingProductName] = useState<string | null>(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({
)}
</ScrollWrapper>
{remaining > 0 && (
{showMore && remaining > 0 && (
<ShowMoreWrap>
<ShowMore type="button" onClick={() => setVisibleCount(products.length)}>
<ShowMore type="button" onClick={() => {
setShowMore(false);
}}>
Показать ещё <span>{remaining}</span> товаров
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19 9L12 16L5 9" stroke="#5EA12D" strokeWidth="2" strokeLinecap="round"

View File

@ -6,6 +6,7 @@ import {subscribeOnFail} from "../../api/promoApi";
export const NotEnoughPopup = ({onClose}: any) => {
const [email, setEmail] = useState<string>("");
const [error, setError] = useState<string>("");
const [value, setValue] = useState('');
const [sent, setSent] = useState(false);
@ -37,7 +38,15 @@ export const NotEnoughPopup = ({onClose}: any) => {
}}></FeedbackTextarea>
<V16/>
<V24/>
<ActiveButton onClick={() => subscribeOnFail(email, value).then(() => {setSent(true)})}>Отправить</ActiveButton>
<ActiveButton onClick={() => subscribeOnFail(email, value)
.then((d) => {
if (d.status === 400) {
setError(d.error_message)
} else {
setSent(true)
}
})}>Отправить</ActiveButton>
<Error>{error ? error : <>&nbsp;</>}</Error>
</>}
</ModalContent>
</Window>
@ -158,4 +167,9 @@ const ActiveButton = styled(Button)`
&:active {
background-color: #4A8D19;
}
`;
`;
const Error = styled.div`
text-align: center;
height: 16px;
padding-top: 8px;
`

View File

@ -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({
</Header>
<FormGroup>
<TagsWrap>
{/*{((showExpanded == 'favorite' ? form.favorite : form.avoided) || []).map(tag => (*/}
{/*{((showExpanded == 'favorite' ? form.favorite : form.avoid) || []).map(tag => (*/}
{availableTags.map(tag => (
<Tag
key={tag}
$type={showExpanded}
$active={(showExpanded == 'favorite' ? form.favorite : form.avoided).indexOf(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({
<TagsInput
title="Исключить"
type="avoid"
value={form.avoided}
value={form.avoid}
availableTags={availableTags}
excludedTags={form.favorite}
onChange={handleAvoidChange}
@ -237,7 +237,7 @@ export function PersonModal({
type="favorite"
value={form.favorite}
availableTags={availableTags}
excludedTags={form.avoided}
excludedTags={form.avoid}
onChange={handleFavoriteChange}
onExpand={() => 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;
`)}
`

View File

@ -7,6 +7,6 @@ export interface User {
age: number;
weight?: number;
height?: number;
avoided: string[];
avoid: string[];
favorite: string[];
}

View File

@ -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;