From 713d169915a82edfcfe4b44622e3dce8c6adaf0c Mon Sep 17 00:00:00 2001
From: Shravya Ramesh <37447613+shravyaramesh@users.noreply.github.com>
Date: Tue, 17 Nov 2020 18:06:14 -0800
Subject: [TMA-382] Edit profile screen (#121)

* added more icon

* a less fat icon

* and the actual icon asset

* bottom drawer skeleton done

* removed warning, better code

* a more completed skeleton done

* bottom drawer done!

* Added content container,  sent birthday picker props, minor styling

* differenciating defined and undefined birthdate in birthdate, datepicker

* removed restricting width for TaggDropDown

* Added edit profile screen to navigator stack

* Add EditProfile view, refresh profile view on save

* Removes unnecessary import

* Stores gender and birthdate as part of ProfileType

* Added gender, birthdate, isEditProfile to AuthProv

* Conditional view applied for edit profile button

* Includes discarded changes in previous merge- BD

* removed unused icon

* resolved scary warnings

* added icon to drawer

* Small fix

* minor code improvement

* sc

* fixed birthday bug

* custom gender updation fixed

* small change to birthday default value

* missed something

* cleaned up types! Warnings gone!

* fixed another gender picker bug

* fixed gender bug and cleaned up logic

* removed warning, MUCH better code now

Co-authored-by: Ivan Chen <ivan@thetaggid.com>
Co-authored-by: Ashm Walia <ashmwalia@outlook.com>
---
 src/components/common/TaggDatePicker.tsx | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

(limited to 'src/components/common/TaggDatePicker.tsx')

diff --git a/src/components/common/TaggDatePicker.tsx b/src/components/common/TaggDatePicker.tsx
index d8010251..059bf620 100644
--- a/src/components/common/TaggDatePicker.tsx
+++ b/src/components/common/TaggDatePicker.tsx
@@ -1,3 +1,4 @@
+import moment from 'moment';
 import React, {useState} from 'react';
 import DatePicker from 'react-native-date-picker';
 
@@ -5,23 +6,24 @@ interface TaggDatePickerProps {
   handleDateUpdate: (_: Date) => void;
   maxDate: Date;
   textColor: string;
+  date: Date | undefined;
 }
 
-const TaggDatePicker: React.FC<TaggDatePickerProps> = ({
-  handleDateUpdate,
-  maxDate,
-  textColor,
-}) => {
-  const [date, setDate] = useState(new Date());
+const TaggDatePicker: React.FC<TaggDatePickerProps> = (props) => {
+  const [date, setDate] = useState(
+    props.date
+      ? new Date(moment(props.date).add(1, 'day').format('YYYY-MM-DD'))
+      : undefined,
+  );
   return (
     <DatePicker
-      date={date}
-      textColor={textColor}
+      date={date ? date : props.maxDate}
+      textColor={props.textColor}
       mode={'date'}
-      maximumDate={maxDate}
+      maximumDate={props.maxDate}
       onDateChange={(newDate) => {
         setDate(newDate);
-        handleDateUpdate(newDate);
+        props.handleDateUpdate(newDate);
       }}
     />
   );
-- 
cgit v1.2.3-70-g09d2

