|
|
@@ -10,7 +10,8 @@ const api = axios.create({
|
|
|
|
|
|
api.interceptors.request.use(
|
|
|
async (config) => {
|
|
|
- const accessToken = userStore().accessToken;
|
|
|
+ const store = userStore();
|
|
|
+ const accessToken = store.accessToken;
|
|
|
const savedLanguage = Cookies.get("locale");
|
|
|
const language = savedLanguage || window.navigator.language;
|
|
|
config.headers["Accept-Language"] = language;
|
|
|
@@ -18,6 +19,11 @@ api.interceptors.request.use(
|
|
|
if (accessToken) {
|
|
|
config.headers.Authorization = `Bearer ${accessToken}`;
|
|
|
}
|
|
|
+ // Envia a unidade ativa para o backend filtrar os dados corretamente
|
|
|
+ const activeUnitId = store.selectedUnit?.id;
|
|
|
+ if (activeUnitId) {
|
|
|
+ config.headers["X-Unit-Id"] = activeUnitId;
|
|
|
+ }
|
|
|
return config;
|
|
|
},
|
|
|
(error) => {
|