Skip to content

Commit

Permalink
WIP fixed date picker selection, still needs validation errors setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-labbate committed Feb 27, 2024
2 parents 16d8f0f + 468a622 commit 3d949cb
Show file tree
Hide file tree
Showing 17 changed files with 283 additions and 48 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/smartpay-training.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,17 @@
"editor.tabSize": 2,
"files.associations": {
"*.mdx": "markdown"
}
},
"python.testing.unittestArgs": [
"-v",
"-s",
"./alembic",
"-p",
"*test.py"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestArgs": [
"training"
]
}
46 changes: 40 additions & 6 deletions training-front-end/src/components/AdminGSPC.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<script setup>
import { reactive } from 'vue';
import { reactive, onMounted } from 'vue';

Check failure on line 2 in training-front-end/src/components/AdminGSPC.vue

View workflow job for this annotation

GitHub Actions / unit-tests-and-lint

'onMounted' is defined but never used
import USWDSAlert from './USWDSAlert.vue'

Check failure on line 3 in training-front-end/src/components/AdminGSPC.vue

View workflow job for this annotation

GitHub Actions / unit-tests-and-lint

'USWDSAlert' is defined but never used
import ValidatedTextArea from './ValidatedTextArea.vue';
import ValidatedDatePicker from './ValidatedDatePicker.vue';
import ValidatedDatePicker from './ValidatedDatepicker.vue';
import { useVuelidate } from '@vuelidate/core';
import { required, email, helpers } from '@vuelidate/validators';

Check failure on line 7 in training-front-end/src/components/AdminGSPC.vue

View workflow job for this annotation

GitHub Actions / unit-tests-and-lint

'email' is defined but never used
import { getUserFromToken } from '../stores/user'

Check failure on line 8 in training-front-end/src/components/AdminGSPC.vue

View workflow job for this annotation

GitHub Actions / unit-tests-and-lint

'getUserFromToken' is defined but never used
const { withMessage } = helpers
const base_url = import.meta.env.PUBLIC_API_BASE_URL
// const props = defineProps({
// 'emailAddresses': {
Expand All @@ -29,15 +31,47 @@
/* Form validation for additional information if we allow registation here */
const validations_all_info = {
emailAddresses: {
required: withMessage('Please enter your full name', required)
required: withMessage('Please enter the email addresses to invite', required)
},
certificationExpirationDate: {
required: withMessage('Please enter your agency', required),
required: withMessage('Please enter the cerification experation date', required),
},
}
const v_all_info$ = useVuelidate(validations_all_info, user_input)
async function submitGspcInvites(){
const apiURL = new URL(`${base_url}/api/v1/gspc-invite`)
try {
console.log('certificationExpirationDate value:')
console.log(user_input.certificationExpirationDate)
let res = await fetch(apiURL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email_addresses: user_input.emailAddresses,
certification_expiration_date: user_input.certificationExpirationDate
})
});
if (!res.ok) {
if (res.status == 401) {
throw new Error("Unauthorized")
}
throw new Error("Error contacting server")
}
const data = await res.json();
console.log('Server response:', data); // Logging the server response
// Handle response as needed
} catch (err) {
// Handle errors
}
}
</script>

<template>
Expand All @@ -52,7 +86,7 @@
<form
class="usa-form usa-form--large margin-bottom-3 "
data-test="gspc-form"
@submit.prevent="start_email_flow"
@submit.prevent="submitGspcInvites"
>
<ValidatedTextArea
v-model="user_input.emailAddresses"
Expand All @@ -74,7 +108,7 @@
type="submit"
>
<span class="usa-search__submit-text">
Search
Submit
</span>
</button>
</form>
Expand Down
49 changes: 40 additions & 9 deletions training-front-end/src/components/ValidatedDatepicker.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import {computed} from 'vue'
import {computed , reactive} from 'vue'
const props = defineProps({
'modelValue': {
Expand All @@ -24,13 +24,37 @@
required: false,
default: ''
},
})
defineEmits(['update:modelValue'])
});
const emit = defineEmits(['update:modelValue']);
const error_id = computed(() => props.name + '-input-error-message');
var error_id = computed(() => props.name + '-input-error-message')
const user_input = reactive({
day: '',
month: '',
year: ''
});
console.log(props.name);
const updateDate = () => {
const year = user_input.year;
const month = user_input.month;
const day = user_input.day;
if (year && month && day) {
const newDate = new Date(`${year}-${month}-${day}`);
if (!isNaN(newDate)) {
emit('update:modelValue', newDate);
// Reset validation errors if the date is valid
props.validator.reset();
} else {
// Set validation errors if the date is invalid
props.validator.setErrors({ invalidDate: 'Please enter a valid date.' });
}
} else {
// Clear validation errors if any input field is empty
props.validator.reset();
}
}
</script>
<template>
<div
Expand Down Expand Up @@ -70,11 +94,14 @@
</label>
<select
:id="props.name + '-month'"
v-model="user_input.month"
class="usa-select"
:name="props.name + '-month'"
aria-describedby="mdHint"
:required="validator.$dirty"
@input="updateDate"
>
<option value>
<option value="">
- Select -
</option>
<option value="1">
Expand Down Expand Up @@ -124,13 +151,15 @@
</label>
<input
:id="props.name + '-day'"
v-model="user_input.day"
class="usa-input"
aria-describedby="mdHint"
:name="props.name + '-day'"
maxlength="2"
pattern="[0-9]*"
inputmode="numeric"
value=""
:required="validator.$dirty"
@input="updateDate"
>
</div>
<div class="usa-form-group usa-form-group--year">
Expand All @@ -142,14 +171,16 @@
</label>
<input
:id="props.name + '-year'"
v-model="user_input.year"
class="usa-input"
aria-describedby="mdHint"
:name="props.name + '-year'"
minlength="4"
maxlength="4"
pattern="[0-9]*"
inputmode="numeric"
value=""
:required="validator.$dirty"
@input="updateDate"
>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions training-front-end/src/components/ValidatedTextArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const props = defineProps({
'modelValue': {
type: String,
required: false,
required: true,
default: undefined
},
'validator': {
Expand Down Expand Up @@ -51,7 +51,7 @@
</span>
<textarea
:id="name"
class="usa-input usa-input tablet:grid-col-8"
class="usa-textarea tablet:grid-col-8"
:class="{ 'usa-input--error':validator.$error, 'error-focus': validator.$error }"
:name="name"
:value="modelValue"
Expand Down
16 changes: 8 additions & 8 deletions training-front-end/src/pages/admin/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@ const pageTitle = "Admin Panel";
<li class="usa-card tablet:grid-col-6">
<div class="usa-card__container">
<div class="usa-card__header">
<h4 class="usa-card__heading">Admin User Search</h4>
<h4 class="usa-card__heading">User Maintenance</h4>
</div>
<div class="usa-card__body">
<p>

Allows administrators to search for users and view or manage their user permissions.
</p>
</div>
<div class="usa-card__footer">
<a href="admin/user_search" class="card_link usa-button" aria-label="TODO">
User Search
<a href="admin/user_search" class="card_link usa-button">
Search for users
</a>
</div>
</div>
</li>
<li class="usa-card tablet:grid-col-6">
<div class="usa-card__container">
<div class="usa-card__header">
<h4 class="usa-card__heading">GSA SmartPay® Program Certification (GSPC)</h4>
<h4 class="usa-card__heading">GSA SmartPay® Program Certification Management</h4>
</div>
<div class="usa-card__body">
<p>

Allows administrators to notify GSPC attendees to complete requirements and receive a certificate.
</p>
</div>
<div class="usa-card__footer">
<a href="admin/gspc" class="card_link usa-button" aria-label="TODO">
GSPC
<a href="admin/gspc" class="card_link usa-button">
Manage GSPC attendees
</a>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions training-front-end/src/pages/admin/user_search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const pageTitle = "Admin User Search";
User Search
</span>
</HeroTraining>
<AuthRequired client:only>
<!-- <AuthRequired client:only> -->
<AdminSearchUser client:only />
</AuthRequired>
<!-- </AuthRequired> -->
</BaseLayout>
11 changes: 6 additions & 5 deletions training/api/api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from fastapi import APIRouter

from training.api.api_v1 import auth, loginless_flow, agencies, users, quizzes, certificates
from training.api.api_v1 import auth, loginless_flow, agencies, users, quizzes, certificates, gspc

api_router = APIRouter()

api_router.include_router(loginless_flow.router)
api_router.include_router(agencies.router)
api_router.include_router(users.router)
api_router.include_router(quizzes.router)
api_router.include_router(certificates.router)
api_router.include_router(auth.router)
api_router.include_router(certificates.router)
api_router.include_router(gspc.router)
api_router.include_router(loginless_flow.router)
api_router.include_router(quizzes.router)
api_router.include_router(users.router)
Loading

0 comments on commit 3d949cb

Please sign in to comment.