Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion guard_app/src/screen/ActiveSOSScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default function ActiveSOSScreen() {
const lastPushedAtRef = useRef<number>(0);
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
const cancelTickRef = useRef<ReturnType<typeof setInterval> | null>(null);
const cancelDeadlineRef = useRef<number>(Date.now() + CANCEL_GRACE_MS);
const [initialDeadline] = useState(() => Date.now() + CANCEL_GRACE_MS);
const cancelDeadlineRef = useRef<number>(initialDeadline);
const mountedRef = useRef(true);

const closeError = useCallback(() => setErrorState(null), []);
Expand Down
46 changes: 18 additions & 28 deletions guard_app/src/screen/EditProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,21 @@ export default function EditProfileScreen({ navigation, route }: EditProfileScre

const [loading, setLoading] = useState(false);
const [profileImage, setProfileImage] = useState<string | null>(null);
const [licenseImage, setLicenseImage] = useState<string | null>(null);
const profile = route?.params?.userProfile;

const [formData, setFormData] = useState({
name: '',
email: '',
phone: '',
street: '',
suburb: '',
state: '',
postcode: '',
name: profile?.name || '',
email: profile?.email || '',
phone: profile?.phone || '',
street: profile?.address?.street || '',
suburb: profile?.address?.suburb || '',
state: profile?.address?.state || '',
postcode: profile?.address?.postcode || '',
});

useEffect(() => {
if (route?.params?.userProfile) {
const profile = route.params.userProfile;
setFormData({
name: profile.name || '',
email: profile.email || '',
phone: profile.phone || '',
street: profile.address?.street || '',
suburb: profile.address?.suburb || '',
state: profile.address?.state || '',
postcode: profile.address?.postcode || '',
});

if (profile.license?.imageUrl) {
setLicenseImage(API_BASE_URL + profile.license.imageUrl);
}

loadProfileImage();
}
}, [route?.params?.userProfile]);
const [licenseImage, setLicenseImage] = useState<string | null>(
profile?.license?.imageUrl ? API_BASE_URL + profile.license.imageUrl : null,
);

const loadProfileImage = async () => {
try {
Expand All @@ -81,6 +65,12 @@ export default function EditProfileScreen({ navigation, route }: EditProfileScre
}
};

useEffect(() => {
const init = async () => {
await loadProfileImage();
};
init();
}, []);
const handleInputChange = (field: string, value: string) => {
setFormData((prev) => ({
...prev,
Expand Down
21 changes: 14 additions & 7 deletions guard_app/src/screen/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function ProfileScreen({ navigation, route }: any) {
};

const loadProfileData = async () => {
await Promise.resolve();
try {
setLoading(true);
setError(null);
Expand All @@ -60,16 +61,22 @@ export default function ProfileScreen({ navigation, route }: any) {
};

useEffect(() => {
loadProfileData();
loadProfileImage();
const init = async () => {
loadProfileData();
loadProfileImage();
};
init();
}, []);

useEffect(() => {
if (route?.params?.refresh) {
loadProfileData();
loadProfileImage();
navigation.setParams({ refresh: false });
}
const init = async () => {
if (route?.params?.refresh) {
loadProfileData();
loadProfileImage();
navigation.setParams({ refresh: false });
}
};
init();
}, [navigation, route?.params?.refresh]);

const getStatusBadgeStyle = (status: LicenseStatus) => {
Expand Down
Loading