-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77a1af2
commit 05ddc16
Showing
17 changed files
with
236 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import type { UpsertSystemSettingsBody } from '@cpn-console/shared' | ||
import type { SystemSettings, UpsertSystemSettingsBody } from '@cpn-console/shared' | ||
import { upsertSystemSetting as upsertSystemSettingQuery } from './queries.js' | ||
|
||
import { config } from '@/utils/config.js' | ||
import { getConfig } from '@/utils/config.js' | ||
|
||
export function getSystemSettings(key?: keyof typeof config) { | ||
export async function getSystemSettings(key?: keyof SystemSettings) { | ||
const config = await getConfig() | ||
if (key) { | ||
return { [key]: config[key] } | ||
} else { | ||
return config | ||
} | ||
} | ||
|
||
export const upsertSystemSettings = (newSystemSetting: UpsertSystemSettingsBody) => upsertSystemSettingQuery(newSystemSetting) | ||
export async function upsertSystemSettings(newSystemSettings: UpsertSystemSettingsBody) { | ||
if (!newSystemSettings) return getSystemSettings() | ||
for (const [key, value] of Object.entries(newSystemSettings)) { | ||
await upsertSystemSettingQuery({ key, value }) | ||
} | ||
return getSystemSettings() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.