Skip to content
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
9 changes: 9 additions & 0 deletions public/icon/PickCha2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 36 additions & 12 deletions src/actions/external/getHtmlJustWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ProviderInfo } from '@/types/justwatch/providers';
export const getHtmlJustWatch = async (moviename: string) => {
const encode = encodeURIComponent(moviename);

const res = await fetch(`https://www.justwatch.com/kr/๊ฒ€์ƒ‰?q=${encode}`, {
const res = await fetch(`https://www.justwatch.com/kr/search?content_type=movie&q=${encode}`, {
//.json๋ง๊ณ  .textํ•ด์•ผํ•ด์„œ ๊ทธ๋ƒฅ fetch๋กœ
cache: 'force-cache',
headers: {
Expand All @@ -20,15 +20,39 @@ export const getHtmlJustWatch = async (moviename: string) => {
const $ = cheerio.load(html);

const providers: ProviderInfo[] = [];
$('.buybox-row a').each((_, el) => {
const $el = $(el);
const url = $el.attr('href') || '';
const logo = $el.find('img').attr('src');

if (url.startsWith('http') && !providers.some((p) => p.logo === logo)) {
providers.push({ url, logo });
}
});

return providers;
let matched = false;
const allowedProviders = ['netflix', 'watcha', 'disney', 'wavve'];

const firstTitleRow = $('.title-list-row__row').first();

//๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ์˜ ์ฒซ๋ฒˆ์งธ ํ•ญ๋ชฉ
const title = firstTitleRow.find('.title-list-row__column-header').text().trim();

// ๊ฒ€์ƒ‰์–ด๊ฐ€ ์˜ํ™” ์ œ๋ชฉ์— 'ํฌํ•จ' ๋˜์–ด ์žˆ๋Š”์ง€?
if (title.toLowerCase().includes(moviename.toLowerCase())) {
matched = true;

//์ฒซ๋ฒˆ์งธ ํ•ญ๋ชฉ ์•ˆ์˜ ํ”„๋กœ๋ฐ”์ด๋”๋“ค ์ค‘
firstTitleRow.find('.buybox-row a').each((_, el) => {
const $el = $(el);
const url = $el.attr('href') || '';
const logo = $el.find('img').attr('src');

const lowerUrl = url.toLowerCase();
if (
allowedProviders.some((p) => lowerUrl.includes(p)) && //[๋„ทํ”Œ, ๋””์ฆˆ๋‹ˆ, ์›จ์ด๋ธŒ, ์™“์ฑ ๋งŒ]
url.startsWith('http') &&
!providers.some((p) => p.logo === logo)
) {
const providerName = allowedProviders.find((p) => lowerUrl.includes(p));
const alreadyAdded = providers.some((p) => p.url.toLowerCase().includes(providerName!));

if (!alreadyAdded) {
providers.push({ url, logo });
}
}
});
}

return matched ? providers : [];
};
4 changes: 0 additions & 4 deletions src/actions/profile/getUserInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ export const getMyInfo = async () => {
};

export const getUserInfo = async (userid: number) => {
const session = await auth();
const accessToken = session?.accessToken;

return await fetcher(`${process.env.API_BASE_URL}/${process.env.TEST_TEAM_ID}/users/${userid}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
cache: 'no-store',
Expand Down
4 changes: 2 additions & 2 deletions src/app/(profile)/(component)/Activities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const Activities = async ({ userid }: Props) => {
<StatisticsCard title='๋‚จ๊ธด ๋ณ„์  ํ‰๊ท '>
<div className='text-yellow-ffc83c flex gap-[5px]'>
<StarIcon size={20} />
<span className='text-white-f1f1f5 light:text-gray-9fa6b2'>{RoundaverageRating}</span>
<span className='text-white-f1f1f5'>{RoundaverageRating}</span>
</div>
</StatisticsCard>

<StatisticsCard title='๋‚จ๊ธด ๋ฆฌ๋ทฐ'>
<div className='light:text-gray-9fa6b2 flex gap-[5px]'>
<div className='flex gap-[5px]'>
<ReviewIcon size={20} />
{data.reviewCount}
</div>
Expand Down
15 changes: 9 additions & 6 deletions src/app/(profile)/(component)/ProfileUpdateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useState } from 'react';

import { zodResolver } from '@hookform/resolvers/zod';
import { useSession } from 'next-auth/react';
import { useErrorBoundary } from 'react-error-boundary';
import { Controller, useForm } from 'react-hook-form';

import { patchProfileInfo } from '@/actions/profile/patchProfileInfo';
Expand All @@ -17,7 +16,6 @@ import { useUserInfoStore } from '@/store/userInfoStore';
import { profileSchema, type ProfileFormValues } from '@/types/profile/profileUpdateSchema';

const ProfileUpdateForm = () => {
const { showBoundary } = useErrorBoundary();
const { update } = useSession();
const closeModal = useModalStore((state) => state.closeModal);
const [isLoading, setIsLoading] = useState(false);
Expand All @@ -26,6 +24,8 @@ const ProfileUpdateForm = () => {
const description = useUserInfoStore((state) => state.description);
const image = useUserInfoStore((state) => state.image);

const [err, setError] = useState(false);

const {
register,
handleSubmit,
Expand Down Expand Up @@ -63,8 +63,8 @@ const ProfileUpdateForm = () => {
});

closeModal();
} catch (err) {
showBoundary(err);
} catch {
setError(true);
} finally {
setIsLoading(false);
}
Expand All @@ -86,6 +86,9 @@ const ProfileUpdateForm = () => {
maxLength={10}
defaultValue={nickname}
{...register('nickname')}
setError={setError}
errorMessage={err ? ' ' : ''}
className={err ? 'animate-shake' : ''}
/>

<Textbox
Expand All @@ -95,8 +98,8 @@ const ProfileUpdateForm = () => {
{...register('description')}
/>

<Button disabled={!isDirty || isLoading} className='my-5'>
{isLoading ? '์ €์žฅ ์ค‘...' : '์ €์žฅํ•˜๊ธฐ'}
<Button disabled={!isDirty || isLoading || err} className='my-5'>
{isLoading ? '์ €์žฅ ์ค‘...' : err ? '๋‹‰๋„ค์ž„์ด ์ค‘๋ณต๋˜์—ˆ์Šต๋‹ˆ๋‹ค' : '์ €์žฅํ•˜๊ธฐ'}
</Button>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/(profile)/(component)/StatisticsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props {

const ActivityCard = ({ title, children }: Props) => {
return (
<div className='border-black-353542 bg-black-252530 light:bg-white flex h-[119px] w-full min-w-[92px] flex-col items-center justify-center gap-[15px] rounded-[12px] xl:h-[128px] xl:gap-5'>
<div className='border-black-353542 bg-black-252530 flex h-[119px] w-full min-w-[92px] flex-col items-center justify-center gap-[15px] rounded-[12px] xl:h-[128px] xl:gap-5'>
<h3 className='text-mogazoa-14px-500 xl:text-mogazoa-16px-500 text-gray-9fa6b2 text-center break-keep'>
{title}
</h3>
Expand Down
4 changes: 2 additions & 2 deletions src/app/testTrailer/StreamingIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface Props {

export const StreamingIcon = ({ providers }: Props) => {
return (
<div className='relative inline-block'>
<h3 className='text-mogazoa-16px-600 text-black-2e2e3a mb-5'>๊ฐ์ƒํ•˜๊ธฐ</h3>
<div className='relative inline-block min-w-40'>
<h3 className='text-mogazoa-16px-600 text-black-2e2e3a mb-5'>{`๋ฐ”๋กœ ๊ฐ์ƒํ•˜๊ธฐ`}</h3>
<div className='inline-flex items-center'>
{providers.map((item) => (
<Link
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
if (maxLength) e.target.value = truncated(e.target.value, maxLength);
return e.target.value.length;
});
setError && setError(false);
if (setError) setError(false);
props.onChange?.(e);
}}
/>
Expand Down