Skip to content

Commit

Permalink
fix: accessToken処理を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
narirou committed Dec 5, 2024
1 parent 2c8e760 commit 45adb66
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
6 changes: 2 additions & 4 deletions frontend/app/contexts/client-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "~/api/api-components";
import { isClientApiError } from "~/types";
import { getCookieValue } from "~/utils/get-cookie-value";
import { getUserAccessToken, getUserId } from "~/utils/storage";
import { getUserId } from "~/utils/storage";

function jsonFromSSEResponse<T>(value: string) {
const data = value.slice("data:".length).trim();
Expand Down Expand Up @@ -140,13 +140,11 @@ export const useNotification = ():
type ClientContextProps = {
data?: AppGetNotificationResponse["data"];
userId?: string | null;
accessToken?: string | null;
};

const ClientContext = createContext<ClientContextProps>({});

export const ClientProvider = ({ children }: { children: ReactNode }) => {
const [accessToken] = useState(() => getUserAccessToken());
const [userId] = useState(() => getUserId());
const navigate = useNavigate();
const data = useNotification();
Expand All @@ -160,7 +158,7 @@ export const ClientProvider = ({ children }: { children: ReactNode }) => {
}, [navigate]);

return (
<ClientContext.Provider value={{ data, userId, accessToken }}>
<ClientContext.Provider value={{ data, userId }}>
{children}
</ClientContext.Provider>
);
Expand Down
7 changes: 2 additions & 5 deletions frontend/app/routes/client._index/driving-state/arrived.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ import { useClientContext } from "~/contexts/client-context";
import confetti from "canvas-confetti";

export const Arrived = ({ onEvaluated }: { onEvaluated: () => void }) => {
const { accessToken, data } = useClientContext();
const { data } = useClientContext();
const [rating, setRating] = useState(0);

const onClick: MouseEventHandler<HTMLButtonElement> = useCallback(
(e) => {
e.preventDefault();
try {
void fetchAppPostRideEvaluation({
headers: {
Authorization: `Bearer ${accessToken}`,
},
pathParams: {
rideId: data?.ride_id ?? "",
},
Expand All @@ -35,7 +32,7 @@ export const Arrived = ({ onEvaluated }: { onEvaluated: () => void }) => {
}
onEvaluated();
},
[onEvaluated, accessToken, data?.ride_id, rating],
[onEvaluated, data?.ride_id, rating],
);

useEffect(() => {
Expand Down
8 changes: 0 additions & 8 deletions frontend/app/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,3 @@ export const setUserId = (id: string) => {
export const getUserId = (): string | null => {
return getStorage("user.id", sessionStorage);
};

export const setUserAccessToken = (id: string) => {
return setStorage("user.accessToken", id, sessionStorage);
};

export const getUserAccessToken = (): string | null => {
return getStorage("user.accessToken", sessionStorage);
};

0 comments on commit 45adb66

Please sign in to comment.