Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Roster): enforce selection of company #2395

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: enforce selection of company
krantheman committed Nov 7, 2024
commit 56973daac29ff2eaa37643fb1ac7834fd164bcd9
6 changes: 5 additions & 1 deletion roster/src/views/MonthView.vue
Original file line number Diff line number Diff line change
@@ -28,12 +28,14 @@
@addToMonth="addToMonth"
/>
<MonthViewTable
v-if="isCompanySelected"
ref="monthViewTable"
:firstOfMonth="firstOfMonth"
:employees="employees.data || []"
:employeeFilters="employeeFilters"
:shiftTypeFilter="shiftTypeFilter"
/>
<div v-else class="my-40 text-center">Please select a company.</div>
</div>
</div>
<ShiftAssignmentDialog
@@ -61,6 +63,7 @@ export type EmployeeFilters = {
};

const monthViewTable = ref<InstanceType<typeof MonthViewTable>>();
const isCompanySelected = ref(false);
const showShiftAssignmentDialog = ref(false);
const firstOfMonth = ref(dayjs().date(1).startOf("D"));
const shiftTypeFilter = ref("");
@@ -73,6 +76,8 @@ const addToMonth = (change: number) => {
};

const updateFilters = (newFilters: EmployeeFilters & { shift_type: string }) => {
isCompanySelected.value = !!newFilters.company;
if (!isCompanySelected.value) return;
let employeeUpdated = false;
(Object.entries(newFilters) as [keyof EmployeeFilters | "shift_type", string][]).forEach(
([key, value]) => {
@@ -96,7 +101,6 @@ const employees = createListResource({
fields: ["name", "employee_name", "designation", "image"],
filters: employeeFilters,
pageLength: 99999,
auto: true,
onError(error: { messages: string[] }) {
raiseToast("error", error.messages[0]);
},