refactor: added data sharing configs to confighandler

This commit is contained in:
Joel Jacob Stephen
2024-02-19 19:19:02 +05:30
parent 70c4ef5699
commit 5095c2b76f

View File

@@ -54,6 +54,11 @@ export type Config = {
mailer_from_address: string;
};
};
dataSharingConfigs: {
name: string;
enabled: boolean;
};
};
type UpdatedConfigs = {
@@ -86,6 +91,7 @@ export function useConfigHandler(updatedConfigs?: Config) {
'GITHUB_CLIENT_SECRET',
'MAILER_SMTP_URL',
'MAILER_ADDRESS_FROM',
'ALLOW_ANALYTICS_COLLECTION',
] as InfraConfigEnum[],
},
(x) => x.infraConfigs
@@ -164,6 +170,15 @@ export function useConfigHandler(updatedConfigs?: Config) {
?.value ?? '',
},
},
dataSharingConfigs: {
name: 'data_sharing',
enabled:
infraConfigs.value.find(
(x) => x.name === 'ALLOW_ANALYTICS_COLLECTION'
)?.value === 'true'
? true
: false,
},
};
// Cloning the current configs to working configs
@@ -254,6 +269,17 @@ export function useConfigHandler(updatedConfigs?: Config) {
);
}
if (updatedConfigs?.dataSharingConfigs.enabled) {
config.push({
name: 'ALLOW_ANALYTICS_COLLECTION',
value: updatedConfigs?.dataSharingConfigs.enabled ? 'true' : 'false',
});
} else {
config = config.filter(
(item) => item.name !== 'ALLOW_ANALYTICS_COLLECTION'
);
}
config = config.filter((item) => item.name !== '');
return config;