Skip to content

Commit

Permalink
search form ready
Browse files Browse the repository at this point in the history
  • Loading branch information
ramory-l committed Jan 5, 2021
1 parent aac6ac7 commit 07e3b84
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 23 deletions.
7 changes: 7 additions & 0 deletions frontend/src/components/common/styles/statusIndicator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@
background-color: gray;
box-shadow: 0 0 10px 3px gray;
}

@media (max-width: 500px) {
.StatusIndicator {
width: 10px;
height: 10px;
}
}
34 changes: 21 additions & 13 deletions frontend/src/components/searchForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class SearchForm extends Form {
data: {
man: false,
woman: false,
rateFrom: "",
rateTo: "",
ageFrom: 18,
ageTo: 80,
to_rate: "",
rate_confirm: "",
to_age: 18,
age_confirm: 80,
radius: "",
tags: "",
},
Expand All @@ -22,11 +22,19 @@ class SearchForm extends Form {
schema = Joi.object({
man: Joi.boolean().required().label("Man"),
woman: Joi.boolean().required().label("Woman"),
rateFrom: Joi.number().optional().empty("").label("Rate From"),
rateTo: Joi.number().optional().empty("").label("Rate To"),
ageFrom: Joi.number().min(18).required().label("Age From"),
ageTo: Joi.number().min(18).max(90).required().label("Age To"),
radius: Joi.number().optional().empty("").label("Radius"),
to_rate: Joi.number()
.less(Joi.ref("rate_confirm"))
.optional()
.empty("")
.label("Rate From"),
rate_confirm: Joi.number().optional().empty("").label("Rate To"),
to_age: Joi.number()
.less(Joi.ref("age_confirm"))
.min(18)
.required()
.label("Age From"),
age_confirm: Joi.number().required().max(90).label("Age To"),
radius: Joi.number().optional().min(0).empty("").label("Radius"),
tags: Joi.string().optional().label("Tags"),
});

Expand All @@ -47,10 +55,10 @@ class SearchForm extends Form {
</div>
<div className="SearchForm-Options">
<div className="Options-Title">Options:</div>
{this.renderInput("rateFrom", "Rate From")}
{this.renderInput("rateTo", "Rate To")}
{this.renderInput("ageFrom", "Age From")}
{this.renderInput("ageTo", "Age To")}
{this.renderInput("to_rate", "Rate From")}
{this.renderInput("rate_confirm", "Rate To")}
{this.renderInput("to_age", "Age From")}
{this.renderInput("age_confirm", "Age To")}
</div>
<div className="SearchForm-Location">
<div className="Location-Title">Location:</div>
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/styles/searchForm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
border-radius: 5px;
padding: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
font-family: "Cinzel Decorative", cursive;
}

.SearchForm-Gender {
Expand Down Expand Up @@ -55,8 +54,8 @@
}
}

@media (max-width: 350px) {
@media (max-width: 500px) {
.SearchForm {
display: block;
flex-direction: column;
}
}
30 changes: 24 additions & 6 deletions frontend/src/components/tagsInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ const TagsInput = ({ userId, editMode, isSearchForm, onHandleTags }) => {
? await getUserTags(getCurrentUser().id)
: await getUserTags(userId);
const { data: suggestions } = await getTopTags();
const tagsStr = tags
.map((tag) => {
return `${tag.name}`;
})
.join(",");
onHandleTags(tagsStr);
if (isSearchForm) {
const tagsStr = tags
.map((tag) => {
return `${tag.name}`;
})
.join(",");
onHandleTags(tagsStr);
}
setTags(tags);
setSuggestions(suggestions);
};
Expand All @@ -32,12 +34,28 @@ const TagsInput = ({ userId, editMode, isSearchForm, onHandleTags }) => {
const newTags = tags.slice(0);
const tag = newTags.splice(i, 1);
await deleteTag(tag[0].name);
if (isSearchForm) {
const tagsStr = newTags
.map((tag) => {
return `${tag.name}`;
})
.join(",");
onHandleTags(tagsStr);
}
setTags(newTags);
};

const handleAddition = async (tag) => {
const newTags = [].concat(tags, tag);
await createTag(tag.name);
if (isSearchForm) {
const tagsStr = newTags
.map((tag) => {
return `${tag.name}`;
})
.join(",");
onHandleTags(tagsStr);
}
setTags(newTags);
};

Expand Down
11 changes: 10 additions & 1 deletion frontend/src/services/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,16 @@ export function getUserBlacklist() {
}

export function searchForUsers(params) {
const { man, woman, ageFrom, ageTo, rateFrom, rateTo, radius, tags } = params;
const {
man,
woman,
to_age: ageFrom,
age_confirm: ageTo,
to_rate: rateFrom,
rate_confirm: rateTo,
radius,
tags,
} = params;
const userId = auth.getCurrentUser().id;
return http.get(
`${apiEndpoint}/search/${userId}?man=${man}&woman=${woman}&agefrom=${ageFrom}&ageto=${ageTo}${
Expand Down

0 comments on commit 07e3b84

Please sign in to comment.