Skip to content

Fixes#13

Merged
ByMuhmd merged 1 commit into
mainfrom
Sami
Jul 3, 2026
Merged

Fixes#13
ByMuhmd merged 1 commit into
mainfrom
Sami

Conversation

@ByMuhmd

@ByMuhmd ByMuhmd commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings July 3, 2026 15:01
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hirfa Ready Ready Preview, Comment Jul 3, 2026 3:01pm

Request Review

@ByMuhmd ByMuhmd merged commit 5a75fea into main Jul 3, 2026
9 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread lib/supabase/schema.sql
Comment on lines +55 to 57
CREATE POLICY "System can insert notifications"
ON public.notifications FOR INSERT
WITH CHECK (true);
Comment thread lib/supabase/schema.sql
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;
Comment thread lib/supabase/schema.sql

RETURN TRUE;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
Comment thread lib/supabase/schema.sql
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 thread hooks/useClientBooking.ts
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 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants