Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR expands the booking/engagement features around Supabase by introducing bundled bookings, a local “trust board” leaderboard, warranty/recurrence support, and new RPCs to centralize cancellation-fee and rating updates, alongside several UI/UX adjustments.
Changes:
- Add Supabase schema updates: bookings bundle/warranty fields + new RPCs (
cancel_booking_with_fee,update_worker_rating) + notification policy tweak. - Introduce client bundle-booking flow (bundle selection + confirmation pages) and a client trust-board leaderboard page.
- Update multiple client/worker flows: emergency pricing adjustments, ranking sort logic using rating+completed orders, booking completion writes warranty metadata.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/supabase/schema.sql | Adds bookings bundle/warranty columns, notification policies, and new SECURITY DEFINER RPCs |
| lib/supabase/booking-payments.ts | Updates worker total_earnings during booking completion processing |
| hooks/useHome.ts | Updates emergency booking price calculation |
| hooks/useClientHome.ts | Adjusts worker ranking sort to include completed orders in the trust metric |
| hooks/useClientBooking.ts | Adds bundle booking creation + switches cancellation to RPC-first behavior |
| hooks/useCategoryWorkers.ts | Adjusts rating sort to include completed orders in the trust metric |
| components/shared/CapacitorListener.tsx | Adds Android back button handling behavior in Capacitor |
| app/client/trust-board/page.tsx | New local trust-board leaderboard UI |
| app/client/rate-review/[bookingId]/ClientPage.tsx | Switches worker rating update to RPC call |
| app/client/orders/page.tsx | Adds warranty recurrence request flow + UI gating based on warranty expiry |
| app/client/order/success/page.tsx | Updates rating display to use icon |
| app/client/home/page.tsx | Adds navigation cards for bundles + trust-board; minor UI tweaks |
| app/client/emergency/page.tsx | Extends emergency search timeout + adds compensation logic on timeout; updates price |
| app/client/bundle/page.tsx | New bundle selection UI (choose services/date) |
| app/client/bundle/confirm/page.tsx | New bundle confirmation UI with worker auto-assignment + booking creation |
| app/client/addresses/new/page.tsx | Replaces emoji icons with Lucide icons in address type selector |
| app/client/addresses/edit/[id]/ClientPage.tsx | Replaces emoji icons with Lucide icons in address type selector |
| app/(main)/worker/booking/[id]/ClientPage.tsx | Writes warranty metadata on booking completion based on rating/subscription |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
57
| CREATE POLICY "System can insert notifications" | ||
| ON public.notifications FOR INSERT | ||
| WITH CHECK (true); |
Comment on lines
+346
to
+368
| -- Get booking details | ||
| SELECT client_id, tracking_status INTO v_client_id, v_tracking_status | ||
| FROM public.bookings | ||
| WHERE id = p_booking_id; | ||
|
|
||
| IF NOT FOUND THEN | ||
| RETURN FALSE; | ||
| END IF; | ||
|
|
||
| -- Update booking status to cancelled | ||
| UPDATE public.bookings SET status = 'cancelled' WHERE id = p_booking_id; | ||
|
|
||
| -- Check if tracking_status is 'on_the_way', 'arrived', 'work_started' | ||
| IF v_tracking_status IN ('on_the_way', 'arrived', 'work_started') THEN | ||
| -- Deduct 50 EGP from client | ||
| UPDATE public.profiles | ||
| SET wallet_balance = COALESCE(wallet_balance, 0) - 50 | ||
| WHERE id = v_client_id; | ||
|
|
||
| -- Log transaction | ||
| INSERT INTO public.transactions (user_id, type, amount, description, reference_type, reference_id) | ||
| VALUES (v_client_id, 'payment', -50, 'رسوم إلغاء حجز بعد تحرك الحرفي', 'booking', p_booking_id); | ||
| END IF; |
|
|
||
| RETURN TRUE; | ||
| END; | ||
| $$ LANGUAGE plpgsql SECURITY DEFINER; |
| SET rating = ROUND(v_avg_rating, 1) | ||
| WHERE id = p_worker_id; | ||
| END; | ||
| $$ LANGUAGE plpgsql SECURITY DEFINER; |
Comment on lines
+34
to
+37
| const supabase = createClient() | ||
| const { data: { user } } = await supabase.auth.getUser() | ||
| if (!user) return | ||
|
|
| <div className="relative"> | ||
| <div className={`w-14 h-14 rounded-full overflow-hidden border-2 ${medal ? medal.border : 'border-white/10'}`}> | ||
| {craftsman.avatar_url ? ( | ||
| <Image src={craftsman.avatar_url} alt="" fill className="object-cover" /> |
| <div className="flex items-center gap-3 mt-1.5 text-xs text-white/60"> | ||
| <span className="flex items-center gap-1"> | ||
| <Star size={12} className="text-yellow-500 fill-yellow-500" /> | ||
| {craftsman.rating?.toFixed(1) || '5.0'} |
Comment on lines
+218
to
+224
| <img src={assignment.worker.avatar_url || ''} alt="" className="w-6 h-6 rounded-full bg-slate-700" /> | ||
| <div className="text-xs"> | ||
| <p className="text-white font-medium">{assignment.worker.full_name}</p> | ||
| <p className="text-[#F97316] flex items-center gap-1"> | ||
| <Star size={10} className="fill-current" /> {assignment.worker.rating || '4.9'} | ||
| </p> | ||
| </div> |
| <div className="flex items-center gap-1"> | ||
| <span className="text-[#94A3B8] text-sm">{worker.profession || 'حرفي'} • </span> | ||
| <span className="text-[#F97316] text-sm">★ {worker.rating?.toFixed(1) || '4.9'}</span> | ||
| <span className="text-[#F97316] text-sm flex items-center gap-1"><Star size={12} className="fill-current" /> {worker.rating?.toFixed(1) || '4.9'}</span> |
Comment on lines
+114
to
+121
| // First try the RPC which handles the cancellation fee logic | ||
| const { error: rpcError } = await supabase.rpc('cancel_booking_with_fee', { p_booking_id: bookingId }) | ||
|
|
||
| if (rpcError) { | ||
| console.warn('RPC failed or not found, falling back to standard cancellation', rpcError) | ||
| const { error: err } = await supabase.from('bookings').update({ status: 'cancelled' }).eq('id', bookingId) | ||
| if (err) { setError(err.message); setSubmitting(false); return false } | ||
| } |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.