-
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.
#51 Show assessors error when uploading IA late
- Loading branch information
Showing
5 changed files
with
178 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<template> | ||
<div class="govuk-warning-text"> | ||
<span | ||
class="govuk-warning-text__icon" | ||
aria-hidden="true" | ||
>!</span> | ||
<strong class="govuk-warning-text__text"> | ||
<span class="govuk-warning-text__assistive">Warning</span> | ||
{{ message }} | ||
</strong> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
props: { | ||
message: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
}; | ||
</script> |
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,73 @@ | ||
const isDate = (date) => date instanceof Date; | ||
|
||
const isDateInFuture = (date) => { | ||
// @TODO #388 update to full datetime instead of hardcoding time | ||
if (!(date instanceof Date)) { | ||
throw 'Supplied date must be a Date object'; | ||
} | ||
|
||
const today = new Date(); | ||
|
||
date = new Date( | ||
date.getFullYear(), | ||
date.getMonth(), | ||
date.getDate(), | ||
13, | ||
0, | ||
0 | ||
); | ||
|
||
return date > today; | ||
}; | ||
|
||
const formatDate = (date, type) => { | ||
if (!(date instanceof Date)) { | ||
throw 'Supplied date must be a Date object'; | ||
} | ||
|
||
if (type && type === 'time') { | ||
return date.toLocaleString('en-GB', { hour: 'numeric', minute: 'numeric', hour12: true }).toLowerCase(); | ||
} | ||
|
||
const month = date.toLocaleString('en-GB', { month: 'long' }); | ||
|
||
if (type && type === 'month') { | ||
return `${month} ${date.getFullYear()}`; | ||
} | ||
|
||
return `${date.getDate()} ${month} ${date.getFullYear()}`; | ||
}; | ||
|
||
const parseEstimatedDate = (value) => { | ||
if (value instanceof Date) { | ||
return value; | ||
} | ||
|
||
if (typeof value != 'string') { | ||
return; | ||
} | ||
const parts = value.split('-'); | ||
|
||
const [year, month, day] = [...parts, 1]; | ||
const date = new Date(Date.UTC(year, month - 1, day)); | ||
|
||
return date; | ||
}; | ||
|
||
const validateYear = (val) => { | ||
val = parseInt(val); | ||
|
||
if (isNaN(val) || val.toString().length !== 4) { | ||
return null; | ||
} | ||
|
||
return val; | ||
}; | ||
|
||
export { | ||
isDate, | ||
isDateInFuture, | ||
formatDate, | ||
parseEstimatedDate, | ||
validateYear | ||
}; |
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