Browse Source

feat: implement profile section listing and synchronization logic with match start trigger

Dev
ghorbani 1 week ago
parent
commit
55c9dc5473
  1. 2
      src/app/questions-list/page.tsx
  2. 38
      src/components/Componentes/question-date.tsx
  3. 2
      src/hooks/marriage/use-match-start.ts

2
src/app/questions-list/page.tsx

@ -225,7 +225,7 @@ export default function QuestionsListPage() {
} }
} }
await queryClient.invalidateQueries();
queryClient.invalidateQueries();
startMatchMutation.mutate(); startMatchMutation.mutate();
} catch (err) { } catch (err) {
console.error("Failed to sync pending sections:", err); console.error("Failed to sync pending sections:", err);

38
src/components/Componentes/question-date.tsx

@ -12,19 +12,19 @@ type QuestionDateProps = {
disabled?: boolean; disabled?: boolean;
}; };
const MONTHS = [
{ value: "01", label: "01 - January" },
{ value: "02", label: "02 - February" },
{ value: "03", label: "03 - March" },
{ value: "04", label: "04 - April" },
{ value: "05", label: "05 - May" },
{ value: "06", label: "06 - June" },
{ value: "07", label: "07 - July" },
{ value: "08", label: "08 - August" },
{ value: "09", label: "09 - September" },
{ value: "10", label: "10 - October" },
{ value: "11", label: "11 - November" },
{ value: "12", label: "12 - December" },
const MONTH_VALUES = [
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
"11",
"12",
]; ];
const DAYS = Array.from({ length: 31 }, (_, i) => { const DAYS = Array.from({ length: 31 }, (_, i) => {
@ -50,6 +50,16 @@ export function QuestionDate({
const value = getAnswerValue(question, questionIndex); const value = getAnswerValue(question, questionIndex);
const dateValue = typeof value === "string" ? value : ""; const dateValue = typeof value === "string" ? value : "";
const months = useMemo(() => {
return MONTH_VALUES.map((val, idx) => {
const date = new Date(2000, idx, 15);
const label = new Intl.DateTimeFormat(`${locale}-u-ca-gregory`, {
month: "long",
}).format(date);
return { value: val, label };
});
}, [locale]);
const [selectedYear, setSelectedYear] = useState(() => { const [selectedYear, setSelectedYear] = useState(() => {
const parts = dateValue ? dateValue.split("-") : []; const parts = dateValue ? dateValue.split("-") : [];
return parts[0] || ""; return parts[0] || "";
@ -170,7 +180,7 @@ export function QuestionDate({
className="h-[54px] w-full cursor-pointer rounded-[16px] border border-[#D0D5DD] bg-white px-3 text-[15px] font-medium text-[#181818] outline-none transition-all hover:border-[#98A2B3] focus:border-[#6F6F6F] focus:ring-1 focus:ring-[#6F6F6F]" className="h-[54px] w-full cursor-pointer rounded-[16px] border border-[#D0D5DD] bg-white px-3 text-[15px] font-medium text-[#181818] outline-none transition-all hover:border-[#98A2B3] focus:border-[#6F6F6F] focus:ring-1 focus:ring-[#6F6F6F]"
> >
<option value="">Month</option> <option value="">Month</option>
{MONTHS.map((m) => (
{months.map((m) => (
<option key={m.value} value={m.value}> <option key={m.value} value={m.value}>
{m.label} {m.label}
</option> </option>

2
src/hooks/marriage/use-match-start.ts

@ -23,7 +23,7 @@ export function useStartMarriageMatchMutation(
...options, ...options,
mutationFn: startMarriageMatch, mutationFn: startMarriageMatch,
onSuccess: async (data, variables, onMutateResult, context) => { onSuccess: async (data, variables, onMutateResult, context) => {
await Promise.all([
Promise.all([
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: marriageQueryKeys.profile(), queryKey: marriageQueryKeys.profile(),
}), }),

Loading…
Cancel
Save