employee view
parent
1dac4d4dbd
commit
170f9085a6
|
@ -227,6 +227,13 @@ export async function GetUser(req: Request, res: Response) {
|
||||||
attributes: ["store_id", "name"],
|
attributes: ["store_id", "name"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let respData = {
|
||||||
|
user: user,
|
||||||
|
stores: stores,
|
||||||
|
// only temporary until we have a proper permissions system
|
||||||
|
permissions: [] as string[],
|
||||||
|
};
|
||||||
|
|
||||||
// if user is not a store master, then check if user is a worker
|
// if user is not a store master, then check if user is a worker
|
||||||
if (!stores || stores.length === 0) {
|
if (!stores || stores.length === 0) {
|
||||||
const store = await Store.findOne({
|
const store = await Store.findOne({
|
||||||
|
@ -241,9 +248,20 @@ export async function GetUser(req: Request, res: Response) {
|
||||||
}
|
}
|
||||||
|
|
||||||
stores.push(store);
|
stores.push(store);
|
||||||
|
|
||||||
|
respData.stores = stores;
|
||||||
|
|
||||||
|
respData.permissions.push("calendar");
|
||||||
|
} else {
|
||||||
|
respData.permissions.push(
|
||||||
|
"settings",
|
||||||
|
"employees",
|
||||||
|
"services",
|
||||||
|
"calendar"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).send({ user, stores });
|
res.status(200).send(respData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
res.status(500).send({ err: "invalid request" });
|
res.status(500).send({ err: "invalid request" });
|
||||||
|
|
Loading…
Reference in New Issue