-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#138] Fix request history visibility and add status field #142
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,16 @@ const props = defineProps<{ | |
cta?: Boolean | ||
}>() | ||
|
||
// A list of all the users in your account including their name, title, email and role. | ||
const visibleRequests = ref(props.requests || []) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement server-side filtering for the requests based on their status to improve performance and scalability. This approach reduces the client-side workload and ensures the application can handle a large number of requests efficiently. [important] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're using this approach for quicker prototyping while we gather the initial feedback from users. |
||
const hasOpenRequests = ref(false) | ||
|
||
onMounted(() => { | ||
console.log('requests', visibleRequests.value) | ||
let computedValue = computed(() => visibleRequests.value.some(request => request.status !== 'delivered')) | ||
hasOpenRequests.value = computedValue.value | ||
}) | ||
|
||
|
||
</script> | ||
|
||
<template> | ||
|
@@ -21,42 +30,30 @@ const props = defineProps<{ | |
<p class="mt-2 text-sm text-gray-700 dark:text-gray-200">{{ description }}</p> | ||
</div> | ||
<div class="mt-4 sm:ml-16 sm:mt-0 sm:flex-none"> | ||
<a v-if="cta" type="button" href="/requests/new" | ||
<a v-if="cta && !hasOpenRequests" type="button" href="/requests/new" | ||
class="block rounded-md bg-primary px-3 py-2 text-center text-sm font-semibold text-white dark:text-black shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 "> | ||
Request Pet Food | ||
</a> | ||
</div> | ||
</div> | ||
<!-- { | ||
"address_text": "1201 Kingsway, Med Hat", | ||
"address_google_place_id": null, | ||
"address_canadapost_id": null, | ||
"address_latitude": null, | ||
"address_longitude": null, | ||
"address_buildingtype": "NOT_SPECIFIED", | ||
"address_details": {}, | ||
"contact_phone": "+12507772171", | ||
"contact_email": "", | ||
"contact_name": "Pearl", | ||
"method_of_contact": "Email", | ||
"pet_details": {}, | ||
"confirm_correct": true, | ||
"accept_terms": true, | ||
"date_requested": "2024-04-06" | ||
} --> | ||
|
||
<div class="-mx-4 mt-8 sm:-mx-0"> | ||
<table class="min divide-y divide-gray-300 dark:divide-gray-300"> | ||
<thead> | ||
<tr> | ||
<th scope="col" class="hidden py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 dark:text-white lg:table-cell sm:pl-0 ">Date</th> | ||
<th scope="col" class="hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white lg:table-cell">Contact</th> | ||
<th scope="col" class="hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white lg:table-cell">Address</th> | ||
<th scope="col" class="hidden py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 dark:text-white sm:table-cell sm:pl-0 ">Date</th> | ||
<th scope="col" class="hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white sm:table-cell">Contact</th> | ||
<th scope="col" class="hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white sm:table-cell">Address</th> | ||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white sm:table-cell sm:pl-0 ">Contents</th> | ||
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-0"><span class="sr-only">View</span></th> | ||
</tr> | ||
</thead> | ||
<tbody class="divide-y divide-gray-200 bg-white dark:bg-slate-900 dark:divide-gray-500"> | ||
<tr v-for="request in requests" :key="request.id"> | ||
<tbody class="divide-y divide-gray-200 bg-white dark:bg-gray-900 dark:divide-gray-500"> | ||
<tr | ||
v-for="(request, index) in requests" | ||
:key="request.id" | ||
:class="(index === 0) ? 'bg-slate-100 dark:bg-slate-800': ''" | ||
> | ||
<td class="max-w-sm w-full py-4 pl-4 pr-3 text-sm font-medium text-gray-900 dark:text-white sm:w-auto sm:max-w-none sm:pl-0"> | ||
{{ request.date_requested }} | ||
<dl class="font-normal lg:hidden"> | ||
|
@@ -68,11 +65,11 @@ const props = defineProps<{ | |
<dd class="mt-1 truncate text-gray-500 dark:text-gray-200">{{ request.address_text }}</dd> | ||
</dl> | ||
</td> | ||
<td class="max-w-xs hidden px-3 py-4 text-sm text-gray-500 dark:text-gray-200 lg:table-cell">{{ request.contact_name }}</td> | ||
<td class="max-w-xs hidden px-3 py-4 text-sm text-gray-500 dark:text-gray-200 lg:table-cell">{{ request.contact_name }}</td> | ||
<td class="max-w-xs hidden px-3 py-4 text-sm text-gray-500 dark:text-gray-200 lg:table-cell">{{ request.address_text }}</td> | ||
<td class="max-w-xs hidden px-3 py-4 text-sm text-gray-500 dark:text-gray-200 lg:table-cell">{{ request.pet_details?.pets_blob }}</td> | ||
<td class="py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-0"> | ||
<a :href="`/requests/${request.id}/details`" class="text-indigo-600 hover:text-indigo-900 dark:text-blue-400">View<span class="sr-only">, {{ request.name | ||
<a :href="`/requests/${request.id}/details`" class="text-indigo-600 hover:text-indigo-900 dark:text-blue-400">{{ request.status }}<span class="sr-only">, {{ request.name | ||
}}</span></a> | ||
</td> | ||
</tr> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing "status" from
read_only_fields
inFoodRequestUpdateSerializer
if the status is intended to be updated by the user or through the API. This change allows the status field to be updated when necessary. [important]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not meant to be updatable via the API. Only by logic in our code.