Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
Restyled by prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Jul 23, 2021
1 parent 6662e1b commit 8ff8b09
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 110 deletions.
23 changes: 5 additions & 18 deletions src/pages/private/user/messages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ class PeopleCards extends Component {
filterPeople = (e) => {
const people = this.state.persons.filter(
(person) =>
person.name
.toLowerCase()
.search(e.target.value.trim().toLowerCase()) !== -1,
person.name.toLowerCase().search(e.target.value.trim().toLowerCase()) !== -1,
);
this.setState({ people, NoSearchResults: !people.length });
};
Expand All @@ -74,10 +72,7 @@ class PeopleCards extends Component {
return this.setState({
people: persons.filter((e) => {
if (sectionSelect !== 'ALL') {
return (
e.department === input.value &&
e.section === sectionSelect
);
return e.department === input.value && e.section === sectionSelect;
}
return e.department === input.value;
}),
Expand All @@ -101,10 +96,7 @@ class PeopleCards extends Component {
return this.setState({
people: persons.filter((e) => {
if (departmentSelect !== 'ALL') {
return (
e.section === input.value &&
e.department === departmentSelect
);
return e.section === input.value && e.department === departmentSelect;
}
return e.section === input.value;
}),
Expand All @@ -113,13 +105,8 @@ class PeopleCards extends Component {
};

render() {
const {
ProgressBar,
departments,
sections,
people,
NoSearchResults,
} = this.state;
const { ProgressBar, departments, sections, people, NoSearchResults } =
this.state;

return (
<>
Expand Down
12 changes: 9 additions & 3 deletions src/pages/private/user/messages/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ import { apiUrl, endPoints } from '../../../../config.json';
import http from '../../../../services/httpService';
import { NotifyAlert, TimerAlert } from '../../../../components';

const ModalBox = ({ personId, personName, toggleOpen, triggerModal, modalValue }) => {
const ModalBox = ({
personId,
personName,
toggleOpen,
triggerModal,
modalValue,
}) => {
const [ModalValue, setModalValue] = useState(() => modalValue);

useEffect(() => {
setModalValue(modalValue)
}, [modalValue])
setModalValue(modalValue);
}, [modalValue]);

const handleSubmit = () => {
const messageObject = {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/private/user/messages/single.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const UserCard = ({ person, personName, personBio, personImageUrl }) => {
};

const triggerModal = () => {
getUserMessage()
getUserMessage();
setModalOpen(!modalOpen);
};

Expand Down
5 changes: 1 addition & 4 deletions src/pages/private/user/profile/messages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ const Message = ({ person, message, index }) => {
<>
<div className={getClass()}>
<div className="card-body text-dark">
<h5
className="card-title h5-responsive mb-2"
style={{ fontWeight: 500 }}
>
<h5 className="card-title h5-responsive mb-2" style={{ fontWeight: 500 }}>
{person}
</h5>
<p className="p-responsive" style={{ fontFamily: 'Product Sans' }}>
Expand Down
16 changes: 3 additions & 13 deletions src/pages/private/user/profile/profileCard/socialCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ const PersonalCard = () => {
snapchat: '',
});

const {
email,
phone,
instagram,
linkedin,
facebook,
snapchat,
} = socialHandles;
const { email, phone, instagram, linkedin, facebook, snapchat } = socialHandles;

useEffect(() => {
const fetchUserData = async () => {
Expand All @@ -44,7 +37,7 @@ const PersonalCard = () => {
linkedin: data.socialHandles.linkedin,
snapchat: data.socialHandles.snapchat,
});
console.log('socialss', data)
console.log('socialss', data);
} catch (ex) {
if (ex.response && ex.response.status === 400) {
TimerAlert('Error', ex.response.data, 'error');
Expand Down Expand Up @@ -90,10 +83,7 @@ const PersonalCard = () => {
<Tooltip title="You can add more details from update details section">
<div className="row">
{email && (
<SocialHandle
platform={email}
iconClass="fas fa-lg fa-envelope"
/>
<SocialHandle platform={email} iconClass="fas fa-lg fa-envelope" />
)}
{phone && (
<SocialHandle
Expand Down
9 changes: 5 additions & 4 deletions src/services/httpService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import logger from './logService';
// import { TimerAlert } from '../components';

axios.interceptors.response.use(null, (error) => {
const expectedErrors = error.response && error.response.status >= 400 &&
error.response.status < 500;
const expectedErrors =
error.response && error.response.status >= 400 && error.response.status < 500;
if (!expectedErrors) {
logger.log(error);
// TimerAlert('Error', ' An unexpected error occurred', 'error');
}
return Promise.reject(error);
});

const setJwt =
(jwt) => { axios.defaults.headers.common['x-auth-token'] = jwt; };
const setJwt = (jwt) => {
axios.defaults.headers.common['x-auth-token'] = jwt;
};

export default {
get: axios.get,
Expand Down
143 changes: 76 additions & 67 deletions src/utils/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,88 +2,97 @@ import Joi from 'joi-browser';

const LoginSchema = () => {
return {
userId : Joi.number()
.error(() => {
return {
message : 'Please enter a valid enrollment number',
};
})
.required(),
password : Joi.string()
.error(() => {
return {
message : 'Password cannot be empty',
};
})
.required(),
userId: Joi.number()
.error(() => {
return {
message: 'Please enter a valid enrollment number',
};
})
.required(),
password: Joi.string()
.error(() => {
return {
message: 'Password cannot be empty',
};
})
.required(),
};
};

const SignUpSchema = () => {
return {
name : Joi.string().min(5).label('Name').required(),
password : Joi.string()
.min(7)
.error(() => {
return {
message :
'Password should be at least 7 characters long',
};
})
.required(),
department : Joi.string().min(2).max(3).required(),
section : Joi.string().length(1).required(),
name: Joi.string().min(5).label('Name').required(),
password: Joi.string()
.min(7)
.error(() => {
return {
message: 'Password should be at least 7 characters long',
};
})
.required(),
department: Joi.string().min(2).max(3).required(),
section: Joi.string().length(1).required(),
};
};

const DetailsSchema = () => {
return {
contactEmail :
Joi.string().email().allow('').trim().strict().label('Contact Email'),
facebook : Joi.string().uri().label('Facebook').error(() => {
return {
message : 'Please enter a valid Facebook profile URL',
};
}),
linkedin : Joi.string().uri().label('Linkedin').error(() => {
return {
message : 'Please enter a valid LinkedIn profile URL',
};
}),
whatsappNo : Joi.string()
.length(10)
.regex(/^\d+$/)
.label('WhatsApp Number')
.error(() => {
return {
message : 'Input should be a number of length 10',
};
}),
contactNo : Joi.string()
.label('Contact Number')
.length(10)
.regex(/^\d+$/)
.error(() => {
return {
message : 'Input should be a number of length 10',
};
}),
snapchat : Joi.string().label('Snapchat'),
instagram : Joi.string().label('Instagram'),
contactEmail: Joi.string()
.email()
.allow('')
.trim()
.strict()
.label('Contact Email'),
facebook: Joi.string()
.uri()
.label('Facebook')
.error(() => {
return {
message: 'Please enter a valid Facebook profile URL',
};
}),
linkedin: Joi.string()
.uri()
.label('Linkedin')
.error(() => {
return {
message: 'Please enter a valid LinkedIn profile URL',
};
}),
whatsappNo: Joi.string()
.length(10)
.regex(/^\d+$/)
.label('WhatsApp Number')
.error(() => {
return {
message: 'Input should be a number of length 10',
};
}),
contactNo: Joi.string()
.label('Contact Number')
.length(10)
.regex(/^\d+$/)
.error(() => {
return {
message: 'Input should be a number of length 10',
};
}),
snapchat: Joi.string().label('Snapchat'),
instagram: Joi.string().label('Instagram'),
};
};

const EmailAccess = () => {
return {
email : Joi.string()
.email()
.error(() => {
return {
message : 'Please enter a valid Email',
};
})
.required(),
email: Joi.string()
.email()
.error(() => {
return {
message: 'Please enter a valid Email',
};
})
.required(),
};
};

export {LoginSchema, SignUpSchema, DetailsSchema, EmailAccess};
export { LoginSchema, SignUpSchema, DetailsSchema, EmailAccess };

0 comments on commit 8ff8b09

Please sign in to comment.