Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add new qualification helpers #1578

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/cozy-client/src/models/document/qualification.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,20 @@ export const getIconByLabel = label => {
)
return ''
}

/**
* @param {string} label - The qualification label
* @returns {boolean}
*/
export const isSupportedQualification = label =>
qualificationModel.qualifications.some(qualif => qualif.label === label)

/**
* @param {object} document - The document
* @returns {boolean}
*/
export const hasSupportedQualification = document => {
const label = document?.metadata?.qualification?.label

return isSupportedQualification(label)
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export namespace Qualification {
export function setQualification(document: object, qualification: Qualification): object;
export function getQualification(document: object): Qualification | null;
export function getIconByLabel(label: string): import('../../types').IconQualificationLabels | string;
export function isSupportedQualification(label: string): boolean;
export function hasSupportedQualification(document: object): boolean;
export type QualificationAttributes = {
/**
* - The qualification icon.
Expand Down
Loading