Skip to content

Commit

Permalink
fix type error
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Jul 11, 2024
1 parent 63b052c commit 1afd4b5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/crowdin/common/apiFns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@ export const createCommonFns = (client: CrowdinApi) => {
return response
}
const addSingleKey: AddSingleKey = async ({ isDatabaseString, key, text, ...params }) => {
const branchId = isDatabaseString ? branches.database : undefined
const fileId = isDatabaseString ? undefined : fileIds.main[params.ns ?? 'common']
const identifier = key

const requestArgs: typeof isDatabaseString extends true
? SourceStringsModel.CreateStringStringsBasedRequest
: SourceStringsModel.CreateStringRequest = {
...(branchId && { branchId }),
...(fileId && { fileId }),
identifier,
text,
}
const requestArgs:
| SourceStringsModel.CreateStringStringsBasedRequest
| SourceStringsModel.CreateStringRequest = isDatabaseString
? ({
branchId: branches.database,
identifier,
text,
} satisfies SourceStringsModel.CreateStringStringsBasedRequest)
: ({
fileId: fileIds.main[params.ns ?? 'common'],
identifier,
text,
} satisfies SourceStringsModel.CreateStringRequest)

const { data: response } = await client.sourceStringsApi.addString(
getProjectId(isDatabaseString),
Expand Down

0 comments on commit 1afd4b5

Please sign in to comment.