mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 04:41:32 +02:00
* open visual code if user havent used latex before * test tooltip on code editor switch * firstTimeLoadedEditor * track editor.codeEditorOpened value * lastEditorLoadedDate * odc data loaded from mongo * fix a typo * use tutorial to check if it was dissmised * use getInactiveTutorials fn * fix test * check if code editor was opened * added translations * pass classname to tooltip * use signUpDate instead of lastEditorLoadedDate * refactor visual fallback value * use tutorial completed data only for tooltip * set lastUsedMode in odc form * safer usedLatex check * getOnboardingDataValue helper function * move tooltip to a separate component * move classname to tooltipProps * usedLatex in meta tag * codeEdtiorOpened fallback value * fix release date year * fix 24 hours criteria for showing the tooltip * fix tests * hide tooltip when code editor is opened * remove setting lastUsedMode in ODC form * remove empty comment * change date for checking signUpDate * fix linting error GitOrigin-RevId: 0a57ba3f4717492d4546633571117f667d3a05f8
78 lines
1.7 KiB
JavaScript
78 lines
1.7 KiB
JavaScript
const {
|
|
OnboardingDataCollection,
|
|
OnboardingDataCollectionSchema,
|
|
} = require('../../models/OnboardingDataCollection')
|
|
const OError = require('@overleaf/o-error')
|
|
|
|
async function getOnboardingDataCollection(userId, projection = {}) {
|
|
try {
|
|
return await OnboardingDataCollection.findOne(
|
|
{ _id: userId },
|
|
projection
|
|
).exec()
|
|
} catch (error) {
|
|
throw OError.tag(error, 'Failed to get OnboardingDataCollection')
|
|
}
|
|
}
|
|
|
|
async function getOnboardingDataValue(userId, key) {
|
|
if (!OnboardingDataCollectionSchema.paths[key]) {
|
|
throw new Error(`${key} is not a valid onboarding data key`)
|
|
}
|
|
|
|
const result = await getOnboardingDataCollection(userId, { [key]: 1 })
|
|
return result ? result[key] : null
|
|
}
|
|
|
|
async function upsertOnboardingDataCollection({
|
|
userId,
|
|
firstName,
|
|
lastName,
|
|
usedLatex,
|
|
primaryOccupation,
|
|
companyDivisionDepartment,
|
|
companyJobTitle,
|
|
governmentJobTitle,
|
|
institutionName,
|
|
otherJobTitle,
|
|
nonprofitDivisionDepartment,
|
|
nonprofitJobTitle,
|
|
role,
|
|
subjectArea,
|
|
updatedAt,
|
|
}) {
|
|
const odc = await OnboardingDataCollection.findOneAndUpdate(
|
|
{ _id: userId },
|
|
{
|
|
firstName,
|
|
lastName,
|
|
usedLatex,
|
|
primaryOccupation,
|
|
companyDivisionDepartment,
|
|
companyJobTitle,
|
|
governmentJobTitle,
|
|
institutionName,
|
|
otherJobTitle,
|
|
nonprofitDivisionDepartment,
|
|
nonprofitJobTitle,
|
|
role,
|
|
subjectArea,
|
|
updatedAt,
|
|
},
|
|
{ upsert: true }
|
|
)
|
|
|
|
return odc
|
|
}
|
|
|
|
function deleteOnboardingDataCollection(id) {
|
|
return OnboardingDataCollection.deleteOne({ _id: id })
|
|
}
|
|
|
|
module.exports = {
|
|
getOnboardingDataCollection,
|
|
upsertOnboardingDataCollection,
|
|
deleteOnboardingDataCollection,
|
|
getOnboardingDataValue,
|
|
}
|