B2B-51: add medreport product tables, relations and constraints (#19)

* B2B-51: add medreport product tables, relations and constraints

* change table names

* sync data based on env

---------

Co-authored-by: Helena <helena@Helenas-MacBook-Pro.local>
This commit is contained in:
Helena
2025-06-19 16:40:22 +03:00
committed by GitHub
parent 538a17031a
commit ea540a4aeb
2 changed files with 246 additions and 10 deletions

View File

@@ -8,6 +8,8 @@ async function syncData() {
config({ path: `.env.${process.env.NODE_ENV}` });
}
const isProd = process.env.NODE_ENV === 'production';
const baseUrl = process.env.CONNECTED_ONLINE_URL;
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseServiceRoleKey =
@@ -26,15 +28,12 @@ async function syncData() {
});
try {
const response = await axios.post(
`${baseUrl}/Search_Load`,
{
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
param: "{'Value':'|et|-1'}", // get all available services in Estonian
const response = await axios.post(`${baseUrl}/Search_Load`, {
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
);
param: "{'Value':'|et|-1'}", // get all available services in Estonian
});
const responseData: {
Value: any;
@@ -59,8 +58,20 @@ async function syncData() {
});
}
const clinics = responseData.Data.T_Lic;
const services = responseData.Data.T_Service;
let clinics;
let services;
// Filter out "Dentas Demo OÜ" in prod or only sync "Dentas Demo OÜ" in any other environment
if (isProd) {
clinics = responseData.Data.T_Lic.filter((clinic) => clinic.ID !== 2);
services = responseData.Data.T_Service.filter(
(service) => service.ClinicID !== 2,
);
} else {
clinics = responseData.Data.T_Lic.filter((clinic) => clinic.ID === 2);
services = responseData.Data.T_Service.filter(
(service) => service.ClinicID === 2,
);
}
const mappedClinics = clinics.map((clinic) => {
return {