avoided user groups
This commit is contained in:
parent
3480e3141d
commit
259dec1df6
@ -28,7 +28,7 @@ export function App() {
|
|||||||
const [openSection, setOpenSection] = useState<string>('family');
|
const [openSection, setOpenSection] = useState<string>('family');
|
||||||
const [needRefresh, setNeedRefresh] = useState<boolean>(true);
|
const [needRefresh, setNeedRefresh] = useState<boolean>(true);
|
||||||
const [isFullnessHighlighted, setIsFullnessHighlighted] = useState<boolean>(false);
|
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 {setInitial, precision} = useGlobalZustandState((state) => state);
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@ -344,8 +344,8 @@ const Container = styled.main<{$fullHeight: boolean}>`
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
flex-direction: column;
|
//flex-direction: column;
|
||||||
height: ${$fullHeight => $fullHeight ? 'auto' : '90vh'};
|
height: 90vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
${({ theme }) => theme.media.mobile(css<{$fullHeight: boolean}>`
|
${({ theme }) => theme.media.mobile(css<{$fullHeight: boolean}>`
|
||||||
@ -387,6 +387,7 @@ const LeftColumn = styled(Column)<{$dataShow: boolean}>`
|
|||||||
position: relative;
|
position: relative;
|
||||||
${props => props.theme.media.mobile(css`
|
${props => props.theme.media.mobile(css`
|
||||||
display: ${props.$dataShow ? 'flex' : 'none'};
|
display: ${props.$dataShow ? 'flex' : 'none'};
|
||||||
|
max-width: 100%;
|
||||||
`)}
|
`)}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -35,13 +35,14 @@ export function Cart({
|
|||||||
}: CartProps) {
|
}: CartProps) {
|
||||||
const [showNotEnoughPopup, setShowNotEnoughPopup] = useState(false);
|
const [showNotEnoughPopup, setShowNotEnoughPopup] = useState(false);
|
||||||
const [visibleCount, setVisibleCount] = useState(5);
|
const [visibleCount, setVisibleCount] = useState(5);
|
||||||
|
const [showMore, setShowMore] = useState(true);
|
||||||
const [displayText, setDisplayText] = useState('');
|
const [displayText, setDisplayText] = useState('');
|
||||||
const [selectedProduct, setSelectedProduct] = useState<Product | null>(null);
|
const [selectedProduct, setSelectedProduct] = useState<Product | null>(null);
|
||||||
const [processingProductName, setProcessingProductName] = useState<string | null>(null);
|
const [processingProductName, setProcessingProductName] = useState<string | null>(null);
|
||||||
|
|
||||||
const {showFullRefreshButton, excess} = useGlobalZustandState((state) => state);
|
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 remaining = products.length - visibleProducts.length;
|
||||||
|
|
||||||
const totalPrice = useMemo(
|
const totalPrice = useMemo(
|
||||||
@ -144,9 +145,11 @@ export function Cart({
|
|||||||
)}
|
)}
|
||||||
</ScrollWrapper>
|
</ScrollWrapper>
|
||||||
|
|
||||||
{remaining > 0 && (
|
{showMore && remaining > 0 && (
|
||||||
<ShowMoreWrap>
|
<ShowMoreWrap>
|
||||||
<ShowMore type="button" onClick={() => setVisibleCount(products.length)}>
|
<ShowMore type="button" onClick={() => {
|
||||||
|
setShowMore(false);
|
||||||
|
}}>
|
||||||
Показать ещё <span>{remaining}</span> товаров
|
Показать ещё <span>{remaining}</span> товаров
|
||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<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"
|
<path d="M19 9L12 16L5 9" stroke="#5EA12D" strokeWidth="2" strokeLinecap="round"
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {subscribeOnFail} from "../../api/promoApi";
|
|||||||
|
|
||||||
export const NotEnoughPopup = ({onClose}: any) => {
|
export const NotEnoughPopup = ({onClose}: any) => {
|
||||||
const [email, setEmail] = useState<string>("");
|
const [email, setEmail] = useState<string>("");
|
||||||
|
const [error, setError] = useState<string>("");
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
const [sent, setSent] = useState(false);
|
const [sent, setSent] = useState(false);
|
||||||
|
|
||||||
@ -37,7 +38,15 @@ export const NotEnoughPopup = ({onClose}: any) => {
|
|||||||
}}></FeedbackTextarea>
|
}}></FeedbackTextarea>
|
||||||
<V16/>
|
<V16/>
|
||||||
<V24/>
|
<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 : <> </>}</Error>
|
||||||
</>}
|
</>}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Window>
|
</Window>
|
||||||
@ -158,4 +167,9 @@ const ActiveButton = styled(Button)`
|
|||||||
&:active {
|
&:active {
|
||||||
background-color: #4A8D19;
|
background-color: #4A8D19;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
const Error = styled.div`
|
||||||
|
text-align: center;
|
||||||
|
height: 16px;
|
||||||
|
padding-top: 8px;
|
||||||
|
`
|
||||||
@ -19,7 +19,7 @@ interface PersonForm {
|
|||||||
age: string;
|
age: string;
|
||||||
weight: string;
|
weight: string;
|
||||||
height: string;
|
height: string;
|
||||||
avoided: string[];
|
avoid: string[];
|
||||||
favorite: string[];
|
favorite: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ const defaultForm: PersonForm = {
|
|||||||
age: '',
|
age: '',
|
||||||
weight: '',
|
weight: '',
|
||||||
height: '',
|
height: '',
|
||||||
avoided: [],
|
avoid: [],
|
||||||
favorite: [],
|
favorite: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export function PersonModal({
|
|||||||
age: String(user.age),
|
age: String(user.age),
|
||||||
weight: user.weight ? String(user.weight) : '',
|
weight: user.weight ? String(user.weight) : '',
|
||||||
height: user.height ? String(user.height) : '',
|
height: user.height ? String(user.height) : '',
|
||||||
avoided: user.avoided ?? [],
|
avoid: user.avoid ?? [],
|
||||||
favorite: user.favorite ?? [],
|
favorite: user.favorite ?? [],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -74,7 +74,7 @@ export function PersonModal({
|
|||||||
function handleAvoidChange(tags: string[]) {
|
function handleAvoidChange(tags: string[]) {
|
||||||
setForm(current => ({
|
setForm(current => ({
|
||||||
...current,
|
...current,
|
||||||
avoided: tags,
|
avoid: tags,
|
||||||
favorite: current.favorite.filter(tag => !tags.includes(tag)),
|
favorite: current.favorite.filter(tag => !tags.includes(tag)),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ export function PersonModal({
|
|||||||
setForm(current => ({
|
setForm(current => ({
|
||||||
...current,
|
...current,
|
||||||
favorite: tags,
|
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,
|
age,
|
||||||
weight: form.weight ? Number(form.weight) : undefined,
|
weight: form.weight ? Number(form.weight) : undefined,
|
||||||
height: form.height ? Number(form.height) : undefined,
|
height: form.height ? Number(form.height) : undefined,
|
||||||
avoided: form.avoided,
|
avoid: form.avoid,
|
||||||
favorite: form.favorite,
|
favorite: form.favorite,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -128,20 +128,20 @@ export function PersonModal({
|
|||||||
</Header>
|
</Header>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<TagsWrap>
|
<TagsWrap>
|
||||||
{/*{((showExpanded == 'favorite' ? form.favorite : form.avoided) || []).map(tag => (*/}
|
{/*{((showExpanded == 'favorite' ? form.favorite : form.avoid) || []).map(tag => (*/}
|
||||||
{availableTags.map(tag => (
|
{availableTags.map(tag => (
|
||||||
<Tag
|
<Tag
|
||||||
key={tag}
|
key={tag}
|
||||||
$type={showExpanded}
|
$type={showExpanded}
|
||||||
$active={(showExpanded == 'favorite' ? form.favorite : form.avoided).indexOf(tag) > -1}
|
$active={(showExpanded == 'favorite' ? form.favorite : form.avoid).indexOf(tag) > -1}
|
||||||
onClick={() => {
|
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' ? handleFavoriteChange : handleAvoidChange)(
|
||||||
((showExpanded == 'favorite' ? form.favorite : form.avoided) || []).filter(item => item != tag)
|
((showExpanded == 'favorite' ? form.favorite : form.avoid) || []).filter(item => item != tag)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(showExpanded == 'favorite' ? handleFavoriteChange : handleAvoidChange)(
|
(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
|
<TagsInput
|
||||||
title="Исключить"
|
title="Исключить"
|
||||||
type="avoid"
|
type="avoid"
|
||||||
value={form.avoided}
|
value={form.avoid}
|
||||||
availableTags={availableTags}
|
availableTags={availableTags}
|
||||||
excludedTags={form.favorite}
|
excludedTags={form.favorite}
|
||||||
onChange={handleAvoidChange}
|
onChange={handleAvoidChange}
|
||||||
@ -237,7 +237,7 @@ export function PersonModal({
|
|||||||
type="favorite"
|
type="favorite"
|
||||||
value={form.favorite}
|
value={form.favorite}
|
||||||
availableTags={availableTags}
|
availableTags={availableTags}
|
||||||
excludedTags={form.avoided}
|
excludedTags={form.avoid}
|
||||||
onChange={handleFavoriteChange}
|
onChange={handleFavoriteChange}
|
||||||
onExpand={() => setShowExpanded('favorite')}
|
onExpand={() => setShowExpanded('favorite')}
|
||||||
/>
|
/>
|
||||||
@ -412,14 +412,11 @@ const SaveButton = styled.button`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const MobileBack = styled.div`
|
const MobileBack = styled.div`
|
||||||
display: none;
|
display: flex;
|
||||||
top:0;
|
top:0;
|
||||||
left:0;
|
left:0;
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
${({ theme }) => theme.media.mobile(css`
|
|
||||||
display: flex;
|
|
||||||
`)}
|
|
||||||
`
|
`
|
||||||
@ -7,6 +7,6 @@ export interface User {
|
|||||||
age: number;
|
age: number;
|
||||||
weight?: number;
|
weight?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
avoided: string[];
|
avoid: string[];
|
||||||
favorite: string[];
|
favorite: string[];
|
||||||
}
|
}
|
||||||
@ -2352,7 +2352,7 @@ function wholeRender(initialData) {
|
|||||||
favTags.push(el.textContent.trim().replace('×', '').trim());
|
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) {
|
if (editingIndex !== null) {
|
||||||
people[editingIndex] = personData;
|
people[editingIndex] = personData;
|
||||||
editingIndex = null;
|
editingIndex = null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user