-
Notifications
You must be signed in to change notification settings - Fork 0
Add registration workflow page #3
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
Open
nasmans
wants to merge
1
commit into
main
Choose a base branch
from
codex/create-registration-page-and-components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import React from "react"; | ||
|
|
||
| export interface RegistrationData { | ||
| fullName: string; | ||
| email: string; | ||
| phone: string; | ||
| wilaya: string; | ||
| city: string; | ||
| address: string; | ||
| notes?: string; | ||
| guests: number; | ||
| } | ||
|
|
||
| interface RegistrationReviewDialogProps { | ||
| open: boolean; | ||
| onClose: () => void; | ||
| onConfirm: () => void; | ||
| data: RegistrationData; | ||
| agreementChecked: boolean; | ||
| onAgreementChange: (checked: boolean) => void; | ||
| } | ||
|
|
||
| export const RegistrationReviewDialog: React.FC<RegistrationReviewDialogProps> = ({ | ||
| open, | ||
| onClose, | ||
| onConfirm, | ||
| data, | ||
| agreementChecked, | ||
| onAgreementChange, | ||
| }) => { | ||
| if (!open) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm"> | ||
| <div className="w-full max-w-xl rounded-2xl bg-white p-6 shadow-2xl"> | ||
| <header className="mb-4 flex items-center justify-between"> | ||
| <h2 className="text-2xl font-bold text-gray-900">مراجعة معلومات التسجيل</h2> | ||
| <button | ||
| type="button" | ||
| onClick={onClose} | ||
| className="rounded-full p-2 text-gray-500 transition hover:bg-gray-100 hover:text-gray-700" | ||
| aria-label="إغلاق" | ||
| > | ||
| × | ||
| </button> | ||
| </header> | ||
|
|
||
| <div className="space-y-2 text-gray-700"> | ||
| <InfoRow label="الاسم الكامل" value={data.fullName} /> | ||
| <InfoRow label="البريد الإلكتروني" value={data.email} /> | ||
| <InfoRow label="رقم الهاتف" value={data.phone} /> | ||
| <InfoRow label="الولاية" value={data.wilaya} /> | ||
| <InfoRow label="البلدية / المدينة" value={data.city} /> | ||
| <InfoRow label="العنوان" value={data.address} /> | ||
| <InfoRow label="عدد الضيوف" value={String(data.guests)} /> | ||
| {data.notes ? <InfoRow label="ملاحظات إضافية" value={data.notes} /> : null} | ||
| </div> | ||
|
|
||
| <label className="mt-6 flex items-start space-x-3 space-x-reverse text-sm text-gray-600"> | ||
| <input | ||
| type="checkbox" | ||
| className="mt-1 h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500" | ||
| checked={agreementChecked} | ||
| onChange={(event) => onAgreementChange(event.target.checked)} | ||
| /> | ||
| <span> | ||
| أؤكد أن جميع المعلومات صحيحة وأوافق على شروط الحجز وسياسة الخصوصية. | ||
| </span> | ||
| </label> | ||
|
|
||
| <div className="mt-6 flex flex-col-reverse gap-3 sm:flex-row sm:justify-end"> | ||
| <button | ||
| type="button" | ||
| onClick={onClose} | ||
| className="w-full rounded-full border border-gray-300 px-5 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-50 sm:w-auto" | ||
| > | ||
| تعديل المعلومات | ||
| </button> | ||
| <button | ||
| type="button" | ||
| onClick={onConfirm} | ||
| disabled={!agreementChecked} | ||
| className="w-full rounded-full bg-indigo-600 px-6 py-2 text-sm font-semibold text-white transition enabled:hover:bg-indigo-500 enabled:focus:outline-none enabled:focus:ring-2 enabled:focus:ring-indigo-400 disabled:cursor-not-allowed disabled:bg-indigo-300 sm:w-auto" | ||
| > | ||
| أكمل عملية التسجيل | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| interface InfoRowProps { | ||
| label: string; | ||
| value: string; | ||
| } | ||
|
|
||
| const InfoRow: React.FC<InfoRowProps> = ({ label, value }) => ( | ||
| <p className="flex flex-col rounded-lg bg-gray-50 px-4 py-2 text-sm sm:flex-row sm:items-center sm:justify-between"> | ||
| <span className="font-semibold text-gray-900">{label}</span> | ||
| <span className="mt-1 text-gray-700 sm:mt-0">{value}</span> | ||
| </p> | ||
| ); | ||
|
|
||
| export default RegistrationReviewDialog; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { RegistrationData } from "../components/RegistrationReviewDialog"; | ||
|
|
||
| export interface RegistrationPayload extends RegistrationData { | ||
| status: "pending"; | ||
| } | ||
|
|
||
| export interface RegistrationResponse { | ||
| success: boolean; | ||
| message: string; | ||
| } | ||
|
|
||
| /** | ||
| * Prepares the payload and triggers the registration API to persist a pending request | ||
| * and send the confirmation email. | ||
| */ | ||
| export async function submitRegistration( | ||
| data: RegistrationData, | ||
| signal?: AbortSignal | ||
| ): Promise<RegistrationResponse> { | ||
| const payload: RegistrationPayload = { | ||
| ...data, | ||
| status: "pending", | ||
| }; | ||
|
|
||
| const response = await fetch("/api/registrations", { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| body: JSON.stringify({ | ||
| registration: payload, | ||
| sendConfirmationEmail: true, | ||
| }), | ||
| signal, | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error("فشل إرسال طلب التسجيل. يرجى المحاولة لاحقًا."); | ||
| } | ||
|
|
||
| return (await response.json()) as RegistrationResponse; | ||
| } |
Oops, something went wrong.
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.
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.
The confirm button only disables when the agreement checkbox is unchecked.
handleDialogConfirmsetsisSubmittingand awaitssubmitRegistration, but because this state is not passed to the dialog and the global loading overlay sits behind the dialog (z-40vsz-50), the button remains clickable while the network request is in flight. A user can double-click or repeatedly click during a slow response and trigger multiple registration requests and confirmation emails. Passing the submitting state to the dialog and disabling the button (or otherwise guarding against re-entry) would avoid duplicate submissions.Useful? React with 👍 / 👎.