Implemented Add Employer #27
@@ -4,16 +4,16 @@ export type User = {
|
|||||||
name?: string
|
name?: string
|
||||||
avatar?: string
|
avatar?: string
|
||||||
// email?: string
|
// email?: string
|
||||||
position?: string
|
// position?: string
|
||||||
role?: string
|
// role?: string
|
||||||
last_login?: string
|
// last_login?: string
|
||||||
two_steps?: boolean
|
// two_steps?: boolean
|
||||||
joined_day?: string
|
// joined_day?: string
|
||||||
online?: boolean
|
// online?: boolean
|
||||||
initials?: {
|
// initials?: {
|
||||||
label: string
|
// label: string
|
||||||
state: string
|
// state: string
|
||||||
}
|
// }
|
||||||
uid?: string
|
uid?: string
|
||||||
percent_interest?: string
|
percent_interest?: string
|
||||||
max_loan?: string
|
max_loan?: string
|
||||||
@@ -31,8 +31,8 @@ export type UsersQueryResponse = Response<Array<User>>
|
|||||||
|
|
||||||
export const initialUser: User = {
|
export const initialUser: User = {
|
||||||
avatar: 'avatars/300-6.jpg',
|
avatar: 'avatars/300-6.jpg',
|
||||||
position: 'Art Director',
|
// position: 'Art Director',
|
||||||
role: 'Administrator',
|
// role: 'Administrator',
|
||||||
name: '',
|
name: '',
|
||||||
email: '',
|
email: '',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,18 +19,31 @@ const getEmployersList = (query: string): Promise<UsersQueryResponse> => { // FU
|
|||||||
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
|
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// const createUser = (user: User): Promise<User | undefined> => { // FUNCTION TO ADD/CREATE NEW USER
|
// const createUser = (user: any): Promise<User | undefined> => { // FUNCTION TO ADD/CREATE NEW USER
|
||||||
|
// const formData = new FormData();
|
||||||
|
// delete user.email
|
||||||
|
// delete user.role
|
||||||
|
// delete user.position
|
||||||
|
// delete user.avatar
|
||||||
|
// delete user.id
|
||||||
|
// for (let data in user) {
|
||||||
|
// formData.append(data, user[data]);
|
||||||
|
// }
|
||||||
// return axios
|
// return axios
|
||||||
// .post(`${NEW_USER_ENDPOINT}/employers`, user)
|
// .post(`${NEW_USER_ENDPOINT}/employer`, formData)
|
||||||
// .then((response: AxiosResponse<Response<User>>) => response.data)
|
// .then((response: AxiosResponse<Response<User>>) => response.data)
|
||||||
// .then((response: Response<User>) => response.data);
|
// .then((response: Response<User>) => response.data);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
const createUser = (user: User): Promise<UsersQueryResponse | undefined> => { // FUNCTION TO ADD/CREATE NEW USER
|
const createUser = (user: any): Promise<UsersQueryResponse | undefined> => { // FUNCTION TO ADD/CREATE NEW USER
|
||||||
return axios
|
const formData = new FormData();
|
||||||
.post(`${NEW_USER_ENDPOINT}/employers`, user)
|
delete user.avatar
|
||||||
|
delete user.id
|
||||||
|
for (let data in user) {
|
||||||
|
formData.append(data, user[data]);
|
||||||
|
}
|
||||||
|
return axios.post(`${NEW_USER_ENDPOINT}/employer`, formData)
|
||||||
.then((response: AxiosResponse<UsersQueryResponse>) => response.data)
|
.then((response: AxiosResponse<UsersQueryResponse>) => response.data)
|
||||||
// .then((response: Response<User>) => response.data);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUserById = (id: ID): Promise<User | undefined> => {
|
const getUserById = (id: ID): Promise<User | undefined> => {
|
||||||
|
|||||||
+3
-3
@@ -61,10 +61,10 @@ const UserEditModalForm: FC<Props> = ({ user, isUserLoading }) => {
|
|||||||
const [userForEdit] = useState<User>({
|
const [userForEdit] = useState<User>({
|
||||||
...user,
|
...user,
|
||||||
avatar: user.avatar || initialUser.avatar,
|
avatar: user.avatar || initialUser.avatar,
|
||||||
role: user.role || initialUser.role,
|
// role: user.role || initialUser.role,
|
||||||
position: user.position || initialUser.position,
|
// position: user.position || initialUser.position,
|
||||||
name: user.name || initialUser.name,
|
name: user.name || initialUser.name,
|
||||||
email: user.email || initialUser.email,
|
// email: user.email || initialUser.email,
|
||||||
});
|
});
|
||||||
|
|
||||||
const cancel = (withRefresh?: boolean) => {
|
const cancel = (withRefresh?: boolean) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user