last master commit
This commit is contained in:
@ -12,29 +12,27 @@ export const Axios = axios.create({
|
||||
export const updateDog = async ({email, name, phone}:
|
||||
{email: string, name: string, phone: string}) =>
|
||||
{
|
||||
const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
setWait(true);
|
||||
// const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
// setWait(true);
|
||||
try{
|
||||
const {data} = await Axios.post('updateDog.php',{
|
||||
email,
|
||||
name,
|
||||
phone
|
||||
});
|
||||
setWait(false);
|
||||
// setWait(false);
|
||||
return data;
|
||||
}
|
||||
catch(err){
|
||||
setWait(false);
|
||||
// setWait(false);
|
||||
return {success:0, message:'Server Error!'};
|
||||
}
|
||||
}
|
||||
|
||||
export const getDog = async ( str: string | undefined) =>
|
||||
export const getDog = async ( str: string | undefined) : Promise<ResponseT> =>
|
||||
{
|
||||
const { setWait, setDog } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
|
||||
var ret: ResponseT = {};
|
||||
setWait(true);
|
||||
// setWait(true);
|
||||
|
||||
try
|
||||
{
|
||||
@ -42,33 +40,43 @@ export const getDog = async ( str: string | undefined) =>
|
||||
{
|
||||
qr_id: str
|
||||
});
|
||||
setDog(ret.data as ResponseT);
|
||||
setWait(false);
|
||||
return;
|
||||
// setDog(ret.data as ResponseT);
|
||||
// setWait(false);
|
||||
return ret.data as ResponseT;
|
||||
}
|
||||
catch (error:any)
|
||||
{
|
||||
console.log('error message: ', error.message);
|
||||
setWait(false);
|
||||
return;
|
||||
// setWait(false);
|
||||
ret =
|
||||
{
|
||||
success: 0,
|
||||
status: 500,
|
||||
message: error.message,
|
||||
fields: null,
|
||||
data: null
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
export const registerUser = async ({email,password}:
|
||||
{email: string, password: string}) =>
|
||||
{
|
||||
const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
setWait(true);
|
||||
// const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
// setWait(true);
|
||||
try{
|
||||
const {data} = await Axios.post('register.php',{
|
||||
const {data} = await Axios.post('register.php',
|
||||
{
|
||||
email,
|
||||
password
|
||||
});
|
||||
setWait(false);
|
||||
// setWait(false);
|
||||
return data;
|
||||
}
|
||||
catch(err){
|
||||
setWait(false);
|
||||
catch(err)
|
||||
{
|
||||
// setWait(false);
|
||||
return {success:0, message:'Server Error!'};
|
||||
}
|
||||
}
|
||||
@ -76,30 +84,33 @@ export const registerUser = async ({email,password}:
|
||||
export const updateQR = async ({qr_width_cm, qr_height_cm, qr_fontsize, qr_visible_items, qr_item_sequence}:
|
||||
{qr_width_cm: number, qr_height_cm: number, qr_fontsize: number, qr_visible_items: number, qr_item_sequence: number}) =>
|
||||
{
|
||||
const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
// const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
|
||||
setWait(true);
|
||||
try{
|
||||
const {data} = await Axios.post('updateQR.php',{
|
||||
// setWait(true);
|
||||
try
|
||||
{
|
||||
const {data} = await Axios.post('updateQR.php',
|
||||
{
|
||||
qr_width_cm,
|
||||
qr_height_cm,
|
||||
qr_fontsize,
|
||||
qr_visible_items,
|
||||
qr_item_sequence
|
||||
});
|
||||
setWait(false);
|
||||
// setWait(false);
|
||||
return data;
|
||||
}
|
||||
catch(err){
|
||||
setWait(false);
|
||||
catch(err)
|
||||
{
|
||||
// setWait(false);
|
||||
return {success:0, message:'Server Error!'};
|
||||
}
|
||||
}
|
||||
|
||||
export const loginUser = async ({email,password}:{email: string, password: string}) =>
|
||||
{
|
||||
const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
setWait(true);
|
||||
// const { setWait } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
// setWait(true);
|
||||
try
|
||||
{
|
||||
var postReturn:
|
||||
@ -113,32 +124,32 @@ export const loginUser = async ({email,password}:{email: string, password: strin
|
||||
}
|
||||
= { data : {success: 0, message: '', data: null } };
|
||||
|
||||
postReturn = await Axios.post('login.php',{
|
||||
email,
|
||||
password
|
||||
});
|
||||
postReturn = await Axios.post('login.php',
|
||||
{
|
||||
email,
|
||||
password
|
||||
});
|
||||
|
||||
const {data} = postReturn;
|
||||
if(data.success && data.data)
|
||||
{
|
||||
setUser(data.data);
|
||||
setWait(false);
|
||||
// setUser(data.data);
|
||||
// setWait(false);
|
||||
return {success:1};
|
||||
}
|
||||
setWait(false);
|
||||
// setWait(false);
|
||||
return {success:0, message:data.message};
|
||||
}
|
||||
catch(err){
|
||||
setWait(false);
|
||||
catch(err)
|
||||
{
|
||||
// setWait(false);
|
||||
return {success:0, message:'Server Error!'};
|
||||
}
|
||||
}
|
||||
|
||||
export const logout = async () =>
|
||||
{
|
||||
const { setUser } = useContext<UserCtxT | null>(UserCtx) as UserCtxT;
|
||||
await Axios.get('logout.php');
|
||||
setUser(null);
|
||||
}
|
||||
// export const logout = async () =>
|
||||
// {
|
||||
// await Axios.get('logout.php');
|
||||
// }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user