-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
441 additions
and
33 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
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
95 changes: 95 additions & 0 deletions
95
client/components/StudentPage/ExtendedRequestDeviceForm.js
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,95 @@ | ||
import React, { useState } from 'react' | ||
import { useSelector, useDispatch } from 'react-redux' | ||
import { | ||
Button, Segment, Form, Checkbox, | ||
} from 'semantic-ui-react' | ||
import { deviceRequestAction } from 'Utilities/redux/deviceRequestReducer' | ||
import { localeSelector } from 'Utilities/redux/localeReducer' | ||
import InstructionModal from './InstructionModal' | ||
|
||
const translations = { | ||
iWantDevice: { | ||
en: 'I want a device', | ||
fi: 'Haluan laitteen', | ||
}, | ||
hello: { | ||
en: 'Hello', | ||
fi: 'Hei', | ||
}, | ||
youAreEntitledToADevice: { | ||
en: '...', | ||
fi: 'Olet oikeutettu normaalin jakelun ulkopuolella annettavaan fuksilaitteeseen', | ||
}, | ||
email: { | ||
en: 'Email', | ||
fi: 'Sähköposti', | ||
}, | ||
termsAndConditions: { | ||
en: 'Read the instructions', | ||
fi: 'Lue ohjeet', | ||
}, | ||
areYouSure: { | ||
en: 'Are you sure?', | ||
fi: 'Oletko varma?', | ||
}, | ||
iHaveRead: { | ||
en: 'I have read and understood the instructions', | ||
fi: 'Olen lukenut ja ymmärtänyt ohjeet', | ||
}, | ||
} | ||
|
||
const ExtendedRequestDeviceForm = () => { | ||
const [termsOpen, setTermsOpen] = useState(false) | ||
const [termsHaveBeenOpened, setTermsHaveBeenOpened] = useState(false) | ||
const [termsAccepted, setTermsAccepted] = useState(false) | ||
const dispatch = useDispatch() | ||
const user = useSelector(state => state.user.data) | ||
const locale = useSelector(localeSelector) | ||
|
||
const handleRequestClick = () => { | ||
dispatch(deviceRequestAction({ extended: true, email: null })) | ||
} | ||
|
||
const handleTermsClose = () => setTermsOpen(false) | ||
|
||
const primaryButtonDisabled = !termsAccepted // Always disable if not valid | ||
|
||
const handleTermsOpen = () => { | ||
setTermsOpen(true) | ||
setTermsHaveBeenOpened(true) | ||
} | ||
|
||
return ( | ||
<div> | ||
<InstructionModal open={termsOpen} handleClose={handleTermsClose} /> | ||
<Segment> | ||
<p>{`${translations.hello[locale]} ${user.name},`}</p> | ||
<p>{translations.youAreEntitledToADevice[locale]}</p> | ||
<Form> | ||
<div style={{ display: 'flex', flexDirection: 'column', padding: '1em 0em' }}> | ||
<span | ||
role="button" | ||
tabIndex={0} | ||
style={{ | ||
width: '100%', marginBottom: '1em', cursor: 'pointer', color: 'blue', | ||
}} | ||
onKeyPress={handleTermsOpen} | ||
onClick={handleTermsOpen} | ||
data-cy="terms" | ||
> | ||
{translations.termsAndConditions[locale]} | ||
</span> | ||
<Checkbox data-cy="acceptTerms" checked={termsAccepted} disabled={!termsHaveBeenOpened} onClick={() => setTermsAccepted(!termsAccepted)} label={translations.iHaveRead[locale]} /> | ||
</div> | ||
<div style={{ display: 'flex' }}> | ||
<Button style={{ flex: 1, paddingTop: '2em', paddingBottom: '2em' }} color="purple" onClick={handleRequestClick} disabled={primaryButtonDisabled} data-cy="getDevicePrimary"> | ||
{translations.iWantDevice[locale]} | ||
</Button> | ||
</div> | ||
</Form> | ||
</Segment> | ||
</div> | ||
) | ||
} | ||
|
||
export default ExtendedRequestDeviceForm |
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,78 @@ | ||
import React from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { Segment, Icon, Header } from 'semantic-ui-react' | ||
import { localeSelector } from 'Utilities/redux/localeReducer' | ||
import TranslatedMarkdown from 'Components/TranslatedMarkdown' | ||
import StudentInfo from './StudentInfo' | ||
// import TaskInfo from './TaskInfo' | ||
|
||
const translations = { | ||
taskStatus: { | ||
en: 'Task status:', | ||
fi: 'Tehtävien tila:', | ||
}, | ||
beFuksi: { | ||
en: 'Be a fresher', | ||
fi: 'Ole fuksi', | ||
}, | ||
registeredToRelevant: { | ||
en: 'Registered to relevant course', | ||
fi: 'Rekisteröitynyt relevantille kurssille', | ||
}, | ||
digiSkillsCompleted: { | ||
en: 'DIGI-A completed', | ||
fi: 'DIGI-A suoritettu', | ||
}, | ||
tasksFinished: { | ||
en: 'You have completed the tasks required for fresher device. Info about device distribution will be sent to you by email.', | ||
fi: 'Olet suorittanut fuksilaitteeseen vaadittavat tehtävät. Saat tiedot laitteiden jakelusta sähköpostitse.', | ||
}, | ||
} | ||
|
||
const Task = ({ task, completed }) => { | ||
if (completed) { | ||
return ( | ||
<Segment style={{ background: '#d2f3db' }} textAlign="center"> | ||
{task} | ||
<Icon name="checkmark" size="large" style={{ marginLeft: '10px' }} /> | ||
</Segment> | ||
) | ||
} | ||
return ( | ||
<Segment style={{ background: '#fddede' }} textAlign="center"> | ||
{task} | ||
<Icon name="cancel" size="large" style={{ marginLeft: '10px' }} /> | ||
</Segment> | ||
) | ||
} | ||
|
||
const fake = { | ||
user: { | ||
eligible: true, | ||
courseRegistrationCompleted: true, | ||
digiSkillsCompleted: true, | ||
}, | ||
} | ||
|
||
const StudentStatusPage = ({ faking }) => { | ||
const user = faking ? fake.user : useSelector(state => state.user.data) | ||
const locale = useSelector(localeSelector) | ||
|
||
return ( | ||
<Segment.Group> | ||
<StudentInfo faking={faking} /> | ||
{/* <TaskInfo | ||
courseRegistrationCompleted={user.courseRegistrationCompleted} | ||
digiSkillsCompleted={user.digiSkillsCompleted} | ||
/> */} | ||
<Segment> | ||
You will get an email when the device is ready! | ||
</Segment> | ||
<Segment> | ||
<TranslatedMarkdown textKey="deviceSpecs" /> | ||
</Segment> | ||
</Segment.Group> | ||
) | ||
} | ||
|
||
export default StudentStatusPage |
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
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
17 changes: 17 additions & 0 deletions
17
migrations/20240125203210-extended-device-fields-to-user.js
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,17 @@ | ||
|
||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => queryInterface.sequelize.transaction(t => Promise.all([ | ||
queryInterface.addColumn('users', 'extended_wants_device', { | ||
type: Sequelize.BOOLEAN, | ||
}, { transaction: t }), | ||
queryInterface.addColumn('users', 'extended_eligible', { | ||
type: Sequelize.BOOLEAN, | ||
}, { transaction: t }), | ||
])), | ||
|
||
down: queryInterface => queryInterface.sequelize.transaction(t => Promise.all([ | ||
queryInterface.removeColumn('users', 'extended_wants_device', { transaction: t }), | ||
queryInterface.removeColumn('users', 'extended_eligible', { transaction: t }), | ||
])), | ||
} |
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
Oops, something went wrong.