Skip to content

Commit

Permalink
feat(Project): Added default license info header in add project page
Browse files Browse the repository at this point in the history
  • Loading branch information
amritkv authored and heliocastro committed Dec 19, 2024
1 parent e9678e5 commit 430e8c7
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 8 deletions.
3 changes: 2 additions & 1 deletion messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
"Session has expired": "Sitzung ist abgelaufen",
"Set Outdated": "Hergestellt",
"Set To Outdated": "Auf den Wunschzettel",
"Set to default text": "Standardtext festlegen",
"Set to default text": "Auf Standardtext einstellen",
"Short Name": "Kurzbezeichnung",
"Short Status": "Kurzstatus",
"Shortname": "",
Expand Down Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "Überprüfung <strong>{number}</strong> Sicherheitslücken werden geändert",
"There are internal server error": "Es liegen interne Serverfehler vor",
"There are some errors while creating project": "Es gibt einige Fehler bei der Erstellung von Projekten",
"There are some errors while fetching default license info header": "Beim Abrufen des Standard-Lizenzinformationsheaders sind einige Fehler aufgetreten",
"There are some errors while updating moderation request": "Beim Aktualisieren der Moderationsanfrage sind einige Fehler aufgetreten",
"There are some errors while updating project": "Beim Aktualisieren des Projekts sind einige Fehler aufgetreten",
"There are some problem to update your comments": "Es gibt ein Problem beim Aktualisieren Ihrer Kommentare!",
Expand Down
3 changes: 2 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
"Session has expired": "Session has expired",
"Set Outdated": "Set Outdated",
"Set To Outdated": "Set To Outdated",
"Set to default text": "Set to default text",
"Set to default text": "Set to Default Text",
"Short Name": "Short Name",
"Short Status": "Short Status",
"Shortname": "Shortname",
Expand Down Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "The verification of <strong>{number}</strong> vulnerabilities will be changed to",
"There are internal server error": "There are internal server error",
"There are some errors while creating project": "There are some errors while creating project",
"There are some errors while fetching default license info header": "There are some errors while fetching default license info header",
"There are some errors while updating moderation request": "There are some errors while updating moderation request",
"There are some errors while updating project": "There are some errors while updating project",
"There are some problem to update your comments": "There are some problem to update your comments !",
Expand Down
1 change: 1 addition & 0 deletions messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "La verificación de <strong>{número}</strong> vulnerabilidades se cambiarán",
"There are internal server error": "Hay un error interno del servidor.",
"There are some errors while creating project": "Hay algunos errores al crear proyecto",
"There are some errors while fetching default license info header": "Hay algunos errores al recuperar el encabezado de información de licencia predeterminado",
"There are some errors while updating moderation request": "Hay algunos errores al actualizar la solicitud de moderación.",
"There are some errors while updating project": "Hay algunos errores al actualizar el proyecto.",
"There are some problem to update your comments": "¡Hay algún problema para actualizar tus comentarios!",
Expand Down
1 change: 1 addition & 0 deletions messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "La vérification <strong>{numéro}</strong> les vulnérabilités seront changées en",
"There are internal server error": "Il y a une erreur de serveur interne",
"There are some errors while creating project": "Il y a quelques erreurs lors de la création du projet",
"There are some errors while fetching default license info header": "Il y a des erreurs lors de la récupération de l'en-tête des informations de licence par défaut",
"There are some errors while updating moderation request": "Il y a des erreurs lors de la mise à jour de la demande de modération",
"There are some errors while updating project": "Il y a des erreurs lors de la mise à jour du projet",
"There are some problem to update your comments": "Il y a un problème pour mettre à jour vos commentaires !",
Expand Down
3 changes: 2 additions & 1 deletion messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
"Session has expired": "セッションの有効期限が切れました",
"Set Outdated": "セット古い",
"Set To Outdated": "古いものに設定",
"Set to default text": "デフォルトのテキストに設定する",
"Set to default text": "デフォルトのテキストに設定",
"Short Name": "短縮名",
"Short Status": "ショートステータス",
"Shortname": "",
Expand Down Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "<strong>{number}</strong> 件の脆弱性の検証を変更",
"There are internal server error": "内部サーバーエラーが発生しています",
"There are some errors while creating project": "プロジェクトの作成中にいくつかのエラーが発生しました",
"There are some errors while fetching default license info header": "デフォルトのライセンス情報ヘッダーを取得中にいくつかのエラーが発生しました",
"There are some errors while updating moderation request": "モデレートリクエストの更新中にエラーが発生しました",
"There are some errors while updating project": "プロジェクトの更新中にいくつかのエラーが発生しました",
"There are some problem to update your comments": "コメントを更新するには問題があります。",
Expand Down
3 changes: 2 additions & 1 deletion messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
"Session has expired": "세션이 만료되었습니다.",
"Set Outdated": "설치하기",
"Set To Outdated": "설치하기",
"Set to default text": "기본 텍스트 설정",
"Set to default text": "기본 텍스트로 설정",
"Short Name": "이름 *",
"Short Status": "단기 상태",
"Shortname": "",
Expand Down Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "인증현황 <strong>이름 *</strong> 취약점이 변경됩니다.",
"There are internal server error": "내부서버 오류가 있습니다",
"There are some errors while creating project": "프로젝트를 만드는 동안 몇 가지 오류가 있습니다.",
"There are some errors while fetching default license info header": "기본 라이선스 정보 헤더를 가져오는 중에 오류가 발생했습니다.",
"There are some errors while updating moderation request": "검토 요청을 업데이트하는 중에 오류가 발생했습니다.",
"There are some errors while updating project": "프로젝트를 업데이트하는 중 오류가 발생했습니다.",
"There are some problem to update your comments": "귀하의 의견을 업데이트하는 데 문제가 있습니다!",
Expand Down
3 changes: 2 additions & 1 deletion messages/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
"Session has expired": "A sessão expirou",
"Set Outdated": "Definir desatualizado",
"Set To Outdated": "Definir como desatualizado",
"Set to default text": "Restaurar Definições",
"Set to default text": "Definir como texto padrão",
"Short Name": "Nome Curto",
"Short Status": "Status curto",
"Shortname": "",
Expand Down Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "A verificação de <strong>{number}</strong> vulnerabilidades será alterada para",
"There are internal server error": "Há erros internos do servidor",
"There are some errors while creating project": "Ocorreram alguns erros ao criar o projeto",
"There are some errors while fetching default license info header": "Existem alguns erros ao buscar o cabeçalho de informações de licença padrão",
"There are some errors while updating moderation request": "Ocorreram alguns erros ao atualizar a solicitação de moderação",
"There are some errors while updating project": "Existem alguns erros ao atualizar o projeto",
"There are some problem to update your comments": "Há algum problema para atualizar seus comentários!",
Expand Down
1 change: 1 addition & 0 deletions messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "Việc xác minh lỗ hổng <strong>{number}</strong> sẽ được thay đổi thành",
"There are internal server error": "Có lỗi máy chủ nội bộ",
"There are some errors while creating project": "Có một số lỗi khi tạo dự án",
"There are some errors while fetching default license info header": "Có một số lỗi khi tìm nạp tiêu đề thông tin giấy phép mặc định",
"There are some errors while updating moderation request": "Có một số lỗi trong khi cập nhật yêu cầu kiểm duyệt",
"There are some errors while updating project": "Có một số lỗi trong khi cập nhật dự án",
"There are some problem to update your comments": "Có một số vấn đề khi cập nhật nhận xét của bạn!",
Expand Down
1 change: 1 addition & 0 deletions messages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "<strong>{number}</strong> 个漏洞的验证将更改为",
"There are internal server error": "服务器内部出现错误",
"There are some errors while creating project": "创建项目时出现一些错误",
"There are some errors while fetching default license info header": "获取默认许可证信息标头时出现一些错误",
"There are some errors while updating moderation request": "更新审核请求时出现一些错误",
"There are some errors while updating project": "更新项目时出现一些错误",
"There are some problem to update your comments": "更新评论有问题!",
Expand Down
3 changes: 2 additions & 1 deletion messages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
"Session has expired": "會話已過期",
"Set Outdated": "設定已过期",
"Set To Outdated": "設定為已过期",
"Set to default text": "設定為預設文字",
"Set to default text": "設定為預設文本",
"Short Name": "短名",
"Short Status": "空頭狀態",
"Shortname": "",
Expand Down Expand Up @@ -1046,6 +1046,7 @@
"The verification of vulnerabilities will be changed to": "核查 <strong>{數字}</strong> 弱點將變為",
"There are internal server error": "伺服器內部出現錯誤",
"There are some errors while creating project": "建立專案時有一些錯誤",
"There are some errors while fetching default license info header": "取得預設許可證資訊標頭時出現一些錯誤",
"There are some errors while updating moderation request": "更新審核請求時出現一些錯誤",
"There are some errors while updating project": "更新項目時出現一些錯誤",
"There are some problem to update your comments": "更新評論有問題!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@

import { useTranslations } from 'next-intl'

import { ProjectPayload } from '@/object-types'
import { HttpStatus, ProjectPayload } from '@/object-types'
import { getSession, signOut } from 'next-auth/react'
import CommonUtils from '@/utils/common.utils'
import { ApiUtils } from '@/utils/index'
import MessageService from '@/services/message.service'

interface Props {
projectPayload: ProjectPayload
setProjectPayload: React.Dispatch<React.SetStateAction<ProjectPayload>>
}

interface LicenseInfoHeader {
licenseInfoHeaderText: string
}

export default function LicenseInfoHeader({ projectPayload, setProjectPayload }: Props): JSX.Element {
const t = useTranslations('default')
const updateInputField = (event: React.ChangeEvent<HTMLSelectElement |
Expand All @@ -29,13 +37,37 @@ export default function LicenseInfoHeader({ projectPayload, setProjectPayload }:
})
}

const getDefaultLicenseInfoHeader = async () => {
try {
const session = await getSession()
if(CommonUtils.isNullOrUndefined(session))
return signOut()
const url = 'projects/licenseInfoHeader'
const response = await ApiUtils.GET(url, session.user.access_token)
if (response.status == HttpStatus.OK) {
const data = await response.json() as LicenseInfoHeader
setProjectPayload({
...projectPayload,
licenseInfoHeaderText: data.licenseInfoHeaderText
})
} else {
MessageService.error(t('There are some errors while fetching default license info header'))
}
} catch(e) {
console.error(e)
}
}

return (
<>
<div className='row mb-4'>
<h6 className='header pb-2 px-2'>{t('License Info Header')}</h6>
<div className='row d-flex justify-content-end'>
<div className='col-lg-3'>
<button type='button' className='btn btn-light'>
<button className='btn btn-light mb-2'
type='button'
onClick={getDefaultLicenseInfoHeader}
>
{t('Set to default text')}
</button>
</div>
Expand Down

0 comments on commit 430e8c7

Please sign in to comment.