From 6fb5e2017039930d97759d1d5fc1a3fcceb9ffe3 Mon Sep 17 00:00:00 2001 From: amir-kedis Date: Wed, 27 Dec 2023 09:13:44 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20breaking=20chan?= =?UTF-8?q?ges=20with=20api=20bodies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/common/InfoSection.jsx | 6 ++++- .../src/components/common/TermInfoSection.jsx | 24 +++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/client/src/components/common/InfoSection.jsx b/client/src/components/common/InfoSection.jsx index add8ae5b..c2912a34 100644 --- a/client/src/components/common/InfoSection.jsx +++ b/client/src/components/common/InfoSection.jsx @@ -22,6 +22,10 @@ export default function InfoSection() { const { data: budget, isFetching: isFetchingBudget } = useGetBudgetQuery(); + if (budget && !isFetchingBudget) console.log(budget); + if (absenceRate && !isFetchingAbsence) console.log(absenceRate); + if (scouts && !isFetchingScoutsCount) console.log(scouts); + return ( <> diff --git a/client/src/components/common/TermInfoSection.jsx b/client/src/components/common/TermInfoSection.jsx index f3b93b87..7a740a54 100644 --- a/client/src/components/common/TermInfoSection.jsx +++ b/client/src/components/common/TermInfoSection.jsx @@ -13,11 +13,15 @@ export default function TermInfoSection() { const { data: weeksLeft, isFetching: isFetchingWeeksLeft } = useGetRemainingWeeksQuery(); - console.log({ - termInfo, - curWeek, - weeksLeft, - }); + if ( + termInfo && + !isFetchingTerm && + curWeek && + !isFetchingWeek && + weeksLeft && + !isFetchingWeeksLeft + ) + console.log({ termInfo, curWeek, weeksLeft }); return (
- + From c44fe65cfd371cd06a5a2e98630ad588e5a186c3 Mon Sep 17 00:00:00 2001 From: amir-kedis Date: Wed, 27 Dec 2023 09:23:02 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=92=85=20fix:=20small=20fix=20in=20di?= =?UTF-8?q?rection=20of=20landing=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/landingpage/LandingPage.scss | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/components/landingpage/LandingPage.scss b/client/src/components/landingpage/LandingPage.scss index c2c041fc..5aa5c80c 100644 --- a/client/src/components/landingpage/LandingPage.scss +++ b/client/src/components/landingpage/LandingPage.scss @@ -1,5 +1,6 @@ .landing_page { --icon-size: 32px; + direction: rtl; .hero { padding-block: 60px; @@ -24,7 +25,7 @@ justify-content: center; gap: 20px; - >* { + > * { min-width: 70%; } } @@ -59,7 +60,7 @@ .icon { color: var(--primary-100); - >* { + > * { width: var(--icon-size); height: var(--icon-size); } @@ -77,4 +78,4 @@ display: flex; justify-content: center; align-items: center; -} \ No newline at end of file +} From 2eb4fa8ffabebb2f0240106c45b7e596230bb383 Mon Sep 17 00:00:00 2001 From: amir-kedis Date: Wed, 27 Dec 2023 09:27:45 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=94=A5=20chore:=20enhance=20the=20loo?= =?UTF-8?q?k=20of=20the=20dropdown=20in=20insert=20sector=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/assets/styles/components/Inputs.scss | 4 ++++ client/src/components/insert-sector/InsertSector.jsx | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/assets/styles/components/Inputs.scss b/client/src/assets/styles/components/Inputs.scss index d89f3fd1..1cabe062 100644 --- a/client/src/assets/styles/components/Inputs.scss +++ b/client/src/assets/styles/components/Inputs.scss @@ -32,4 +32,8 @@ line-height: 1rem; color: var(--grey-100); } + + select { + direction: rtl; + } } diff --git a/client/src/components/insert-sector/InsertSector.jsx b/client/src/components/insert-sector/InsertSector.jsx index e071e094..c9f43421 100644 --- a/client/src/components/insert-sector/InsertSector.jsx +++ b/client/src/components/insert-sector/InsertSector.jsx @@ -79,7 +79,10 @@ export default function InsertSector() { required /> ({ + ...captain, + text: captain?.firstName + " " + captain?.middleName + " " + captain?.lastName, + }))} label="قائد القطاع" name="unitSectorLeader" selectedValue={unitSectorLeader} @@ -87,7 +90,7 @@ export default function InsertSector() { setUnitSectorLeader(e.target.value); }} required - displayMember="firstName" + displayMember="text" valueMember="captainId" /> {isFetching && ( From a536272c17a59ff89a38adc29668a691b15fb759 Mon Sep 17 00:00:00 2001 From: amir-kedis Date: Wed, 27 Dec 2023 09:50:39 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A7=AFfeat:=20make=20tags=20for=20aut?= =?UTF-8?q?omatic=20update=20in=20UI=20and=20global=20states?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/TermInfoSection.jsx | 13 ++++++---- client/src/redux/slices/apiSlice.js | 16 +++++++++++- client/src/redux/slices/captainsApiSlice.js | 2 ++ client/src/redux/slices/financeApiSlice.js | 1 + client/src/redux/slices/scoutApiSlice.js | 1 + client/src/redux/slices/scoutsSlice.js | 26 ------------------- client/src/redux/slices/sectorApiSlice.js | 2 ++ client/src/redux/slices/statsApiSlice.js | 1 + client/src/redux/slices/termApiSlice.js | 5 ++++ client/src/redux/slices/usersApiSlice.js | 2 ++ 10 files changed, 37 insertions(+), 32 deletions(-) delete mode 100644 client/src/redux/slices/scoutsSlice.js diff --git a/client/src/components/common/TermInfoSection.jsx b/client/src/components/common/TermInfoSection.jsx index 7a740a54..bf2f926b 100644 --- a/client/src/components/common/TermInfoSection.jsx +++ b/client/src/components/common/TermInfoSection.jsx @@ -10,8 +10,11 @@ import InfoBox from "./InfoBox"; export default function TermInfoSection() { const { data: termInfo, isFetching: isFetchingTerm } = useGetCurTermQuery(); const { data: curWeek, isFetching: isFetchingWeek } = useGetCurWeekQuery(); - const { data: weeksLeft, isFetching: isFetchingWeeksLeft } = - useGetRemainingWeeksQuery(); + const { + data: weeksLeft, + isFetching: isFetchingWeeksLeft, + isLoading, + } = useGetRemainingWeeksQuery(); if ( termInfo && @@ -36,7 +39,7 @@ export default function TermInfoSection() { color="colorful" title="اسم الفترة" value={ - isFetchingTerm + isFetchingTerm || isLoading ? "جاري التحميل" : !termInfo ? "لا يوجد بيانات" @@ -47,7 +50,7 @@ export default function TermInfoSection() { color="dark" title="الاسبوع الحالي" value={ - isFetchingWeek + isFetchingWeek || isLoading ? "جاري التحميل" : !curWeek ? "0" @@ -58,7 +61,7 @@ export default function TermInfoSection() { color="dark" title="الاسابيع الباقية" value={ - isFetchingWeeksLeft + isFetchingWeeksLeft || isLoading ? "جاري التحميل" : !weeksLeft ? "0" diff --git a/client/src/redux/slices/apiSlice.js b/client/src/redux/slices/apiSlice.js index cadab8ab..c539299b 100644 --- a/client/src/redux/slices/apiSlice.js +++ b/client/src/redux/slices/apiSlice.js @@ -10,6 +10,20 @@ const baseQuery = fetchBaseQuery({ baseUrl }); export const apiSlice = createApi({ baseQuery, - tagTypes: ["Scouts"], + tagTypes: [ + "Scouts", + "Terms", + "Weeks", + "Captains", + "Units", + "finance", + "absence", + "attendance", + "events", + "reports", + "users", + "auth", + "sector", + ], endpoints: () => ({}), }); diff --git a/client/src/redux/slices/captainsApiSlice.js b/client/src/redux/slices/captainsApiSlice.js index 44d97987..0d22963d 100644 --- a/client/src/redux/slices/captainsApiSlice.js +++ b/client/src/redux/slices/captainsApiSlice.js @@ -9,12 +9,14 @@ export const captainsApi = apiSlice.injectEndpoints({ url: `${CAPTAINS_URL}/`, method: "GET", }), + providesTags: ["Captains"], }), GetUnitCaptains: builder.query({ query: () => ({ url: `${CAPTAINS_URL}/`, method: "GET", }), + providesTags: ["Captains"], }), }), }); diff --git a/client/src/redux/slices/financeApiSlice.js b/client/src/redux/slices/financeApiSlice.js index c09ec1b4..0e8206b5 100644 --- a/client/src/redux/slices/financeApiSlice.js +++ b/client/src/redux/slices/financeApiSlice.js @@ -9,6 +9,7 @@ export const financeApi = apiSlice.injectEndpoints({ url: `${FINANCE_URL}`, method: "GET", }), + providesTags: ["finance"], }), }), }); diff --git a/client/src/redux/slices/scoutApiSlice.js b/client/src/redux/slices/scoutApiSlice.js index 5327df4d..354884cc 100644 --- a/client/src/redux/slices/scoutApiSlice.js +++ b/client/src/redux/slices/scoutApiSlice.js @@ -9,6 +9,7 @@ export const scoutsApi = apiSlice.injectEndpoints({ url: `${SCOUT_URL}/`, method: "GET", }), + providesTags: ["Scouts"] }), }), }); diff --git a/client/src/redux/slices/scoutsSlice.js b/client/src/redux/slices/scoutsSlice.js deleted file mode 100644 index d8a78a14..00000000 --- a/client/src/redux/slices/scoutsSlice.js +++ /dev/null @@ -1,26 +0,0 @@ -import { createSlice } from "@reduxjs/toolkit" - -const initialState = { - scouts: [] -} - -const scoutsSlice = createSlice({ - name: 'scouts', - initialState, - reducers: { - addScout: (state, action) => { - const newScout = { - name: action.payload.name, - gender: action.payload.gender, - sector: action.payload.sector, - } - state.scouts = [...state.scouts, newScout]; - }, - }, -}) - -export const { addScout } = scoutsSlice.actions - -export const selectScouts = (state) => state.scouts.scouts; - -export default scoutsSlice.reducer; \ No newline at end of file diff --git a/client/src/redux/slices/sectorApiSlice.js b/client/src/redux/slices/sectorApiSlice.js index cbc40dc4..35de3715 100644 --- a/client/src/redux/slices/sectorApiSlice.js +++ b/client/src/redux/slices/sectorApiSlice.js @@ -10,6 +10,7 @@ export const captainsApi = apiSlice.injectEndpoints({ method: "POST", body: sector, }), + invalidatesTags: ["Sector", "Captains"], }), UpdateSectorUnitCaptain: builder.mutation({ query: (sector) => ({ @@ -21,6 +22,7 @@ export const captainsApi = apiSlice.injectEndpoints({ suffixName: sector.suffixName, }, }), + invalidatesTags: ["Sector", "Captains"], }), }), }); diff --git a/client/src/redux/slices/statsApiSlice.js b/client/src/redux/slices/statsApiSlice.js index 13452ede..0b83eb43 100644 --- a/client/src/redux/slices/statsApiSlice.js +++ b/client/src/redux/slices/statsApiSlice.js @@ -9,6 +9,7 @@ export const statsApi = apiSlice.injectEndpoints({ url: `${STATS_URL}/scouts`, method: "GET", }), + providesTags: ["Stats", "absence"], }), }), }); diff --git a/client/src/redux/slices/termApiSlice.js b/client/src/redux/slices/termApiSlice.js index 737ca583..e302748c 100644 --- a/client/src/redux/slices/termApiSlice.js +++ b/client/src/redux/slices/termApiSlice.js @@ -9,18 +9,21 @@ export const termApi = apiSlice.injectEndpoints({ url: `${TERM_URL}/`, method: "GET", }), + providesTags: ["Term"], }), GetCurWeek: builder.query({ query: () => ({ url: `${TERM_URL}/week`, method: "GET", }), + providesTags: ["Weeks"], }), GetRemainingWeeks: builder.query({ query: () => ({ url: `${TERM_URL}/remaining`, method: "GET", }), + providesTags: ["Weeks"], }), InsertTerm: builder.mutation({ query: (term) => ({ @@ -28,6 +31,7 @@ export const termApi = apiSlice.injectEndpoints({ method: "POST", body: term, }), + invalidatesTags: ["Term", "Weeks"], }), UpdateTerm: builder.mutation({ query: (term) => ({ @@ -35,6 +39,7 @@ export const termApi = apiSlice.injectEndpoints({ method: "PATCH", body: term, }), + invalidatesTags: ["Term", "Weeks"], }), }), }); diff --git a/client/src/redux/slices/usersApiSlice.js b/client/src/redux/slices/usersApiSlice.js index e3d8e7f4..3d1fb386 100644 --- a/client/src/redux/slices/usersApiSlice.js +++ b/client/src/redux/slices/usersApiSlice.js @@ -10,6 +10,7 @@ export const usersApi = apiSlice.injectEndpoints({ method: "POST", body: credentials, }), + invalidatesTags: ["auth"], }), logout: builder.mutation({ query: () => ({ @@ -23,6 +24,7 @@ export const usersApi = apiSlice.injectEndpoints({ method: "POST", body: data, }), + invalidatesTags: ["Captains", "auth"], }), }), });