-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/components: refactor register challenge team step into FormSelect…
…Team component (#748) * refactor register challenge team step into a separate component * src/components/form: fix FormFieldSelectTable component modelValue prop default null val Fix FormSelectTeam component Vue.js web browser console warning message: ``` [Vue warn]: Invalid prop: type check failed for prop "modelValue". Expected Number with value 0, got Null at <FormFieldSelectTable modelValue=null onUpdate:modelValue=fn organization-level="team" ... > at <FormSelectTeam ref="VTU_COMPONENT" > at <VTUROOT> ``` * src/components/form: fix replacing i18n deprecated trans func name Web browser Vue.js FormFieldSelectTable component warning message: ``` [intlify] 'tc' and '$tc' has been deprecated in v10. Use 't' or '$t' instead. 'tc' and '$tc’ are going to remove in v11. ``` --------- Co-authored-by: Šimon Macek <simon.macek@proficio.cz> Co-authored-by: Tomas Zigo <tomas.zigo@slovanet.sk>
- Loading branch information
1 parent
379b7a9
commit eea64db
Showing
7 changed files
with
138 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import FormSelectTeam from 'components/form/FormSelectTeam.vue'; | ||
import { i18n } from '../../boot/i18n'; | ||
|
||
// selectors | ||
const selectorFormSelectTeam = 'form-select-team'; | ||
const selectorFormSelectTableTeam = 'form-select-table-team'; | ||
const selectorFormSelectTeamInfo = 'form-select-team-info'; | ||
describe('<FormSelectTeam>', () => { | ||
it('has translation for all strings', () => { | ||
cy.testLanguageStringsInContext( | ||
['textTeamInfo'], | ||
'register.challenge', | ||
i18n, | ||
); | ||
}); | ||
|
||
context('desktop', () => { | ||
beforeEach(() => { | ||
cy.mount(FormSelectTeam, { | ||
props: {}, | ||
}); | ||
cy.viewport('macbook-16'); | ||
}); | ||
|
||
coreTests(); | ||
}); | ||
|
||
context('mobile', () => { | ||
beforeEach(() => { | ||
cy.mount(FormSelectTeam, { | ||
props: {}, | ||
}); | ||
cy.viewport('iphone-6'); | ||
}); | ||
|
||
coreTests(); | ||
}); | ||
}); | ||
|
||
function coreTests() { | ||
it('renders component', () => { | ||
// component | ||
cy.dataCy(selectorFormSelectTeam).should('be.visible'); | ||
// info text | ||
cy.dataCy(selectorFormSelectTeamInfo) | ||
.should('be.visible') | ||
.should('have.text', i18n.global.t('register.challenge.textTeamInfo')); | ||
// select table | ||
cy.dataCy(selectorFormSelectTableTeam).should('be.visible'); | ||
}); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<script lang="ts"> | ||
/** | ||
* FormSelectTeam Component | ||
* | ||
* @description Use this component to render a table for selecting a team. | ||
* Handles fetching teams from API. | ||
* Note: This component is used on `RegisterChallengePage`. | ||
* | ||
* @components | ||
* - `FormFieldSelectTable`: Base component for displaying selectable table options | ||
* | ||
* @example | ||
* <form-select-team /> | ||
* | ||
* @see [Figma Design](https://www.figma.com/design/L8dVREySVXxh3X12TcFDdR/Do-pr%C3%A1ce-na-kole?node-id=5366-26763&t=3zQmiCgIVO72EQBq-1) | ||
*/ | ||
// libraries | ||
import { defineComponent, ref } from 'vue'; | ||
// enums | ||
import { OrganizationLevel } from 'src/components/types/Organization'; | ||
// types | ||
import { FormSelectTableOption } from '../types/Form'; | ||
// components | ||
import FormFieldSelectTable from './FormFieldSelectTable.vue'; | ||
export default defineComponent({ | ||
name: 'FormSelectTeam', | ||
components: { | ||
FormFieldSelectTable, | ||
}, | ||
setup() { | ||
// TODO: fetch teams from API | ||
const teamOptions: FormSelectTableOption[] = [ | ||
{ | ||
label: 'Zelený team', | ||
value: 34565, | ||
members: 2, | ||
maxMembers: 5, | ||
}, | ||
{ | ||
label: 'Modrý team', | ||
value: 34566, | ||
members: 5, | ||
maxMembers: 5, | ||
}, | ||
]; | ||
const team = ref<number | null>(null); | ||
return { | ||
team, | ||
teamOptions, | ||
OrganizationLevel, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div data-cy="form-select-team"> | ||
<!-- Text: Info --> | ||
<div class="q-mb-lg" data-cy="form-select-team-info"> | ||
{{ $t('register.challenge.textTeamInfo') }} | ||
</div> | ||
<!-- Select table --> | ||
<form-field-select-table | ||
v-model="team" | ||
:organization-level="OrganizationLevel.team" | ||
:options="teamOptions" | ||
data-cy="form-select-table-team" | ||
/> | ||
</div> | ||
</template> |
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