mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-05-13 17:21:53 +00:00
Remove Birthdate from GettingStartForm.tsx
Took 5 minutes
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
import {Button, Flex, FormControl, Input} from '@chakra-ui/react';
|
|
||||||
import {useDispatch} from 'react-redux';
|
|
||||||
import {useState} from 'react';
|
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
const BirthInput = () => {
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
const [birth, setBirth] = useState('');
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Flex>
|
|
||||||
<FormControl>
|
|
||||||
<Input type={'date'} onChange={(evt) => setBirth(evt.target.value)}
|
|
||||||
value={birth}/>
|
|
||||||
</FormControl>
|
|
||||||
|
|
||||||
<FormControl>
|
|
||||||
<Button onClick={() => dispatch({
|
|
||||||
type: 'gettingStartForm/setInput',
|
|
||||||
payload: {
|
|
||||||
inputs: {'birth': moment(birth).toISOString()},
|
|
||||||
message: `Le ${moment(birth).format("ll")}.`, // TODO formate date
|
|
||||||
},
|
|
||||||
})}>Envoyer</Button>
|
|
||||||
</FormControl>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default BirthInput;
|
|
||||||
@@ -4,12 +4,11 @@ import {useSelector} from 'react-redux';
|
|||||||
import {RootState} from '@/redux/redux';
|
import {RootState} from '@/redux/redux';
|
||||||
import Message from '@/components/chat/Message';
|
import Message from '@/components/chat/Message';
|
||||||
import {Message as MessageType} from '@prisma/client';
|
import {Message as MessageType} from '@prisma/client';
|
||||||
|
|
||||||
import GenderInput from '@/components/form/GettingStartForm/GenderInput';
|
import GenderInput from '@/components/form/GettingStartForm/GenderInput';
|
||||||
import AgeInput from '@/components/form/GettingStartForm/AgeInput';
|
import AgeInput from '@/components/form/GettingStartForm/AgeInput';
|
||||||
import BirthInput from '@/components/form/GettingStartForm/BirthInput';
|
|
||||||
import PassionsInput from '@/components/form/GettingStartForm/PassionsInput';
|
import PassionsInput from '@/components/form/GettingStartForm/PassionsInput';
|
||||||
import SubmitGettingStartForm
|
import SubmitGettingStartForm from '@/components/form/GettingStartForm/SubmitGettingStartForm';
|
||||||
from '@/components/form/GettingStartForm/SubmitGettingStartForm';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: UserType
|
user: UserType
|
||||||
@@ -19,7 +18,6 @@ type FormInputs = {
|
|||||||
ownGender?: Gender
|
ownGender?: Gender
|
||||||
researchGender?: Gender,
|
researchGender?: Gender,
|
||||||
ages?: [number, number],
|
ages?: [number, number],
|
||||||
birth?: Date,
|
|
||||||
passions?: Passion[]
|
passions?: Passion[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,9 +29,8 @@ export default function GettingStartForm({user}: Props) {
|
|||||||
<GenderInput key={0} field={'ownGender'}/>,
|
<GenderInput key={0} field={'ownGender'}/>,
|
||||||
<GenderInput key={1} field={'researchGender'}/>,
|
<GenderInput key={1} field={'researchGender'}/>,
|
||||||
<AgeInput key={2}/>,
|
<AgeInput key={2}/>,
|
||||||
<BirthInput key={3}/>,
|
<PassionsInput key={3}/>,
|
||||||
<PassionsInput key={4}/>,
|
<SubmitGettingStartForm user={user} key={4}/>,
|
||||||
<SubmitGettingStartForm user={user} key={5}/>,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -10,13 +10,7 @@ export default function SubmitGettingStartForm({user}: { user: User }) {
|
|||||||
(state: RootState) => state.gettingStartForm);
|
(state: RootState) => state.gettingStartForm);
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
const {
|
const {ownGender, researchGender, ages, passions} = gettingStartForm.inputs;
|
||||||
ownGender,
|
|
||||||
researchGender,
|
|
||||||
ages,
|
|
||||||
birth,
|
|
||||||
passions,
|
|
||||||
} = gettingStartForm.inputs;
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -26,11 +20,8 @@ export default function SubmitGettingStartForm({user}: { user: User }) {
|
|||||||
prefGender: researchGender,
|
prefGender: researchGender,
|
||||||
ageMin: ages[0],
|
ageMin: ages[0],
|
||||||
ageMax: ages[1],
|
ageMax: ages[1],
|
||||||
birthdate: new Date(birth),
|
|
||||||
Passion: {
|
Passion: {
|
||||||
connect: passions.map((p: Passion) => {
|
connect: passions.map((p: Passion) => ({id: p.id})),
|
||||||
return {id: p.id};
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ const questions: string[] = [
|
|||||||
'Salut, je suis Cupibot. Il me manque quelques détails avant de terminer ton inscription. C\'est quoi ton sexe ?',
|
'Salut, je suis Cupibot. Il me manque quelques détails avant de terminer ton inscription. C\'est quoi ton sexe ?',
|
||||||
'Ok et tu es attiré par quel genre ?',
|
'Ok et tu es attiré par quel genre ?',
|
||||||
'Ça marche, c\'est quoi la tranche d\'âge que tu recherche ?',
|
'Ça marche, c\'est quoi la tranche d\'âge que tu recherche ?',
|
||||||
'D\'ailleurs je ne t\'ai pas demandé, quand est-ce que tu est né ?',
|
|
||||||
'T\'as des passions dans la vie ? (Choisis-en 3 minimum)',
|
'T\'as des passions dans la vie ? (Choisis-en 3 minimum)',
|
||||||
'Ok j\'ai toutes les infos d\'on j\'ai besoin, je vais tout faire pour te faire trouver la personne qui te correspond!',
|
'Ok j\'ai toutes les infos d\'on j\'ai besoin, je vais tout faire pour te faire trouver la personne qui te correspond!',
|
||||||
];
|
];
|
||||||
@@ -19,7 +18,6 @@ const gettingStartFormSlice = createSlice({
|
|||||||
ownGender: Gender.UNKNOWN,
|
ownGender: Gender.UNKNOWN,
|
||||||
researchGender: Gender.UNKNOWN,
|
researchGender: Gender.UNKNOWN,
|
||||||
ages: [18, 25],
|
ages: [18, 25],
|
||||||
birth: "",
|
|
||||||
passions: [],
|
passions: [],
|
||||||
},
|
},
|
||||||
messages: [
|
messages: [
|
||||||
|
|||||||
Reference in New Issue
Block a user