diff --git a/src/assets/help-ss/default-employee-list.png b/src/assets/help-ss/default-employee-list.png new file mode 100644 index 0000000..659ab37 Binary files /dev/null and b/src/assets/help-ss/default-employee-list.png differ diff --git a/src/assets/help-ss/default-employee-management.png b/src/assets/help-ss/default-employee-management.png new file mode 100644 index 0000000..a130bee Binary files /dev/null and b/src/assets/help-ss/default-employee-management.png differ diff --git a/src/assets/help-ss/default-validation-page.png b/src/assets/help-ss/default-validation-page.png new file mode 100644 index 0000000..b06da43 Binary files /dev/null and b/src/assets/help-ss/default-validation-page.png differ diff --git a/src/modules/help/components/help-module.vue b/src/modules/help/components/help-module.vue index 1401dd6..ea2ceea 100644 --- a/src/modules/help/components/help-module.vue +++ b/src/modules/help/components/help-module.vue @@ -3,25 +3,28 @@ import default_dashboard from 'src/assets/help-ss/default-dashboard.png'; import default_personal_profile from 'src/assets/help-ss/default-personnal_profile.png'; import default_timesheet from 'src/assets/help-ss/default-timesheet.png'; +import default_employee_list from 'src/assets/help-ss/default-employee-list.png'; +import default_employee_management from 'src/assets/help-ss/default-employee-management.png'; +import default_validation_page from 'src/assets/help-ss/default-validation-page.png'; + const default_images: Record = { dashboard: default_dashboard, personal_profile: default_personal_profile, timesheets: default_timesheet, - employee_list: '', - employee_management: '', - timesheets_approval: '', + employee_list: default_employee_list, + employee_management: default_employee_management, + timesheets_approval: default_validation_page, }; -import type { HelpModuleKey } from 'src/modules/help/models/help-module.model'; -import { useHelpStore } from 'src/stores/help-store'; +import type { HelpModuleKey, HelpModuleOptions } from 'src/modules/help/models/help-module.model'; import { ref } from 'vue'; const props = defineProps<{ help_module: HelpModuleKey; + options: HelpModuleOptions[]; moduleIndex: number; }>(); -const help_store = useHelpStore(); const help_module = props.help_module; const current_path = ref(default_images[help_module]); @@ -70,7 +73,7 @@ const switchSide = (index: number) => {
; +export type PartialOptions = Partial>; //Shared images and descriptions diff --git a/src/pages/help-page.vue b/src/pages/help-page.vue index dc44404..f66026b 100644 --- a/src/pages/help-page.vue +++ b/src/pages/help-page.vue @@ -21,10 +21,11 @@ onMounted(async () => { class="text-accent" />
diff --git a/src/stores/help-store.ts b/src/stores/help-store.ts index 091ee83..4d3c987 100644 --- a/src/stores/help-store.ts +++ b/src/stores/help-store.ts @@ -1,12 +1,16 @@ import { defineStore } from "pinia"; -import { ref } from "vue"; +import { computed, ref } from "vue"; import { HelpService } from "src/modules/help/services/help.service"; -import { type Options, type HelpModuleKey, profile_options, timesheets_options, employee_list_options, employee_management_options, timesheets_approval_options, dashboard_options } from "src/modules/help/models/help-module.model"; +import { profile_options, timesheets_options, employee_list_options, employee_management_options, timesheets_approval_options, dashboard_options } from "src/modules/help/models/help-module.model"; +import type { Options, HelpModuleKey, HelpModuleOptions } from "src/modules/help/models/help-module.model"; + + export const useHelpStore = defineStore('help', () => { const is_loading = ref(false); const help_modules = ref([]); - const help_module_options = ref({ + + const help_module_details = ref({ dashboard: dashboard_options, personal_profile: profile_options, timesheets: timesheets_options, @@ -15,29 +19,40 @@ export const useHelpStore = defineStore('help', () => { timesheets_approval: timesheets_approval_options, }); + const help_module_filters = computed>(() => { + const entries = help_modules.value + .map((key) => { + const options = help_module_details.value[key]; + return options ? ([key, options] as const) : null; + }) + .filter( + (entry): entry is readonly [HelpModuleKey, HelpModuleOptions[]] => + entry !== null + ); + + return Object.fromEntries(entries) as Record; + }); + const getHelpModules = async (): Promise => { is_loading.value = true; try { const response = await HelpService.getHelpModules(); if (response.success && response.data) help_modules.value = response.data; - is_loading.value = false; + return response.success; } catch (error) { console.error('An error occured while fetching Help modules', error); - return false; + } finally { + is_loading.value = false; } }; - const buildHelpModuleOptions = () => { - //todo: build a custom versions of help_module_options with only the module the employee has access - } - return { is_loading, help_modules, - help_module_options, + help_module_details, + help_module_filters, getHelpModules, - buildHelpModuleOptions, - } + }; }); \ No newline at end of file