Skip to content
Extraits de code Groupes Projets
Valider 81c1d4b2 rédigé par oussama aftys's avatar oussama aftys
Parcourir les fichiers

changed logo

parent 54093d58
Branches
1 requête de fusion!119changed logo
Pipeline #2178 réussi avec l'étape
in 4 minutes et 10 secondes
public/logo/logo_single.png

7,38 ko | W: | H:

public/logo/logo_single.png

274 ko | W: | H:

public/logo/logo_single.png
public/logo/logo_single.png
public/logo/logo_single.png
public/logo/logo_single.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -2,11 +2,12 @@
import { useMemo, useEffect, useReducer, useCallback } from 'react';
import axios, { endpoints } from '@/utils/axios';
import { AuthContext } from './auth-context';
import { setSession, isValidToken } from './utils';
import { AuthUserType, ActionMapType, AuthStateType } from '../types';
import axios, { endpoints } from '@/utils/axios';
// ----------------------------------------------------------------------
/**
......@@ -75,13 +76,37 @@ const reducer = (state: AuthStateType, action: ActionsType) => {
// ----------------------------------------------------------------------
const STORAGE_KEY = 'accessToken';
type Props = {
children: React.ReactNode;
};
const STORAGE_KEY = 'accessToken';
export const JWT_SECRET = 'minimal-secret-key';
export const JWT_EXPIRES_IN = '3 days';
export const users = [
{
id: '8864c717-587d-472a-929a-8e5f298024da-1',
displayName: 'Jaydon Frankie',
email: 'admin@mydressin.com',
password: 'admin1234',
photoURL: `assets/images/avatars/avatar_default.jpg`,
phoneNumber: '+40 777666555',
country: 'United States',
address: '90210 Broadway Blvd',
state: 'California',
city: 'San Francisco',
zipCode: '94116',
about: 'Praesent turpis. Phasellus viverra nulla ut metus varius laoreet. Phasellus tempus.',
role: 'admin',
isPublic: true,
}
];
export function AuthProvider({ children }: Props) {
const [state, dispatch] = useReducer(reducer, initialState);
const initialize = useCallback(async () => {
......@@ -90,9 +115,7 @@ export function AuthProvider({ children }: Props) {
if (accessToken && isValidToken(accessToken)) {
setSession(accessToken);
const res = await axios.get(endpoints.auth.me);
const { user } = res.data;
dispatch({
......@@ -127,31 +150,50 @@ export function AuthProvider({ children }: Props) {
initialize();
}, [initialize]);
// LOGIN
const login = useCallback(async (email: string, password: string) => {
const data = {
email,
password,
};
const login = useCallback(async (email: string, password: string): Promise<void> => {
console.log("Attempting login with email:", email);
const res = await axios.post(endpoints.auth.login, data);
const user = users.find(u => u.email === email && u.password === password);
const { accessToken, user } = res.data;
if (user) {
console.log("User found:", user);
setSession(accessToken);
const accessToken = sessionStorage.getItem(STORAGE_KEY);
console.log("Access token retrieved from session storage:", accessToken);
dispatch({
type: Types.LOGIN,
payload: {
user: {
...user,
accessToken,
setSession(accessToken);
dispatch({
type: Types.LOGIN,
payload: {
user: {
...user,
accessToken,
},
},
},
});
console.log("Login successful");
return Promise.resolve();
} else {
console.log("Invalid email or password");
throw new Error("Invalid email or password");
}
}, []);
//LOGOUT
const logout = useCallback(async () => {
setSession(null);
dispatch({
type: Types.LOGOUT,
});
}, []);
// REGISTER
const checkAuthenticated = state.user ? 'authenticated' : 'unauthenticated';
const status = state.loading ? 'loading' : checkAuthenticated;
const register = useCallback(
async (email: string, password: string, firstName: string, lastName: string) => {
const data = {
......@@ -179,21 +221,6 @@ export function AuthProvider({ children }: Props) {
},
[]
);
// LOGOUT
const logout = useCallback(async () => {
setSession(null);
dispatch({
type: Types.LOGOUT,
});
}, []);
// ----------------------------------------------------------------------
const checkAuthenticated = state.user ? 'authenticated' : 'unauthenticated';
const status = state.loading ? 'loading' : checkAuthenticated;
const memoizedValue = useMemo(
() => ({
user: state.user,
......@@ -207,6 +234,7 @@ export function AuthProvider({ children }: Props) {
logout,
}),
[login, logout, register, state.user, status]
);
return <AuthContext.Provider value={memoizedValue}>{children}</AuthContext.Provider>;
......
......@@ -34,50 +34,10 @@ const Logo = forwardRef<HTMLDivElement, LogoProps>(
const logo = (
<Box
ref={ref}
component="div"
sx={{
width: 40,
height: 40,
display: 'inline-flex',
...sx,
}}
{...other}
>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 512 512">
<defs>
<linearGradient id="BG1" x1="100%" x2="50%" y1="9.946%" y2="50%">
<stop offset="0%" stopColor={PRIMARY_DARK} />
<stop offset="100%" stopColor={PRIMARY_MAIN} />
</linearGradient>
<linearGradient id="BG2" x1="50%" x2="50%" y1="0%" y2="100%">
<stop offset="0%" stopColor={PRIMARY_LIGHT} />
<stop offset="100%" stopColor={PRIMARY_MAIN} />
</linearGradient>
<linearGradient id="BG3" x1="50%" x2="50%" y1="0%" y2="100%">
<stop offset="0%" stopColor={PRIMARY_LIGHT} />
<stop offset="100%" stopColor={PRIMARY_MAIN} />
</linearGradient>
</defs>
<g fill={PRIMARY_MAIN} fillRule="evenodd" stroke="none" strokeWidth="1">
<path
fill="url(#BG1)"
d="M183.168 285.573l-2.918 5.298-2.973 5.363-2.846 5.095-2.274 4.043-2.186 3.857-2.506 4.383-1.6 2.774-2.294 3.939-1.099 1.869-1.416 2.388-1.025 1.713-1.317 2.18-.95 1.558-1.514 2.447-.866 1.38-.833 1.312-.802 1.246-.77 1.18-.739 1.111-.935 1.38-.664.956-.425.6-.41.572-.59.8-.376.497-.537.69-.171.214c-10.76 13.37-22.496 23.493-36.93 29.334-30.346 14.262-68.07 14.929-97.202-2.704l72.347-124.682 2.8-1.72c49.257-29.326 73.08 1.117 94.02 40.927z"
/>
<path
fill="url(#BG2)"
d="M444.31 229.726c-46.27-80.956-94.1-157.228-149.043-45.344-7.516 14.384-12.995 42.337-25.267 42.337v-.142c-12.272 0-17.75-27.953-25.265-42.337C189.79 72.356 141.96 148.628 95.69 229.584c-3.483 6.106-6.828 11.932-9.69 16.996 106.038-67.127 97.11 135.667 184 137.278V384c86.891-1.611 77.962-204.405 184-137.28-2.86-5.062-6.206-10.888-9.69-16.994"
/>
<path
fill="url(#BG3)"
d="M450 384c26.509 0 48-21.491 48-48s-21.491-48-48-48-48 21.491-48 48 21.491 48 48 48"
/>
</g>
</svg>
</Box>
component="img"
src="/logo/logo_single.png"
sx={{ height: 40, width:100, cursor: 'pointer', ...sx }}
/>
);
if (disabledLink) {
......
......@@ -93,25 +93,7 @@ export default function AccountPopover() {
</IconButton>
<CustomPopover open={popover.open} onClose={popover.onClose} sx={{ width: 200, p: 0 }}>
<Box sx={{ p: 2, pb: 1.5 }}>
<Typography variant="subtitle2" noWrap>
{user?.displayName}
</Typography>
<Typography variant="body2" sx={{ color: 'text.secondary' }} noWrap>
{user?.email}
</Typography>
</Box>
<Divider sx={{ borderStyle: 'dashed' }} />
<Stack sx={{ p: 1 }}>
{OPTIONS.map((option) => (
<MenuItem key={option.label} onClick={() => handleClickItem(option.linkTo)}>
{option.label}
</MenuItem>
))}
</Stack>
<Divider sx={{ borderStyle: 'dashed' }} />
......
......@@ -65,8 +65,6 @@ export default function Header({ onOpenNav }: Props) {
<NotificationsPopover />
<ContactsPopover />
<SettingsButton />
<AccountPopover />
......
......@@ -63,7 +63,6 @@ export default function NavVertical({ openNav, onCloseNav }: Props) {
<Box sx={{ flexGrow: 1 }} />
<NavUpgrade />
</Scrollbar>
);
......
......@@ -13,8 +13,6 @@ import Typography from '@mui/material/Typography';
import LoadingButton from '@mui/lab/LoadingButton';
import InputAdornment from '@mui/material/InputAdornment';
import { paths } from '@/routes/paths';
import RouterLink from '@/routes/router-link';
import { useRouter, useSearchParams } from '@/hooks';
import { useBoolean } from '@/hooks';
......@@ -46,8 +44,8 @@ export default function JwtLoginView() {
});
const defaultValues = {
email: 'demo@minimals.cc',
password: 'demo1234',
email: 'admin@mydressin.com',
password: 'admin1234',
};
const methods = useForm({
......@@ -75,15 +73,15 @@ export default function JwtLoginView() {
const renderHead = (
<Stack spacing={2} sx={{ mb: 5 }}>
<Typography variant="h4">Sign in to Minimal</Typography>
<Typography variant="h4">Sign in </Typography>
<Stack direction="row" spacing={0.5}>
{/* <Stack direction="row" spacing={0.5}>
<Typography variant="body2">New user?</Typography>
<Link component={RouterLink} href={paths.auth.jwt.register} variant="subtitle2">
Create an account
</Link>
</Stack>
</Stack> */}
</Stack>
);
......@@ -106,9 +104,9 @@ export default function JwtLoginView() {
}}
/>
<Link variant="body2" color="inherit" underline="always" sx={{ alignSelf: 'flex-end' }}>
{/* <Link variant="body2" color="inherit" underline="always" sx={{ alignSelf: 'flex-end' }}>
Forgot password?
</Link>
</Link> */}
<LoadingButton
fullWidth
......@@ -127,9 +125,9 @@ export default function JwtLoginView() {
<>
{renderHead}
<Alert severity="info" sx={{ mb: 3 }}>
{/* <Alert severity="info" sx={{ mb: 3 }}>
Use email : <strong>demo@minimals.cc</strong> / password :<strong> demo1234</strong>
</Alert>
</Alert> */}
{!!errorMsg && (
<Alert severity="error" sx={{ mb: 3 }}>
......
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter