File size: 4,305 Bytes
6218385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b812380
6218385
b812380
6218385
 
 
b812380
d6e2b5a
 
6218385
 
d6e2b5a
6218385
 
 
 
 
 
d6e2b5a
 
6218385
 
 
 
 
 
 
b812380
6218385
 
 
 
 
b812380
6218385
 
 
b812380
6218385
 
 
 
 
 
 
b812380
6218385
 
 
b812380
6218385
 
 
 
 
 
b812380
6218385
 
 
 
 
 
 
 
 
 
 
 
 
b812380
6218385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b812380
6218385
d6e2b5a
6218385
d6e2b5a
6218385
 
b812380
6218385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d6e2b5a
6218385
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/**
 * Profile Success Screen Component
 * 
 * GPay-like success animation shown after health profile form submission.
 * Features animated checkmark, success message, and navigation options.
 */
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { motion } from 'framer-motion';
import { Check, ArrowRight } from 'lucide-react';
import './ProfileSuccessScreen.css';

interface ProfileSuccessScreenProps {
  autoRedirect?: boolean;
  redirectDelay?: number;
}

export default function ProfileSuccessScreen({
  autoRedirect = true,
  redirectDelay = 2000
}: ProfileSuccessScreenProps) {
  const navigate = useNavigate();

  useEffect(() => {
    // Profile sync is now handled by the Features page which shows a
    // live sync overlay.  We just redirect there after the success animation.
    if (autoRedirect) {
      const timer = setTimeout(() => {
        navigate('/features', { state: { fromProfileSync: true } });
      }, redirectDelay);

      return () => clearTimeout(timer);
    }
  }, [autoRedirect, redirectDelay, navigate]);

  const handleFeatures = () => {
    navigate('/features', { state: { fromProfileSync: true } });
  };

  const handleSettings = () => {
    navigate('/settings');
  };

  return (
    <motion.div
      className="profile-success-overlay"
      initial={{ opacity: 0 }}
      animate={{ opacity: 1 }}
      exit={{ opacity: 0 }}
    >
      <motion.div
        className="profile-success-container"
        initial={{ scale: 0.8, opacity: 0 }}
        animate={{ scale: 1, opacity: 1 }}
        transition={{
          type: "spring",
          stiffness: 200,
          damping: 20,
          delay: 0.1
        }}
      >
        {/* Animated Checkmark */}
        <motion.div
          className="success-checkmark-container"
          initial={{ scale: 0 }}
          animate={{ scale: 1 }}
          transition={{
            type: "spring",
            stiffness: 300,
            damping: 15,
            delay: 0.2
          }}
        >
          <motion.div
            className="success-checkmark-circle"
            initial={{ scale: 0, rotate: -180 }}
            animate={{ scale: 1, rotate: 0 }}
            transition={{ duration: 0.4, delay: 0.2 }}
          >
            <motion.div
              initial={{ scale: 0, opacity: 0 }}
              animate={{ scale: 1, opacity: 1 }}
              transition={{ duration: 0.3, delay: 0.5 }}
            >
              <Check size={48} strokeWidth={3} />
            </motion.div>
          </motion.div>

          {/* Ripple effect */}
          <motion.div
            className="success-ripple"
            initial={{ scale: 0.8, opacity: 0.8 }}
            animate={{ scale: 2, opacity: 0 }}
            transition={{ duration: 1, delay: 0.3 }}
          />
        </motion.div>

        {/* Success Message */}
        <motion.div
          className="success-message"
          initial={{ opacity: 0, y: 20 }}
          animate={{ opacity: 1, y: 0 }}
          transition={{ delay: 0.6, duration: 0.4 }}
        >
          <h2 className="success-title">Saved!</h2>
          <p className="success-description">
            Your health profile has been updated.
          </p>
        </motion.div>

        {/* Action Buttons */}
        <motion.div
          className="success-actions"
          initial={{ opacity: 0, y: 20 }}
          animate={{ opacity: 1, y: 0 }}
          transition={{ delay: 0.8, duration: 0.4 }}
        >
          <button
            className="success-btn success-btn-primary"
            onClick={handleFeatures}
          >
            View Health Intelligence
            <ArrowRight size={18} />
          </button>
          <button
            className="success-btn success-btn-secondary"
            onClick={handleSettings}
          >
            Edit in Settings
          </button>
        </motion.div>

        {/* Auto-redirect indicator */}
        {autoRedirect && (
          <motion.p
            className="success-auto-redirect"
            initial={{ opacity: 0 }}
            animate={{ opacity: 1 }}
            transition={{ delay: 1, duration: 0.3 }}
          >
            Redirecting to Health Intelligence...
          </motion.p>
        )}
      </motion.div>
    </motion.div>
  );
}