Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Master #400

Merged
merged 1 commit into from
Oct 3, 2024
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: 3 additions & 0 deletions src/app/(dashboard)/admin/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Settings = () => {
const loginAllowed = useAppSelector((state) => state.settings.login);
const shopAllowed = useAppSelector((state) => state.settings.shop);
const trombiAllowed = useAppSelector((state) => state.settings.trombi);
const ticketsAllowed = useAppSelector((state) => state.settings.tickets);

const changeSetting = (setting: string, value: boolean) => {
// TODO: add confirmation modal
Expand All @@ -18,12 +19,14 @@ const Settings = () => {
const changeLogin = (value: boolean) => changeSetting('login', value);
const changeShop = (value: boolean) => changeSetting('shop', value);
const changeTrombi = (value: boolean) => changeSetting('trombi', value);
const changeTickets = (value: boolean) => changeSetting('tickets', value);

return (
<div className={styles.settings}>
<Checkbox label="Autoriser le login" onChange={changeLogin} value={loginAllowed} />
<Checkbox label="Autoriser la boutique" onChange={changeShop} value={shopAllowed} />
<Checkbox label="Autoriser le trombi" onChange={changeTrombi} value={trombiAllowed} />
<Checkbox label="Autoriser l'affichage des billets" onChange={changeTickets} value={ticketsAllowed} />
</div>
);
};
Expand Down
24 changes: 13 additions & 11 deletions src/app/(dashboard)/dashboard/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Account = () => {
const dispatch = useAppDispatch();
const user = useAppSelector((state) => state.login.user)!;
const team = useAppSelector((state) => state.team.team);
const areTicketsAllowed = useAppSelector((state) => state.settings.tickets);

const [firstname, setFirstname] = useState(user.firstname);
const [lastname, setLastname] = useState(user.lastname);
Expand All @@ -36,7 +37,8 @@ const Account = () => {

useEffect(() => {
setDisplayTicket(
(user.hasPaid &&
(areTicketsAllowed &&
user.hasPaid &&
((user.type !== UserType.coach && user.type !== UserType.player) || (team && team.lockedAt))) as boolean,
);
}, [team]);
Expand Down Expand Up @@ -79,15 +81,15 @@ const Account = () => {
}
};

// const downloadTicket = async () => {
// const response = await API.get(`tickets`);
const downloadTicket = async () => {
const response = await API.get(`tickets`);

// const data = window.URL.createObjectURL(response);
// const link = document.createElement('a');
// link.href = data;
// link.download = 'Billet UTT Arena 2024.pdf';
// link.click();
// };
const data = window.URL.createObjectURL(response);
const link = document.createElement('a');
link.href = data;
link.download = 'Billet UTT Arena 2024.pdf';
link.click();
};

return (
<div id="dashboard-account" className={styles.dashboardAccount}>
Expand Down Expand Up @@ -153,7 +155,7 @@ const Account = () => {
</Button>
</a>
</div>
{/* {displayTicket && (
{displayTicket && (
<div className={styles.ticket}>
<Title level={4} align="center">
Mon billet
Expand All @@ -162,7 +164,7 @@ const Account = () => {
Télécharger mon billet
</Button>
</div>
)} */}
)}
</div>
{displayTicket && (
<div className="to-bring">
Expand Down
2 changes: 2 additions & 0 deletions src/modules/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const initialState: Settings = {
login: false,
shop: false,
trombi: false,
tickets: false,
};

export const settingsSlice = createSlice({
Expand Down Expand Up @@ -34,6 +35,7 @@ export const fetchSettings = (): AppThunk => async (dispatch) => {
login: false,
shop: false,
trombi: false,
tickets: false,
}),
);
}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Settings {
login: boolean;
shop: boolean;
trombi: boolean;
tickets: boolean;
}

export interface RegisterUser {
Expand Down
Loading